I want to develop an asynchronous op which takes a tensor as argument. Right now I have to check if op is finished and clear this tensor reference. I would like for the CPP op implementation’s callback clear this memory bu using Py_INCREF and Py_DECREF methods. But these methods take a PyObject*. Is it possible to get the PyObject* from a torch::Tensor
The way we do it internally is with PyObject * THPVariable_Wrap(at::Tensor t)` from torch/autograd/python_variable.h
Not sure if it is the cpp API way to do it though.