I am exploring pt2e quantization and want to quantize a torchscript model using pt2e, but I failed to convert a torchscript to torch.export.
I wonder if there any chance to get a torch.export model given a torchscript? Thanks.
import torch
m = torch.nn.Conv2d(3, 3, 3)
m = torch.jit.script(m)
inputs = (torch.rand(1, 3, 32, 32), )
m(*inputs)
import torch.export._trace
torch.export._trace._export(m, inputs, pre_dispatch=True)
# torch.export.export(m, inputs) # This also failed if the input is scriptmodule
Error message:
gm_torch_level, _ = torch._dynamo.export(
File ".../python3.8/site-packages/torch/_dynamo/eval_frame.py", line 1356, in inner
assert (
AssertionError: Failed to produce a graph during tracing as no tensor operations were found.