How can I save some tensor in python, but load it in libtorch:
I save tensor named piror using python, using the code:
torch.save(prior, 'prior.pth')
And I load the tensor in libtorch using C++, by the following code:
std::vector<torch::Tensor> tensorVec;
torch::load(tensorVec, "/app/model/prior.pth");
torch::Tensor priors = tensorVec[0];
But I got the error:
terminate called after throwing an instance of ‘c10::Error’
what(): torch::jit::load()
received a file from torch.save()
, but torch::jit::load()
can only load files produced by torch.jit.save()
(load at …/torch/csrc/jit/serialization/import.cpp:285)
Why is that? And what should I do to solve the issue? Thanks in advance.