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.

(Will Feng) #2

We don’t support forwarding arbitrary C++ object as a tensor through the network at the moment. I’d recommend opening a feature request at https://github.com/pytorch/pytorch/issues for us to better understand your use case. Thanks!