I follow the tutorial here:https://pytorch.org/tutorials/beginner/deploy_seq2seq_hybrid_frontend_tutorial.html 6
and successfully export a Torch Script.
But when I want to load it the script like this:
import torch
traced_encoder = torch.jit.load(‘traced_encoder.pth’)
print(traced_encoder)
test_seq = torch.LongTensor(10, 1).random_(0, 1000)
test_seq_length = torch.LongTensor([test_seq.size()[0]])
out,hidden = traced_encoder(test_seq,test_seq_length)
hidden = hidden[:2]
traced_decoder = torch.jit.load(‘traced_decoder.pth’)
print(traced_decoder)
test_decoder_input = torch.LongTensor(1, 1).random_(0, 1000)
d_out,d_hidden = traced_decoder(test_decoder_input,hidden,out)
print(d_out,d_out.shape)
#print(d_hidden,d_hidden.shape)
chatbot = torch.jit.load(‘traced_chatbot.pth’)
print(chatbot)
/-----------------------------------------------------------------------------
Output:
ScriptModule(
(embedding): ScriptModule()
(gru): ScriptModule()
)
ScriptModule(
(embedding): ScriptModule()
(gru): ScriptModule()
(concat): ScriptModule()
(out): ScriptModule()
)
tensor([[2.5321e-03, 7.4835e-05, 1.5321e-05,  …, 4.5948e-05, 1.4532e-05,
1.1714e-04]], grad_fn=) torch.Size([1, 7826])
Traceback (most recent call last):
File “load_chatbot.py”, line 15, in 
chatbot = torch.jit.load(‘traced_chatbot.pth’)
File “/home/twang/anaconda3/envs/pytorch1.0/lib/python3.6/site-packages/torch/jit/init.py”, line 85, in load
torch.C.import_ir_module(module_lookup, filename)
RuntimeError: it != value_type_map.end() ASSERT FAILED at /pytorch/torch/csrc/jit/import.cpp:276, please report a bug to PyTorch. (buildIntermediateValue at /pytorch/torch/csrc/jit/import.cpp:276)
frame #0:  + 0x49a8c0 (0x7f592ca738c0 in /home/twang/anaconda3/envs/pytorch1.0/lib/python3.6/site-packages/torch/lib/libtorch.so.1)
frame #1:  + 0x49ad52 (0x7f592ca73d52 in /home/twang/anaconda3/envs/pytorch1.0/lib/python3.6/site-packages/torch/lib/libtorch.so.1)
frame #2:  + 0x49b983 (0x7f592ca74983 in /home/twang/anaconda3/envs/pytorch1.0/lib/python3.6/site-packages/torch/lib/libtorch.so.1)
frame #3:  + 0x49bd32 (0x7f592ca74d32 in /home/twang/anaconda3/envs/pytorch1.0/lib/python3.6/site-packages/torch/lib/libtorch.so.1)
frame #4:  + 0x49c604 (0x7f592ca75604 in /home/twang/anaconda3/envs/pytorch1.0/lib/python3.6/site-packages/torch/lib/libtorch.so.1)
frame #5: torch::jit::import_ir_module(std::function<std::shared_ptr<torch: :jit::script::Module> (std::vector<std::string, std::allocator<std:: string> > const&)>, std::string const&) + 0x2f (0x7f592ca760bf in /home/twang/anaconda3/envs/pytorch1.0/lib/python3.6/site-packages/torch/lib/libtorch.so.1)
frame #6:  + 0x4799b1 (0x7f596464a9b1 in /home/twang/anaconda3/envs/pytorch1.0/lib/python3.6/site-packages/torch/_C.cpython-36m-x86_64-linux-gnu.so)
frame #7:  + 0x1b3c0d (0x7f5964384c0d in /home/twang/anaconda3/envs/pytorch1.0/lib/python3.6/site-packages/torch/_C.cpython-36m-x86_64-linux-gnu.so)

frame #21: __libc_start_main + 0xf5 (0x7f5989aecf45 in /lib/x86_64-linux-gnu/libc.so.6)
frame #22: python() [0x4009e9]
/-------------------------------------------------------------------------------------------------------------------------
I can load the encoder and decoder, but failed at the complete chatbot.
Anyone can help me ? Thank you!