Skip to content

Conversation

ooooo-create
Copy link
Contributor

@ooooo-create ooooo-create commented Aug 25, 2025

PR Category

Operator Mechanism

PR Types

Bug fixes

Description

Fix 0-size for as_strided grad and add bound check for as_strided
PaddleAPITest 中都是 torch error 的例子,所以添加了 check
另外自行测试了 paddle.as_strided(Tensor([0, 32],"float16"), shape=tuple(0,4,), stride=tuple(32,1,), ) 这种 case,修复反向 bug

修复 #74546 中暴露的 as_strided 0-size 问题

  1. 只在 tester\api_config\7_0_size\0_size_tensor_1_8_invalid_1.txt 有配置(Torch error)
图片 2. Pr 对齐 torch 的报错日志,但是仅仅是 0-size 的时候 3. 通过将 shape 某个设置为 0,测试新配置(Pr 修复反向之后可以通过) 图片 图片

Copy link

paddle-bot bot commented Aug 25, 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 Aug 25, 2025
@ooooo-create
Copy link
Contributor Author

/re-run all-failed

@ooooo-create
Copy link
Contributor Author

/re-run all-failed

@codecov-commenter
Copy link

codecov-commenter commented Aug 27, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (develop@d972f9c). Learn more about missing BASE report.

Additional details and impacted files
@@             Coverage Diff             @@
##             develop    #74860   +/-   ##
===========================================
  Coverage           ?   100.00%           
===========================================
  Files              ?         2           
  Lines              ?        10           
  Branches           ?         0           
===========================================
  Hits               ?        10           
  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.

@ooooo-create
Copy link
Contributor Author

/re-run all-failed

@ooooo-create
Copy link
Contributor Author

/re-run all-failed

Comment on lines 43 to 49
if (input.numel() != 0) {
size = 1;
for (int i = 0; i < input.dims().size(); i++) {
size += input.strides()[i] * (input.dims()[i] - 1);
}
memory_size = size * phi::SizeOf(dtype) + input.offset();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

CheckInBoundsForMemory中 input.numel() != 0 这个判断为true的分支目前永远不会被执行到,覆盖率到不到要求。而且无法豁免coverage的ci,请优化下此处。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. coverage ci 已经通过

@ooooo-create
Copy link
Contributor Author

/re-run all-failed

Copy link
Contributor

@DanielSun11 DanielSun11 left a comment

Choose a reason for hiding this comment

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

LGTM

@luotao1 luotao1 merged commit 5a3cbad into PaddlePaddle:develop Sep 15, 2025
57 of 59 checks passed
co63oc pushed a commit to co63oc/Paddle that referenced this pull request Sep 18, 2025
…k for as_strided (PaddlePaddle#74860)

* Fix 0-size for as_strided grad and add bound check for as_strided

* fix bugs

* fix bugs

* fix bugs

* refine code

* refine code

* refine code

* refine code to pass coverage ci
@ooooo-create ooooo-create deleted the accuracy_as_strided branch September 29, 2025 09:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants