[API compatibility]add Tensor.type_as by Difers · Pull Request #74459 · PaddlePaddle/Paddle

@Difers

PR Category

User Experience

PR Types

New features

Description

Pcard-73145
增加paddle.Tensor.type_as

@paddle-bot

你的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.

@zhwesky2010 zhwesky2010 changed the title [API compatibility]add type_as [API compatibility]add Tensor.type_as

Aug 7, 2025

zhwesky2010

Choose a reason for hiding this comment

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

这个加一些测试吧

@codecov-commenter

Codecov Report

❌ Patch coverage is 83.33333% with 1 line in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (develop@2cd4ecd). Learn more about missing BASE report.

Files with missing lines Patch % Lines
python/paddle/base/layers/math_op_patch.py 50.00% 1 Missing ⚠️

❌ Your patch status has failed because the patch coverage (83.33%) 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   #74459   +/-   ##
==========================================
  Coverage           ?   83.33%           
==========================================
  Files              ?        3           
  Lines              ?        6           
  Branches           ?        0           
==========================================
  Hits               ?        5           
  Misses             ?        1           
  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.

SigureMo

@zhwesky2010

@Difers

zhwesky2010

return x.astype(y.dtype)


class TestTypeAsBase(unittest.TestCase):

Choose a reason for hiding this comment

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

你这个单测里没看到调用Tensor.type_as呢

Choose a reason for hiding this comment

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

笔误,已修改~

@Difers

zhwesky2010

Choose a reason for hiding this comment

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

LGTM

SigureMo

@Difers

XiaoguangHu01

Choose a reason for hiding this comment

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

LGTM

jeff41404

Choose a reason for hiding this comment

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

LGTM

maxiaolong001 pushed a commit to maxiaolong001/Paddle that referenced this pull request

Aug 13, 2025

@Difers @maxiaolong001