Skip to content

Conversation

TomWildenhain-Microsoft
Copy link
Collaborator

Signed-off-by: Tom Wildenhain [email protected]

@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

@TomWildenhain-Microsoft TomWildenhain-Microsoft force-pushed the tom/reduce_all_any_nonconst_axis branch from a5a4d07 to a2ae60d Compare August 9, 2021 23:26

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
Collaborator 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.

@TomWildenhain-Microsoft TomWildenhain-Microsoft force-pushed the tom/reduce_all_any_nonconst_axis branch from fa6b652 to f98cdb1 Compare August 9, 2021 23:45
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
Collaborator 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 enabled auto-merge (squash) August 12, 2021 18:29
@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.

3 participants