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

Implement reduce all/any for non-const axes #1657

Merged
merged 5 commits into from Aug 12, 2021

Conversation

TomWildenhain-Microsoft
Copy link
Contributor

Signed-off-by: Tom Wildenhain tomwi@microsoft.com

@lgtm-com
Copy link

lgtm-com bot commented Aug 9, 2021

This pull request introduces 1 alert when merging a5a4d07 into becdcba - view on LGTM.com

new alerts:

  • 1 for Unused local variable

@@ -3557,29 +3557,29 @@ def func(x):
self._run_test_case(func, [_OUTPUT], {_INPUT: input_val})

def test_reduce_all(self):
input_val = np.random.randint(0, 2, (10, 20)).astype(np.bool)
input_val = np.random.randint(0, 2, (2, 20)).astype(np.bool)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

10 isn't great since there's a only a 1/1024 chance of them all matching. 20 sets of size 2 is good.

Signed-off-by: Tom Wildenhain <tomwi@microsoft.com>
reduce_input = node.input[0]
if node.type == "All":
reduce_input = ctx.make_node("Not", [reduce_input]).output[0]
cast = ctx.make_node("Cast", inputs=[reduce_input], attr={"to": onnx_pb.TensorProto.FLOAT}).output[0]
Copy link
Collaborator

Choose a reason for hiding this comment

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

I was wondering why it is necessary to cast into float?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, good question. I copied over the existing code and just modified it to do dynamic axes. I think one of the previous ops maybe didn't support non-float values. In any case, float is technically good because it doesn't roll over and is guaranteed to preserve monotonicity of addition. Since we just want to detect if any of the values are non-zero, this is good.

@TomWildenhain-Microsoft TomWildenhain-Microsoft merged commit fe2a433 into master Aug 12, 2021
@TomWildenhain-Microsoft TomWildenhain-Microsoft deleted the tom/reduce_all_any_nonconst_axis branch August 12, 2021 19:17
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.

None yet

3 participants