I guess it is because “torch::Tensor” is not bound in pybind11, but how to bind it? And make the bound “torch::Tensor” and “pytorch tensor” the same type?
Yes, PyTorch can do it, but you need to import the right header, I think
#include <torch/extension.h>
will do the trick.
The background is that the Python bits are the thing you would not want to include when you are using libtorch purely in C++, so you want more than just torch/torch.h if you use Python.