-
Notifications
You must be signed in to change notification settings - Fork 5.9k
【Hackathon 5th No.33】 reshape more dtype and test -part #58764
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
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,请对应修改下 reshape 的中文文档
python/paddle/tensor/manipulation.py
Outdated
| Args: | ||
| x (Tensor): An N-D Tensor. The data type is ``float32``, ``float64``, ``int32``, ``int64`` or ``bool`` | ||
| x (Tensor): An N-D Tensor. The data type is ``float16``, ``float32``, ``float64``, ``int16``, ``int32``, ``int64``, ``uint16``, ``int8``, ``uint8``, ``complex64``, ``complex128``, ``bfloat16`` or ``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.
no official support for uint16, should delete uint16?
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 use bfloat16 to hold uint16, so no official support for uint16?
In [42]: x = paddle.to_tensor(123, dtype='uint16')
In [43]: x
Out[43]:
Tensor(shape=[], dtype=bfloat16, place=Place(cpu), stop_gradient=True,
123.)
In [46]: x = paddle.to_tensor(65535, dtype='uint16')
In [47]: x
Out[47]:
Tensor(shape=[], dtype=bfloat16, place=Place(cpu), stop_gradient=True,
65280.)| 'int32', | ||
| 'int64', | ||
| 'bool', | ||
| 'uint16', |
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.
same issue of uint16
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.
numpy not support bfloat16, numpy uint16 is paddle bfloat16, so bfloat16 should be removed from check_variable_and_dtype, and keep uint16:
python/paddle/tensor/manipulation.py
check_variable_and_dtype(
x,
'x',
[
'float16',
'float32',
'float64',
'int16',
'int32',
'int64',
'bool',
'uint16',
'int8',
'uint8',
'complex64',
'complex128',
],
'reshape',
)But remove uint16 & keep bfloat6 in unittest:
test/legacy_test/test_reshape_op.py
def _test_static_dtype(self):
places = [paddle.CPUPlace()] + (
[paddle.CUDAPlace(0)] if base.core.is_compiled_with_cuda() else []
)
dtypes = [
'float16',
'float32',
'float64',
'int16',
'int32',
'int64',
'int8',
'uint8',
'complex64',
'complex128',
'bfloat16',
'bool',
]
...right?
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.
Yes, there is a historical issue with function check_variable_and_dtype, which temporarily use uint16 instead of bfloat16 in its parameters. We will make unified revisions in the future. So keep uint16 as parameter of check_variable_and_dtype in python/paddle/tensor/manipulation.py temporarily and use bfloat16 instead of uint16 in unittest
test/legacy_test/test_reshape_op.py
Outdated
| 'int16', | ||
| 'int32', | ||
| 'int64', | ||
| 'uint16', |
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.
same issue of uint16
|
PR-CI-Codestyle-Check 需要过一下 |
@luotao1 我在本地 pre-commit 是过了的 ~ 我看 ci 日志,不像是格式的问题? |
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
…#58764) * [Change] reshape more dtype and test * [Fix] remove uint16 * [Change] use uint16 instead of bfloat16
…#58764) * [Change] reshape more dtype and test * [Fix] remove uint16 * [Change] use uint16 instead of bfloat16
PR types
Function optimization
PR changes
APIs
Description
修改
reshape静态图中数据类型检查,增加支持:并增加相应单元测试。
涉及文件:
python/paddle/tensor/manipulation.py修改数据支持类型test/legacy_test/test_reshape_op.py增加单测关联 PR: #58323