-
Notifications
You must be signed in to change notification settings - Fork 5.8k
在paddle.tensor中加入float,int和complex等数据转换接口 #73351
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
base: develop
Are you sure you want to change the base?
Conversation
modified: python/paddle/base/dygraph/math_op_patch.py new file: test/legacy_test/test_tensor_float16_bfloat16.py
@@ -104,6 +104,26 @@ def astype(self: Tensor, dtype: DTypeLike) -> Tensor: | |||
|
|||
return _C_ops.cast(self, dtype) | |||
|
|||
def float16(self: Tensor) -> Tensor: |
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.
这个是不是得整体加,包括fp32、fp64、int32等所有类型,而不是给某两个类型增加一个函数。
实现方式建议通过一个公共函数,批量注册
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.
嗯,收到,已修改为通过公共函数批量注册
Sorry to inform you that 701fe26's CIs have passed for more than 7 days. To prevent PR conflicts, you need to re-run all CIs manually. |
modified: python/paddle/base/dygraph/math_op_patch.py modified: test/legacy_test/test_tensor_float16_bfloat16.py
renamed: test/legacy_test/test_tensor_float16_bfloat16.py -> test/legacy_test/test_tensor_type_convert_api.py
modified: python/paddle/pir/math_op_patch.py modified: test/legacy_test/test_tensor_type_convert_api.py
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #73351 +/- ##
===========================================
Coverage ? 100.00%
===========================================
Files ? 2
Lines ? 30
Branches ? 0
===========================================
Hits ? 30
Misses ? 0
Partials ? 0 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
'int32': 'int32', | ||
'int64': 'int64', | ||
# other | ||
'bool': 'bool', |
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.
这个应该还有一些其他的用法吧,或者别名用法,也需要配置一下:
x.long、x.double、x.cfloat、x.uint8
这个要配全
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.
嗯,收到,已修改,之前是按照上面的文档的tensor type写的
@@ -37,6 +37,23 @@ | |||
DataType.INT64, | |||
] | |||
|
|||
_supported_dtype_conversions = { |
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.
同上
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.
已修改
Unit tests for all supported tensor dtype conversion methods. | ||
""" | ||
|
||
_supported_dtype_conversions = { |
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.
同上
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.
已修改
modified: python/paddle/base/dygraph/math_op_patch.py modified: python/paddle/pir/math_op_patch.py modified: test/legacy_test/test_tensor_type_convert_api.py
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
Sorry to inform you that 5dc2126's CIs have passed for more than 7 days. To prevent PR conflicts, you need to re-run all CIs manually. |
PR Category
User Experience
PR Types
Improvements
Description
当前问题
paddle中没有float16和bfloat16等数据转换接口,需要用astype转换
解决方案
注册float16和bfloat16等数据转换接口