In c++ side I really get hard time to find trivial things. I need to cast a LongTensor to FloatTensor. Can anyone guide me to find the solution in the c++ api documentation?
Here is the link and sample usage I guess:
auto my_float_tensor = at::_cast_Float(my_long_tensor);
the underscore naming of the function rises a question whether this function also changes the data type of the my_long_tensor
(like in-place notation) but the input tensor is const
so it can not.
The c++ api documentation needs a lot, I believe.
Just use
torch::Tensor longTensor = torch::randint(100, { 1 }, torch::kLong);
torch::Tensor floatTensor = longTensor.toType(torch::kFloat);
There are some examples over here