For anyone interested, I’ve also summarized the other set of issues that can be generated by the script in this table:

Expand Table


Model type
Add type
Exportability
Export backend
Error
Notes




Torch Script
No add
Made exportable
Onnx 13
Exporting the operator linear to ONNX opset version 13 is not supported. Please feel free to request support or submit a pull request on PyTorch GitHub



Torch Script
With add
Made exportable
Onnx 13
add() takes from 3 to 4 positional arguments but 5 were given
This is a quantized add. Inspecting the generated code clearly shows that 4 arguments are passed: add_1 = ops.quantized.add(passthrough_1, passthrough_1, 1., 0)… The arguments are (tensor_a, tensor_b, scale, zero_point).


Torch Script
No add; with add
Not made exportable
Onnx 13
Exporting the operator quantize_per_tensor to ONNX opset version 13 is not supported. Please feel free to request support or submit a pull request on PyTorch GitHub.



Pytorch
No add; with add
Made exportable; not made exportable
Onnx 13
‘torch.dtype’ object has no attribute ‘detach’
Maybe exporting thinks some dtype member variable is a parameter and is trying to detach it. However, I found no such dtype member variable within the model.


Torch Script
No add
Made exportable
Caffe2
RuntimeError: false INTERNAL ASSERT FAILED at /pytorch/torch/csrc/jit/passes/onnx/unpack_quantized_weights.cpp:94, please report a bug to PyTorch. Unrecognized quantized operator while trying to compute q_scale for operator prim::Param



Torch Script
With add; No add
Not made exportable
Caffe2
RuntimeError: Expected node type ‘onnx::Constant’ for argument ‘zero_point’ of node ‘quantize_per_tensor’, got ‘prim::Param’.



Torch Script
With add
Made exportable
Caffe2
No error
Only case without an error