Repository navigation
Conversation
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.
Summary
Preserve reduced dimensions in
MNN.numpy.mean(..., axis=None, keepdims=True).The documented
keepdimsargument currently has no effect whenaxisis omitted: the wrapper always ravels the input and returns a scalar. For example, a float32 vector[-1.5, -1.0, -0.5]returns-1.0rather than a variable with shape[1]and value[-1.0].Keep the existing scalar path for
axis=None, keepdims=False. For the retained-dimension path, pass the original input and an empty axis list to the existing reduction. No changes tovar,std, or dtype handling. No numerical kernel changes.Tests
Extend the existing
test_statisticsmethod with 28 mean cases covering ranks 1–4, singleton dimensions, omitted and explicit nonnegative axes, both keepdims settings, values, and input preservation. The original statistics assertions remain unchanged.math.fsumreference passes 168 mean cases and 504 combined mean/var/std cases. All 252 False controls and 336 var/std results retain exact return types, shapes, and values when this fix is added.Local validation uses the source-built native Expr binding and pristine CPU libraries from
45a002ab19f9021e982ed153826586bb79e41837, with a namespace bootstrap that loads Expr/NumPy without optional package imports. The two affected source files are byte-identical at the current basef8585f650ad92c67bfb65ac8bd8e32481e266ecb. This is focused native CPU validation, not a full Python-package suite, a fresh build of the latest master, or GPU/device validation.AI assistance was used for implementation and review.