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.
I also get ImportError mypacakge.cpython-38-x86_64-linux-gnu.so: undefined symbol: _Z16THPVariable_WrapN2at10TensorBaseE
I added #include <torch/extension.h> in my cpp file, but still it doens’t work