Hello everyone.
I am working with Torchscript on PyTorch 1.5.0.
I want to automatically grab input shape & dtype information from a deserialized, traced torchscript model with the following code line:
[(i.debugName().split('.')[0], i.type().sizes(), i.type().scalarType()) for i in
list(reloaded_module.graph.inputs())[1:]]
The Problem is that this gives me None for both the size and the scalarType when i deserialize the model.
On the other hand, when i execute the same line of code on a non-deserialized model (e.g. a just-in-time traced model that has not been serialized&deserialized) i get the desired results.
You should be able to reproduce this through just a few lines of code.
model = torch.hub.load('pytorch/vision:v0.6.0', 'resnet18', pretrained=True)
input_image = "get an image from somewhere"
traced_path = "./test.pt"
traced_module = torch.jit.trace(model,input_batch)
traced_module.save(traced_path)
reloaded_module = torch.jit.load(traced_path)
print([(i.debugName().split('.')[0], i.type().sizes(), i.type().scalarType()) for i in list(traced_module.graph.inputs())[1:]])
print([(i.debugName().split('.')[0], i.type().sizes(), i.type().scalarType()) for i in list(reloaded_module.graph.inputs())[1:]])
Any suggestions on solutions? Am i missing something or is this actually a bug in Torch-Serialization/Deserialization?
Best regards,
Knight3