Repository: pytorch
Issue: C++ model load error
Labels: oncall: jit,triaged

I got error when load model from a tracing typescripts model. The trace model is simple:

```python
import torch
import torchvision
from torchvision import transforms
from PIL import Image
from time import time
import numpy as np

# An instance of your model.
model = torchvision.models.resnet18(pretrained=True)
model.eval()

# An example input you would normally provide to your model's forward() method.
example = torch.rand(1, 3, 224, 224)

# Use torch.jit.trace to generate a torch.jit.ScriptModule via tracing.
traced_script_module = torch.jit.trace(model, example)
traced_script_module.save("resnet50_typescripts.pt")

# evalute time
batch = torch.rand(64, 3, 224, 224)
start = time()
output = traced_script_module(batch)
stop = time()
print(str(stop - start) + "s")

# read image
image = Image.open('dog.png').convert('RGB')
default_transform = transforms.Compose([
    transforms.Resize([224, 224]),
    transforms.ToTensor(),
    transforms.Normalize(mean=[0.485, 0.456, 0.406],
                         std=[0.229, 0.224, 0.225])
])
image = default_transform(image)

# forward
output = traced_script_module(image.unsqueeze(0))
print(output[0, :10])

# print top-5 predicted labels
labels = np.loadtxt('synset_words.txt', dtype=str, delimiter='\n')

data_out = output[0].data.numpy()
sorted_idxs = np.argsort(-data_out)

for i, idx in enumerate(sorted_idxs[:5]):
    print('top-%d label: %s, score: %f' % (i, labels[idx], data_out[idx]))
```

C++ program is load that model, but even load can not pass. (Build is success)

And error got:
```
terminate called after throwing an instance of 'c10::Error'
  what():  file_format_version <= kMaxSupportedFileFormatVersion ASSERT FAILED at /pytorch/caffe2/serialize/inline_container.h:213, please report a bug to PyTorch. Attempted to read a PyTorch file with version %llu, but the maximum supported version for reading is %llu. Your PyTorch installation may be too old.21 (readAndValidateFileHeader at /pytorch/caffe2/serialize/inline_container.h:213)
frame #0: std::function<std::string ()>::operator()() const + 0x11 (0x7f7a85d6b0d1 in /pt_codes/pt_cpp/libtorch/lib/libc10.so)
frame #1: c10::Error::Error(c10::SourceLocation, std::string const&) + 0x2a (0x7f7a85d6a99a in /pt_codes/pt_cpp/libtorch/lib/libc10.so)
frame #2: <unknown function> + 0x5cb0b0 (0x7f7ab9d900b0 in /pt_codes/pt_cpp/libtorch/lib/libtorch.so.1)
frame #3: <unknown function> + 0x5cb681 (0x7f7ab9d90681 in /pt_codes/pt_cpp/libtorch/lib/libtorch.so.1)
frame #4: <unknown function> + 0x5c8cb6 (0x7f7ab9d8dcb6 in /pt_codes/pt_cpp/libtorch/lib/libtorch.so.1)
frame #5: torch::jit::load(std::istream&) + 0xb4 (0x7f7ab9d8eb64 in /pt_codes/pt_cpp/libtorch/lib/libtorch.so.1)
frame #6: torch::jit::load(std::string const&) + 0x27 (0x7f7ab9d8ec37 in /pt_codes/pt_cpp/libtorch/lib/libtorch.so.1)
frame #7: <unknown function> + 0x8e9b (0x559c7be0ce9b in ./build/ptcpp)
frame #8: __libc_start_main + 0xe7 (0x7f7a853edb97 in /lib/x86_64-linux-gnu/libc.so.6)
frame #9: <unknown function> + 0x801a (0x559c7be0c01a in ./build/ptcpp)

```

What is wrong with current c++ API? I think it is a bug or something? because the error message is not well printed though.

cc @suo