Passing python object reference to c++ extension?

Good day everyone ,

Maybe some one knows how to properly handle torch.data_ptr() ? . I want to pass address of tensor to c++ extension of pytorch .

Main idea is to minimize host to device and device to host usage . Is it possible to pass address of pytorch tensor(python) to pytorch( c++) extension and then use it as normal tensor? . Or it’s better just to rewrite everything in pytorch c++ frontend