-
Notifications
You must be signed in to change notification settings - Fork 6.8k
[MXNET-886] ONNX export: HardSigmoid, Less, Greater, Equal #12812
Conversation
d779756
to
9d40dff
Compare
|
||
if __name__ == '__main__': | ||
test_greater() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do not call each of the test methods separately. These tests are written based on pytest framework. You can say unittest.main()
. pytest at runtime will collect the tests that need to be run.
"""Test for logical greater in onnx operators.""" | ||
input1 = np.array([[ 1, 1, 1], [ 1, 1, 1]]).astype("float32") | ||
input2 = np.array([[ 0], [ 1]]).astype("float32") | ||
op = np.array([[ 1, 1, 1], [ 0, 0, 0]]).astype("float32") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do not hard code this operation. use np.greater
. Also can you please name this variable different, like expected_value
or numpy_op
or something like that.
"""Test for equal in onnx operators.""" | ||
input1 = np.array([[ 1, 1, 1], [ 1, 1, 1]]).astype("float32") | ||
input2 = np.array([[ 0], [ 1]]).astype("float32") | ||
op = np.array([[ 0, 0, 0], [ 1, 1, 1]]).astype("float32") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do not hard code this operation. use np.equal
. Also can you please name this variable different, like expected_value
or numpy_op
or something like that.
"""Test for lesser in onnx operators.""" | ||
input1 = np.array([[ 1, 1, 1], [ 1, 1, 1]]).astype("float32") | ||
input2 = np.array([[ 0], [ 1]]).astype("float32") | ||
op = np.array([[ 0, 0, 0], [ 0, 0, 0]]).astype("float32") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do not hard code this operation. use np.lesser
. Also can you please name this variable different, like expected_value
or numpy_op
or something like that.
f9ba301
to
ae66c1c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Vandana for adding these operators. Added few comments.
Also make sure you add this "tests/python-pytest/onnx/export/mxnet_export_test.py" file in CI
Thanks @Roshrini. Made the changes you suggested and submitted |
Thanks for fixing :) LGTM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@zhreshold for review |
test_mod.init_params() | ||
else: | ||
test_mod.set_params(arg_params=arg_params, aux_params=aux_params, allow_missing=True) | ||
# module bind method requires all data to have same batch size, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not use sym.bind whatsoever
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tests for batchnorm and conv2d alone fail due to missing keys. will debug further and update.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zhreshold Will debug this and submit a separate PR for this commit and InstanceNorm (which depends on this). This will make sure that HardSigmoid and the comparison operators can be reviewed/merged instead of waiting on this. Hope that's ok.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vandanavk making sure only high quality code get merged into master is critical. Having pushing feature request isn't a good reason to bypass this restriction.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed @zhreshold. Opened a WIP PR #12920 to continue debug.
The changes in this PR on HardSigmoid and comparison operators are not impacted by the changes in PR #12920.
mod.bind(for_training=False, data_shapes=data_shapes, | ||
label_shapes=None) | ||
mod.set_params(arg_params=self.arg_params, aux_params=self.aux_params) | ||
# module bind method requires all data to have same batch size, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
duplicate in onnx_export.py
@zhreshold Please let me know if there are any other inputs on this PR. If this PR is good to go, I can rebase my other PRs on top of this. |
@vandanavk What is the PR that is going to correct the repetitive importing? |
@zhreshold This PR #12878 |
please rebase to changes in #12878 |
Rebased. Ready for review again |
37aa0aa
to
cb5e291
Compare
@zhreshold @sandeep-krishnamurthy @nswamy Could you please help with review/merge? |
@@ -238,6 +238,63 @@ def test_square(): | |||
|
|||
npt.assert_almost_equal(result, numpy_op) | |||
|
|||
@with_seed() | |||
def test_greater(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am seeing that a lot of repetitions in the test code. Could you please modularize the test code? happy to discuss offline
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nswamy @vandanavk was the concern addressed offline? what's the status of this PR?
77e0bf1
to
9d440cf
Compare
5cc157e
to
de4c390
Compare
Description
Added support for exporting HardSigmoid, Less, Greater, Equal to ONNX.
v2: Addressed @anirudhacharya's comments on the tests for comparison operators.
Checklist
Essentials
Please feel free to remove inapplicable items for your PR.
Changes
Comments