I am trying to access PyTorch from c code. This needs creating a tensor in c which I can pass to a function in python. I used to do this with torch like this:
   THFloatTensor* tensor = THFloatTensor_newWithSize3d( 3, rows,cols);

and pass to the lua functions.
But this won’t work anymore since now I need a python object. One workaround would be to use numpy arrays as a interface. I can create a numpy array from c and pass this to python code and create a PyTorch tensor from this numpy object. But this means I have to link my project against numpy as well and this seems to be unnecessarily complicated. Can someone please suggest some better alternative.
PS:
This discussion is doing the exact opposite thing–returning from python  to c  Constructing PyTorch's CUDA tensor from C++ with image data already on GPU:
Thanks.