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
Implement reduce all/any for non-const axes #1657
Conversation
This pull request introduces 1 alert when merging a5a4d07 into becdcba - view on LGTM.com new alerts:
|
a5a4d07
to
a2ae60d
Compare
@@ -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) |
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.
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>
fa6b652
to
f98cdb1
Compare
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] |
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 was wondering why it is necessary to cast into float?
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.
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.
Signed-off-by: Tom Wildenhain tomwi@microsoft.com