Hello,
I have a question about using serialization API in C++. I want to load model’s weights in C++ program, and save them in python one.
In python I’m doing next:
class MaskRCNN(nn.Module):
...
  def save_weights():
    torch.save(self.state_dict(), self.checkpoint_path.format(epoch))
...

In C++ I’m trying to load saved weights in the next way:
torch::serialize::InputArchive archive;
archive.load_from(params_path);

But this code fails with exception:
tag == RecordTags::FOOTER ASSERT FAILED at /development/lib/sources/pytorch/caffe2/serialize/inline_container.h:234, please report a bug to PyTorch. File footer has wrong record type. Is this file corrupted? (readAndValidateFileFooter at /development/lib/sources/pytorch/caffe2/serialize/inline_container.h:234)
frame #0: c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) + 0x6c (0x7f6a66008e3c in /home/kirill/development/lib/lib/libc10.so)
frame #1: <unknown function> + 0x5ccc90 (0x7f6a7ce8dc90 in /home/kirill/development/lib/lib/libtorch.so.1)
frame #2: <unknown function> + 0x5cd6b4 (0x7f6a7ce8e6b4 in /home/kirill/development/lib/lib/libtorch.so.1)
frame #3: torch::jit::load(std::istream&) + 0x2af (0x7f6a7ce8c6ff in /home/kirill/development/lib/lib/libtorch.so.1)
frame #4: torch::jit::load(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) + 0x51 (0x7f6a7ce8c961 in /home/kirill/development/lib/lib/libtorch.so.1)
frame #5: torch::serialize::InputArchive::load_from(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) + 0x21 (0x7f6a7d057c91 in /home/kirill/development/lib/lib/libtorch.so.1)
frame #6: main + 0x5ce (0x55bd69bd3538 in /home/kirill/development/mlcpp/mask_rcnn_pytorch/build/mask-rcnn)
frame #7: __libc_start_main + 0xf3 (0x7f6a64c7d223 in /usr/lib/libc.so.6)
frame #8: _start + 0x2e (0x55bd69bd2bae in /home/kirill/development/mlcpp/mask_rcnn_pytorch/build/mask-rcnn)

In python and can successfully load and use saved weights in the next way
model.load_state_dict(torch.load(weights_file_name))

Could you tell me if I misuse API, and it’s incompatible? What functions I should use to solve my problem, if they a exist now?
Thanks, in advance.