Can libtorch return torch::Tensor to pytorch with pybind11?

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.

Best regards

Thomas