Got stuck in TorchScript Trace

Hi,

Basically, I have built the deep learning model which takes dynamic inputs with different shapes,

so how do I trace the model here?

usually, we trace the model using the below command

example = torch.rand(1, 3, 224, 224)
traced_script_module = torch.jit.trace(model, example)

but then, in my scenario, I pass dynamic input ndarray with different shapes
eg:

1. example = torch.rand(1, 3, 224, 224)
2. example = torch.rand(1, 3, 224, 550)
3. example = torch.rand(1, 3, 640, 480)

could you please help me understand and how to implement this?

@ptrblck @ppwwyyxx @driazati
#jit #deployment

You would have to torch.jit.script the model instead of tracing.
The next stable release will use the nvfuser backend during scripting which has dynamic shape support.

thanks for the reply @ptrblck , I will try to save the model by torch.jit.script and get back to you.