Skip to content

Conversation

@taomiao
Copy link
Contributor

@taomiao taomiao commented Jan 11, 2024

nonzero_numpy is not working correctly #16389

@taomiao taomiao changed the title fix a typo mistake fix a typo mistake #16389 Jan 11, 2024
@taomiao taomiao changed the title fix a typo mistake #16389 fix a typo mistake in nonzero_numpy Jan 11, 2024
@taomiao taomiao force-pushed the fix/nonzero_numpy_mistake branch from 0c20c01 to 10926f8 Compare January 11, 2024 12:10
@taomiao taomiao changed the title fix a typo mistake in nonzero_numpy [relay][frontend] fix a typo mistake in nonzero_numpy Jan 12, 2024
@taomiao taomiao changed the title [relay][frontend] fix a typo mistake in nonzero_numpy [Relay][Frontend][Torch] fix a typo mistake in nonzero_numpy Jan 12, 2024
@taomiao
Copy link
Contributor Author

taomiao commented Jan 12, 2024

@junrushao @t-vi Do you think this change is appropriate? Can you help me review it?


def nonzero_numpy(self, inputs, input_types):
return self.nonzero(inputs, input_types, is_numpy_style=False)
return self.nonzero(inputs, input_types, is_numpy_style=True)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch!

"""Module that performs nonzero"""

def __init__(self):
super().__init__()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't actually need this init, and in the test also the docstring.
Also I'd probably make the class definition local to the test to have it all in one place.

import_input = [("input0", (2, 10)), ("input1", (2, 10))]
relay_model_ir, relay_model_params = tvm.relay.frontend.from_pytorch(
traced_torch_model, import_input
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer the test to go in one of the other files (e.g. test_forward.py).
Also, I think it might be best to add a check that PyTorch and TVM actually give the same result (like the other tests in test_forward.py).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see there is a test "test_forward_nonzero" (test_forward.py:4435). added a line there

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you,

Copy link
Contributor

@t-vi t-vi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the fix, I think there might be improvements to the testing.

@taomiao taomiao force-pushed the fix/nonzero_numpy_mistake branch from 10926f8 to c3e5663 Compare January 12, 2024 09:30
@taomiao taomiao requested a review from t-vi January 12, 2024 09:38
Copy link
Contributor

@t-vi t-vi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! Thank you, @taomiao !

@masahi masahi merged commit 196b413 into apache:main Jan 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants