How to forward a c++ object as a tensor through the network?


(x10000year) #1

In a complicated model, I have several complex custom c++ ops that generate and receive c++ objects. (De)serializing the c++ objects into byte tensors is not a good solution as it incurs serialization overhead. This can be done in tensorflow (graph mode) by storing the c++ object as the state the the custom c++ op and forward it’s raw pointer as a tensor. How can I do similar thing in pytorch?

Thanks.