How to change torch.Tensor into C++ version

Hi, is it possible to modify a 4d tensor in python so that it can be called and used in C++ file?

Say I have a C++ function which is called and used in another file in python language. I have a 4d torch.Tensor in my python file and I have also called my function from C++ file to my python file. I want to pass that tensor to my function so that my function can do max pooling on the tensor.

How can I pass the tensor by reference to my C++ file?

The usual way of using C++ functions from Python is in the C++ extension tutorial. As you see there, Python torch.Tensors are automatically converted when you declare your function to take torch::Tensor & (optionally with const).

Best regards

Thomas