Skip to content

Conversation

@huangjiyi
Copy link
Member

@huangjiyi huangjiyi commented Oct 31, 2025

PR Category

User Experience

PR Types

Bug fixes

Description

支持 tensor dtype 用 is 进行比较,is 底层是对象指针的比较,之前用 is 比较有问题是因为每次获取 tensor dtype 都会创建一个类型为对应 dtype 的新 python 对象,本次 PR 通过返回 Python 枚举对象单例来解决该问题

示例代码:

import paddle
a = paddle.tensor(1, dtype="float32")
if a.dtype is paddle.float32:
	pass

@paddle-bot
Copy link

paddle-bot bot commented Oct 31, 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.

SigureMo
SigureMo previously approved these changes Oct 31, 2025
zhwesky2010
zhwesky2010 previously approved these changes Nov 3, 2025
Copy link
Contributor

@zhwesky2010 zhwesky2010 left a comment

Choose a reason for hiding this comment

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

LGTM

@huangjiyi huangjiyi dismissed stale reviews from zhwesky2010 and SigureMo via 9af150a November 3, 2025 13:17
@huangjiyi huangjiyi merged commit cce2771 into PaddlePaddle:develop Nov 4, 2025
84 of 89 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants