Update nonzero onnx export (#18047)
authorBowenBao <semisqg@gmail.com>
Fri, 15 Mar 2019 05:13:11 +0000 (22:13 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Fri, 15 Mar 2019 05:19:20 +0000 (22:19 -0700)
commit8f07a9da30945781dd7c73264506e158d66b333c
tree756a864578f86fa82cc2effc21db59e91e033c84
parente21aa16931f20a7b75a2de5fb32df21782b551c2
Update nonzero onnx export (#18047)

Summary:
The output format of NonZero in ONNX(numpy https://docs.scipy.org/doc/numpy/reference/generated/numpy.nonzero.html) differs from that in PyTorch:
In ONNX: `[rank_of_input, num_of_nonzeros]`, whereas in PyTorch: `[num_of_nonzeros, rank_of_input]`.
To resolve the difference a Transpose op after the nonzero output is added in the exporter.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18047

Differential Revision: D14475081

Pulled By: ezyang

fbshipit-source-id: 7a3e4899f3419766b6145d3e9261e92859e81dc4
test/onnx/expect/TestOperators.test_nonzero.expect
torch/onnx/symbolic.py