Skip to content
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

[Feature] Support for NonZero ONNX operator #4568

Closed
antimora opened this issue Dec 23, 2019 · 3 comments
Closed

[Feature] Support for NonZero ONNX operator #4568

antimora opened this issue Dec 23, 2019 · 3 comments

Comments

@antimora
Copy link

Filing this ticket to request support for NonZero ONNX operator which has been available since version 9 of the default ONNX operator set. Since PyTorch 1.2, ONNX exports with opset 9 as default (And currently Pytorch only exports with 9 and 10 opset versions).

Unless there is some work around this deficiency I cannot use my model with the latest version ( master@e6ff3f701b2bf3e2204709aea392b0abdf6a85d0).

Here is a small model to recreate the issue:
trouble.zip. Zip includes onnx, onnxtxt and graph files.

Here is python code to try with:

import onnx
import numpy as np
import tvm
import tvm.relay as relay

onnx_model = onnx.load('trouble.onnx')

input1 = np.random.rand(1, 192, 100)
input2 = np.random.rand(1)

target = 'llvm'

shape_dict = {'0': input1.shape, '1': input2.shape}
mod, params = relay.frontend.from_onnx(onnx_model, shape_dict)

Here is the error message:

rroot@future:/workspace# /usr/bin/python3 /workspace/trouble_onnx.py
Traceback (most recent call last):

  File "/workspace/trouble_onnx.py", line 15, in <module>
    mod, params = relay.frontend.from_onnx(onnx_model, shape_dict)

  File "/workspace/python/tvm/relay/frontend/onnx.py", line 1601, in from_onnx
    mod, params = g.from_onnx(graph, opset)

  File "/workspace/python/tvm/relay/frontend/onnx.py", line 1406, in from_onnx
    raise tvm.error.OpNotImplemented(msg)

tvm.error.OpNotImplemented: The following operators are not supported for frontend ONNX: NonZero

Please note this onnx model will also fail with missing Expand operator for the tvm 0.6 version but this has been fixed by: #4483

@antimora
Copy link
Author

antimora commented Dec 23, 2019

Related TVM discussion: https://discuss.tvm.ai/t/onnx-nonzero-operator

@gussmith23
Copy link
Contributor

I've been trying to get a GNMT model importing into Relay. The ONNX route seems the most pain-free; however, this is a blocking issue!

@tqchen
Copy link
Member

tqchen commented Mar 19, 2020

#5073 thanks to @cchung100m

@tqchen tqchen closed this as completed Mar 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants