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

[hannk] Fix MeanOp #6336

Merged
merged 4 commits into from
Nov 3, 2021
Merged

[hannk] Fix MeanOp #6336

merged 4 commits into from
Nov 3, 2021

Conversation

steven-johnson
Copy link
Contributor

@steven-johnson steven-johnson commented Oct 20, 2021

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.

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.
@steven-johnson
Copy link
Contributor Author

Gentle Review Ping

if (index < 0) {
index += in->rank();
}
index = in->rank() - 1 - index;
Copy link
Contributor

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?

Copy link
Contributor Author

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

@dsharletg dsharletg merged commit 2cf3afb into master Nov 3, 2021
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.

2 participants