-
Notifications
You must be signed in to change notification settings - Fork 5.9k
[API Compatibility]API supports functionality checks for paddle.dtype #74545
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
Conversation
|
你的PR提交成功,感谢你对开源项目的贡献! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
看大部分只修改了文档,这些已经验证过了 paddle.dtype都是支持的对吧?
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #74545 +/- ##
==========================================
Coverage ? 86.36%
==========================================
Files ? 8
Lines ? 44
Branches ? 0
==========================================
Hits ? 38
Misses ? 6
Partials ? 0 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
一般来说应该不会有paddle.dtype不支持的情况,唯一的可能情况是在静态图模式传入了paddle.dtype,或者动态图传入VarType;我可以再写个脚本检测一下这两种情况完善一下~ |
有一个低成本的测试方式,在这个里面把所有的 'float32' 都改成 paddle.float32 这种,然后提交下CI看单测都能不能过,之前是发现无法通过,才只能将torch.dtype映射到字符串,这个工作完成了按道理 就应该将 torch.dtype映射到paddle.dtype |
a7d490d to
8810ba5
Compare
已根据该方案进行了本地测试与修改,等本PR合入后,再看一下PaConvert单测是否能全部通过,如有遗漏,后续会再提PR补充;另,相关api注释涉及较多,也后续另提pr修改,方便查看。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
那dtype文档后面再统一修改吧,这个也挺乱的
python/paddle/amp/auto_cast.py
Outdated
|
|
||
| # check amp_dtype: float16 or bfloat16 | ||
| dtype = dtype.lower() | ||
| if isinstance(dtype, str): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这些逻辑可以写一个公共函数,将所有输入的dtype归一化成str类型
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已修改~
python/paddle/tensor/creation.py
Outdated
| """ | ||
| if not isinstance(dtype, core.VarDesc.VarType): | ||
| if dtype is None: | ||
| dtype = paddle.get_default_dtype() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get_default_dtype仅针对浮点型的,这个是int32或64
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已修改~
8810ba5 to
b27be74
Compare
|
/re-run all-failed |
8a5b809 to
e469440
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
e469440 to
8bca1f5
Compare
|
API benchmark没过,rerun再试试 |
|
/re-run all-failed |
|
@Difers API-benchmark还是没过,应该新增加的python判断分支导致的,看看怎么精简一下python判断逻辑
|
b6f3ab1 to
417bdd2
Compare
4d55f93 to
9be6d21
Compare
1c603b7 to
f55116b
Compare
| """ | ||
| if use_pir_api(): | ||
| if isinstance(np_dtype, core.DataType): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里的判断是不是就不需要了,一般会在外面判断了
if isinstance(np_dtype, (core.DataType, core.VarDesc.VarType)):
...
|
|
||
| if isinstance(np_dtype, core.VarDesc.VarType): | ||
| return np_dtype | ||
| return convert_np_dtype_to_proto_type(np_dtype) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
python/paddle/tensor/math.py
Outdated
| dtype = x.dtype | ||
| if not isinstance(dtype, (core.VarDesc.VarType, core.DataType)): | ||
| dtype = convert_np_dtype_to_dtype_(dtype) | ||
| if dtype is not None and x.dtype != dtype: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里dtype还有None的情况吗,会不会导致多判断了一次
python/paddle/tensor/math.py
Outdated
| dtype = x.dtype | ||
| if not isinstance(dtype, (core.VarDesc.VarType, core.DataType)): | ||
| dtype = convert_np_dtype_to_dtype_(dtype) | ||
| if dtype is not None and x.dtype != dtype: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同上
|
|
||
| if in_dynamic_or_pir_mode(): | ||
| if dtype is not None: | ||
| if dtype is not None and x.dtype != dtype: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里dtype没有None的情况
python/paddle/tensor/math.py
Outdated
| dtype = x.dtype | ||
| if not isinstance(dtype, (core.VarDesc.VarType, core.DataType)): | ||
| dtype = convert_np_dtype_to_dtype_(dtype) | ||
| if dtype is not None and x.dtype != dtype: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里dtype没有None的情况
python/paddle/tensor/math.py
Outdated
| x = cast(x, dtype) | ||
| if dtype is None and paddle.is_tensor(x): | ||
| dtype = x.dtype | ||
| if dtype is not None and x.dtype != dtype: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里dtype没有None的情况
|
需要再优化一下上面的分支逻辑判断,提升下性能。 |
39cc60d to
c7e40bd
Compare
|
/re-run all-failed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
c7e40bd to
631a8cc
Compare
|
/re-run all-failed |
2 similar comments
|
/re-run all-failed |
|
/re-run all-failed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM



PR Category
Operator Mechanism
PR Types
Improvements
Description
Pcard-73145
根据comment:#74545 (comment)