-
Notifications
You must be signed in to change notification settings - Fork 24.3k
[ONNX] Exported ONNX module with for loop + scatter operation on tensor seems to be incorrect #29647
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
jit scripts have many issues with ONNX now. You should try to find a way to export without jit.script for example find a single |
hi @julioasotodv, thanks for reporting this issue. |
@BowenBao sure! Let me try it and see what happens... |
@BowenBao now there is no error; when this line runs: caffe_model = backend.prepare(model) The Python process segfaults... I don't know if this error is due to my environment (I just updated pytorch to 1.3.1 from conda channel and onnx 1.6.0 from pip), or if the exception now turned to a segmentation fault. |
With latest version of PyTorch built from TorchScript graph:
ONNX graph (from export(verbose=True)):
Tracked internally at Microsoft by https://msdata.visualstudio.com/Vienna/_workitems/edit/1600858 |
Closing this as Caffe2 is being removed from pytorch repo (#125038) |
Uh oh!
There was an error while loading. Please reload this page.
🐛 Bug
It looks like creating a nn.Module with the combination of:
for
loop that loops over a tensorGenerates an inaccurate onnx file that the official
onnx
library cannot load correctly.To Reproduce
Please take a look at the following code (don't worry; it is not as long as it looks):
The
onnx.checker.check_model(model)
fails with:What is weird is that onnxruntime is able to load and perform inference without any problem (it even outputs the right result and seems to capture the dynamic flow). However, the onnx library does not seem to agree.
Expected behavior
The exported onnx file should be compatible with onnx, and caffe2 should be able to emit the same output as onnxruntime.
Environment
Pytorch == 1.3.0 (on OSX, pre-built binary from pytorch's conda channel)
onnxruntime == 0.5.0
onnx == 1.5.0
Additional context
The for loop (in this case iterating over rows in a matrix) + updating iteratively a tensor using scatter is IMO a frequent operation in dynamic flows such as custom attention modules.
Thank you!
cc @houseroad @spandantiwari @lara-hdr @BowenBao @neginraoof
The text was updated successfully, but these errors were encountered: