Repository navigation
Honor the dtype argument of aten::mean.dim before reducing - #3067
Open
Raashish Aggarwal (raashish1601) wants to merge 1 commit into
Open
Raashish Aggarwal (raashish1601) wants to merge 1 commit into
Raashish Aggarwal (raashish1601) wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
aten_mean_dimapplied thedtypeargument afterReduceMean, so the mean was computed in the input type and only the result was cast. #3009 fixed this foraten::mean(nodim), butaten::mean.dimstill has the old order. For an integer input this truncates:and for float inputs it keeps the input precision (e.g.
[1e8, 1, -1e8]in float32 withdtype=float64gives 0 instead of 1/3).The cast now happens before the reduction, like in
aten_mean. The rank check runs before the cast, because in full-graph mode the output ofCasthas no static shape.Testing:
ops.aten.mean.dim_dtypeOpInfo (several shapes and dims, plus the precision-sensitive sample from Honor the dtype argument of aten::mean when exporting without dim #3009) and registered it foraten_mean_dim. It fails onmainand passes with the change.pytest tests/function_libs/torch_lib/ops_test.py -k meanpasses locally (9 passed, 68 subtests), and ruff check / format are clean on the changed files.