Skip to content

[Cpp API Compatibility] add all & allclose API#77542

Open
Le-soleile wants to merge 31 commits intoPaddlePaddle:developfrom
Le-soleile:all
Open

[Cpp API Compatibility] add all & allclose API#77542
Le-soleile wants to merge 31 commits intoPaddlePaddle:developfrom
Le-soleile:all

Conversation

@Le-soleile
Copy link
Contributor

@Le-soleile Le-soleile commented Jan 27, 2026

PR Category

Execute Infrastructure

PR Types

New features

Description

新增 all & allclose 兼容接口

是否引起精度变化

@paddle-bot
Copy link

paddle-bot bot commented Jan 27, 2026

你的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 Jan 27, 2026
@Le-soleile
Copy link
Contributor Author

/re-run all-failed

@Le-soleile
Copy link
Contributor Author

/re-run all-failed

@Le-soleile
Copy link
Contributor Author

/re-run all-failed

1 similar comment
@Le-soleile
Copy link
Contributor Author

/re-run all-failed

// Read the value from the tensor (could be bool, int8, int32, etc.)
auto dtype = result_tensor->dtype();
if (dtype == phi::DataType::BOOL) {
bool* bool_ptr = result_tensor->data<bool>();
Copy link
Contributor

Choose a reason for hiding this comment

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

确认一下paddle::experimental::allclose返回结果的tensor是什么,如果是逐个元素的比较结果,这里的处理就不对,本地做一下实验,将tensor打印出来看一下(type和data),保存好实验结果

Copy link
Contributor Author

@Le-soleile Le-soleile Feb 24, 2026

Choose a reason for hiding this comment

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

image

输出结果:

image

分析:

  1. paddle::experimental::allclose() 返回的是标量 Tensor(shape=[], numel=1)。
  2. dtypepaddle.bool
  3. 代码中已检查了 numel != 1 的情况。
  4. 代码能够正确从 BOOL dtype 中提取对应的值。
image

@Le-soleile
Copy link
Contributor Author

/re-run all-failed

2 similar comments
@Le-soleile
Copy link
Contributor Author

/re-run all-failed

@Le-soleile
Copy link
Contributor Author

/re-run all-failed

@Le-soleile
Copy link
Contributor Author

/re-run all-failed

3 similar comments
@Le-soleile
Copy link
Contributor Author

/re-run all-failed

@Le-soleile
Copy link
Contributor Author

/re-run all-failed

@Le-soleile
Copy link
Contributor Author

/re-run all-failed

@Le-soleile
Copy link
Contributor Author

/re-run xpu test

@Le-soleile
Copy link
Contributor Author

/re-run all-failed

1 similar comment
@Le-soleile
Copy link
Contributor Author

/re-run all-failed

@Le-soleile
Copy link
Contributor Author

/re-run all-failed

} else {
PD_THROW("allclose: unsupported result dtype");
}
}
Copy link
Member

Choose a reason for hiding this comment

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

allallclose 的实现是否可以放在 all.hallclose.h?同时暴露 at::allat::allclose

Copy link
Member

Choose a reason for hiding this comment

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

添加后需要像 https://github.com/PaddlePaddle/Paddle/pull/78037/changes#diff-5847905442941e26d93374313b0e119d01f39267c25427c467c7829150972c06paddle/phi/api/include/compat/ATen/Functions.h 将相关函数 include 过来,以便用户使用

at::Tensor absolute() const { return abs(); }

at::Tensor& absolute_() const { return abs_(); }

Copy link
Member

Choose a reason for hiding this comment

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

这个空行不用删吧

SigureMo
SigureMo previously approved these changes Feb 27, 2026
@Le-soleile
Copy link
Contributor Author

/re-run all-failed

@Le-soleile
Copy link
Contributor Author

/re-run all-failed

@Le-soleile
Copy link
Contributor Author

/re-run all-failed

@codecov-commenter
Copy link

codecov-commenter commented Mar 2, 2026

Codecov Report

❌ Patch coverage is 72.50000% with 11 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (develop@acee55a). Learn more about missing BASE report.

Files with missing lines Patch % Lines
paddle/phi/api/include/compat/ATen/ops/allclose.h 57.69% 11 Missing ⚠️

❌ Your patch status has failed because the patch coverage (72.50%) is below the target coverage (90.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             develop   #77542   +/-   ##
==========================================
  Coverage           ?   72.50%           
==========================================
  Files              ?        2           
  Lines              ?       40           
  Branches           ?        0           
==========================================
  Hits               ?       29           
  Misses             ?       11           
  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.

@Le-soleile
Copy link
Contributor Author

/re-run all-failed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor External developers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants