-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[hannk] Fix MeanOp #6336
[hannk] Fix MeanOp #6336
Conversation
The `reducing()` method didn't handle negative values for indices, and didn't reverse the value of the axis as we do elsewhere, so results were incorrect. Also, we now parse and save the value of `keep_dims`, though I can't find evidence that it does much of anything: test cases pass different values for it but none of them fail (even though we ignore it), and at least one reference implementation I see doesn't seem to do anything with it.
Gentle Review Ping |
if (index < 0) { | ||
index += in->rank(); | ||
} | ||
index = in->rank() - 1 - index; |
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.
This is pretty sketchy, having a mix of dimension indices using the Halide convention and TFlite convention is going to lead to bugs. In this case it's tricky because the dimension comes from a buffer. I wonder if we should just not allow reduction indices to be runtime variables, and make this a vector of indices at parse time?
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.
True, but unfortunately it exists elsewhere already too -- e.g., ReshapeOp allows for the new shape to be an arbitrary Tensor, and (AFAICT) there's no constraint that requires that the new-shape-tensor be constant at parse time (it could be dynamic in theory). Same story here. (I haven't actually found such a case in practice, so maybe it's de facto not legal.)
(But yeah, having the conventions be different is a big pain and the source of various bugs over time. I don't like mixing them either.)
The
reducing()
method didn't handle negative values for indices, and didn't reverse the value of the axis as we do elsewhere, so results were incorrect.Also, we now parse and save the value ofkeep_dims
, though I can't find evidence that it does much of anything: test cases pass different values for it but none of them fail (even though we ignore it), and at least one reference implementation I see doesn't seem to do anything with it.