Load tensors saved in python from c++ and vice versa


#1

Hello,
I noticed that I can’t read tensor from .pt file saved in python with torch.save() from c++ with torch::load() and I can’t read tensor from file saved in c++ with torch::save() from python with torch.load()
I read that PyTorch uses different formats to save tensors in python with pickle and in c++ it seems to be zip with tensors inside, but maybe are there any ways to transfer tensors between python and c++?
Thanks a lot


(Justus Schock) #2

As far as I know, C++ uses the torch.jit serialization. Have you tried saving/loading it via torch.jit?


#3

It is not possible. torch.jit.save() can only save ScriptModule but not a tensor