@Wu_jiang You should use the torch::mm variant and replace all mentions of at::Tensor to torch::Tensor in your function, because at::Tensor is now an implementation detail and torch::Tensor is the preferred way of representing a tensor.
For in-place setting values of a torch::TensorOptions, here is an example:
auto options =
torch::TensorOptions()
.requires_grad(false)
.is_variable(true)
.device(weights.device())
.dtype(weights.dtype());