Skip to content

[Cpp API Compatibility] Align ScalarType related APIs#78806

Merged
SigureMo merged 3 commits into
PaddlePaddle:developfrom
youge325:cAlign-scalar-type
Apr 29, 2026
Merged

[Cpp API Compatibility] Align ScalarType related APIs#78806
SigureMo merged 3 commits into
PaddlePaddle:developfrom
youge325:cAlign-scalar-type

Conversation

@youge325
Copy link
Copy Markdown
Contributor

@youge325 youge325 commented Apr 25, 2026

PR Category

Execute Infrastructure

PR Types

New features

Description

拆分自 #78707

为 C++ 兼容层(compat)补充 PyTorch 对齐的 ScalarType 辅助工具函数与量化类型支持:

  • c10/core/ScalarType.h 中新增:
    • isBitsType / isBarebonesUnsignedType:位宽类型与裸无符号类型判断
    • toQIntType:将基础类型映射为对应的量化类型
    • isUnderlying / toRealValueType / toComplexType:类型转换与校验
    • canCast:类型间可转换性检查(拒绝复数→实数、浮点→整数、非 Bool→Bool 等非法转换)
  • torch/headeronly/core/ScalarType.h 中新增:
    • isQIntType:量化整数类型判断
    • toUnderlying:量化类型到其底层类型的映射
  • test/cpp/compat/c10_ScalarType_test.cc 新增单测,覆盖上述全部辅助函数的行为对齐。

是否引起精度变化

Copilot AI review requested due to automatic review settings April 25, 2026 07:54
@paddle-bot
Copy link
Copy Markdown

paddle-bot Bot commented Apr 25, 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 Apr 25, 2026
Copy link
Copy Markdown
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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

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

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

@youge325
Copy link
Copy Markdown
Contributor Author

/re-run all-failed

Copy link
Copy Markdown
Member

@SigureMo SigureMo left a comment

Choose a reason for hiding this comment

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

LGTMeow 🐾

@SigureMo SigureMo merged commit 2c4c7f6 into PaddlePaddle:develop Apr 29, 2026
138 of 143 checks passed
@youge325 youge325 deleted the cAlign-scalar-type branch April 29, 2026 02:00
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