Skip to content

Conversation

@LLSGYN
Copy link
Contributor

@LLSGYN LLSGYN commented Aug 28, 2025

PR Category

User Experience

PR Types

New features

Description

paddle.mean, paddle.Tensor.mean支持dtype和out参数。未下沉至c++实现。

@paddle-bot
Copy link

paddle-bot bot commented Aug 28, 2025

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

>>> out4 = paddle.mean(x, axis=[0, 2])
>>> print(out4.numpy())
[ 8.5 12.5 16.5]
"""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

只用处理 dtype != None的情况,减少非必要的判断

@LLSGYN LLSGYN force-pushed the feat/op_mean_naive branch from 7a817fb to 6895a04 Compare August 28, 2025 14:04
@codecov-commenter
Copy link

codecov-commenter commented Aug 28, 2025

Codecov Report

❌ Patch coverage is 92.85714% with 1 line in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (develop@3b2c4a1). Learn more about missing BASE report.

Files with missing lines Patch % Lines
python/paddle/tensor/stat.py 91.66% 1 Missing ⚠️
Additional details and impacted files
@@ Coverage Diff @@ ## develop #74955 +/- ## ========================================== Coverage ? 92.85% ========================================== Files ? 2 Lines ? 14 Branches ? 0 ========================================== Hits ? 13 Misses ? 1 Partials ? 0 

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
if not isinstance(dtype, (core.VarDesc.VarType, core.DataType)):
dtype = convert_np_dtype_to_dtype_(dtype)
if x.dtype != dtype:
x = cast_(x, dtype)
Copy link
Contributor

@zhwesky2010 zhwesky2010 Aug 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里非inplace的API就用cast,inplace的API用cast_,之前修改的同学有些也改错了。一起更正下吧。

# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这些单测case直接加到原来的test_mean_op里去吧

np.testing.assert_allclose(result.numpy(), expected, rtol=1e-05)

@skip_if_xpu_or_onednn_and_not_float32('float64')
def test_all_parameters_combination(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

反向也跑下吧

@LLSGYN LLSGYN force-pushed the feat/op_mean_naive branch from 6895a04 to de2afce Compare August 29, 2025 06:58
zhwesky2010
zhwesky2010 previously approved these changes Aug 29, 2025
Copy link
Contributor

@zhwesky2010 zhwesky2010 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zhwesky2010 zhwesky2010 requested a review from SigureMo August 29, 2025 07:32
SigureMo
SigureMo previously approved these changes Aug 29, 2025
XiaoguangHu01
XiaoguangHu01 previously approved these changes Aug 29, 2025
Copy link
Contributor

@XiaoguangHu01 XiaoguangHu01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@LLSGYN LLSGYN force-pushed the feat/op_mean_naive branch from b53ce8a to 437a633 Compare August 29, 2025 16:05
Copy link
Contributor

@zhwesky2010 zhwesky2010 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zhwesky2010 zhwesky2010 merged commit 0a80351 into PaddlePaddle:develop Aug 30, 2025
91 of 94 checks passed
@LLSGYN LLSGYN deleted the feat/op_mean_naive branch August 30, 2025 04:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment