Skip to content

[0-size Tensor Retest No.4] fix shape diff for matrix_rank when input is 0-size tensor #73263

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 12, 2025

Conversation

DanielSun11
Copy link
Contributor

@DanielSun11 DanielSun11 commented Jun 11, 2025

PR Category

Execute Infrastructure

PR Types

Bug fixes

Description

修复了当输入为0 size Tensor时,输出的shape和torch不对齐的error。

回测问题

image

  • 非法参数。输入的最后两个维度不等的检查没过
  • 一些情况输出shape不对

修复方法

通过和torch进行对比,采用的修复方法如下:

  • 如果输入是0-size Tensor即使hermitian=True 也无需检查矩阵是否是方阵。
  • 如果输入是0-size且为二维矩阵则输出shape为[] ,0-dim
  • 如果tol或者atol或者rtol不为None,则输出的shape为x.dims()[:-2],即输入shape删掉最后两个dim
  • atol或者rtol不为None时调用的是_C_ops.matrix_rank_atol_rtol,已经修改infermeta,无对应的infer_symbolic_shape函数
  • tol不为None时调用的是_C_ops.matrix_rank_tol,已经同步修改infermeta和infer_symbolic_shape函数
  • 其他调用_C_ops.matrix_rank,已经同步修改infermeta和infer_symbolic_shape函数

PaddleAPITest 回测

CPU
image

GPU

image

pcard-67164

Copy link

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

wanghuancoder
wanghuancoder previously approved these changes Jun 12, 2025
Copy link
Contributor

@wanghuancoder wanghuancoder left a comment

Choose a reason for hiding this comment

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

LGTM

zyfncg
zyfncg previously approved these changes Jun 12, 2025
@luotao1 luotao1 merged commit 3a63fd5 into PaddlePaddle:develop Jun 12, 2025
47 of 50 checks passed
DrRyanHuang pushed a commit to DrRyanHuang/Paddle that referenced this pull request Jun 14, 2025
… is 0-size tensor (PaddlePaddle#73263)

* fix the matrix rank shape diff  [0-size input]

* rm unused func
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants