Skip to content

Conversation

@Liyulingyue
Copy link
Contributor

PR Category

User Experience

PR Types

Others

Description

#65043

@Liyulingyue Liyulingyue requested a review from Copilot July 6, 2025 23:50
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds validation for the chunks parameter in paddle.chunk and corresponding error-case tests.

  • Enforces that chunks must be >0 and ≤ the size of the specified (non-negative) axis.
  • Raises ValueError when chunks is out of range.
  • Adds unit tests for negative and too-large chunks values.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
test/legacy_test/test_chunk_op.py Added tests for chunks=-1 and chunks>dim to ensure errors.
python/paddle/tensor/manipulation.py Inserted a guard to validate chunks bounds and raise ValueError.
Comments suppressed due to low confidence (2)

test/legacy_test/test_chunk_op.py:63

  • Add a test case for a negative axis (e.g., axis=-1) with chunks larger than that dimension to verify the validation logic for negative axes.
 def test_negative_chunks_tensor(): 

python/paddle/tensor/manipulation.py:4487

  • The current check only covers non-negative axes. Negative axis values (e.g., -1) bypass this validation and may lead to inconsistent behavior; consider normalizing negative axes before comparing against x.shape.
 isinstance(axis, int) and axis >= 0 and chunks > x.shape[axis] 
>>> # out2.shape [3, 3, 5]
"""
check_type(chunks, 'chunks', (int), 'chunk')
# check the chunks value to avoid the meanless split operation, such as <=0 or > x.shape[axis]
Copy link

Copilot AI Jul 6, 2025

Choose a reason for hiding this comment

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

Minor spelling issue: change 'meanless' to 'meaningless' in the comment.

Suggested change
# check the chunks value to avoid the meanless split operation, such as <=0 or > x.shape[axis]
# check the chunks value to avoid the meaningless split operation, such as <=0 or > x.shape[axis]
Copilot uses AI. Check for mistakes.
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (develop@1b1ad5a). Learn more about missing BASE report.

Additional details and impacted files
@@ Coverage Diff @@ ## develop #73857 +/- ## =========================================== Coverage ? 100.00% =========================================== Files ? 1 Lines ? 2 Branches ? 0 =========================================== Hits ? 2 Misses ? 0 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.
@paddle-bot
Copy link

paddle-bot bot commented Jul 7, 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.

@paddle-bot paddle-bot bot added the contributor External developers label Jul 7, 2025
@luotao1 luotao1 added the HappyOpenSource 快乐开源活动issue与PR label Jul 7, 2025
@lshpku lshpku merged commit 7071cd1 into PaddlePaddle:develop Jul 8, 2025
53 of 54 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor External developers HappyOpenSource 快乐开源活动issue与PR

4 participants