How to use kDouble type input for Linear layer in C++

We use

linear3(register_module("linear3",torch::nn::Linear(100,out_sz)))

to create a Linear layer. However it looks like that the default type of it is kFloat. If x is kDouble type, then linear3->forward(x) will generate an error.

Then how do we use double type data as input?

I found that one can use

model.to(torch::kDouble);

to cast parameters of the whole model to double type.