-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
【Hackathon 5th No.15】 为 Paddle 新增 Tensor.to() 以及 Layer.astype() API -part #58244
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
@zhwesky2010 目前ci还剩3个没有过,codestyle是因为 |
for dtype in valid_dtypes: | ||
net = net.astype(dtype) | ||
typex_str = str(net._dtype) | ||
self.assertEqual((typex_str == "paddle." + dtype), True) |
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.
测一下 实际parameter参数的dtype吧,这个只测了layer.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.
新增了对layer param以及buffer的类型测试
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
@@ -40,6 +45,10 @@ def test_layer_astype(self): | |||
net = net.astype(dtype) | |||
typex_str = str(net._dtype) | |||
self.assertEqual((typex_str == "paddle." + dtype), True) | |||
param_typex_str = str(net.parameters()[0].dtype) | |||
self.assertEqual((param_typex_str == "paddle." + dtype), True) |
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.
这里直接使用 self.assertTrue(param_typex_str, 'paddle.' + 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/nn/layer/layers.py
Outdated
If set str, it can be "bool", "float16", "float32", "float64", | ||
"int8", "int16", "int32", "int64", "uint8", "complex64", "complex128". |
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.
should add bfloat16
?
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.
Done
python/paddle/nn/layer/layers.py
Outdated
"dtype value error, must be 'bfloat16', 'float16', 'float32', 'float64', 'int8', 'int16', 'int32', 'int64', 'uint8', 'uint16', 'complex64', 'complex128', 'bool', or paddle.dtype, numpy.dtype, but recieve " | ||
+ str(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.
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.
Done
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
Co-authored-by: zachary sun <70642955+sunzhongkai588@users.noreply.github.com>
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, 用 pre-commit 修一下风格检查的问题吧
昨天已经修过了,目前codestyle的CI已经过了 |
@YibinLiu666 请提交对应的中文文档 |
hi, @YibinLiu666
|
…part (PaddlePaddle#58244) * support tensor.to and layer.astype * add UT and comments * update * update com * update dtype * fix example test * update example * add some ut to fix ci-coverage * fix codestyle * fix codestyle * update * add ut to test layer params' and buffers' type * update test * fix doc * Update python/paddle/base/dygraph/tensor_patch_methods.py Co-authored-by: zachary sun <70642955+sunzhongkai588@users.noreply.github.com> * update doc --------- Co-authored-by: zachary sun <70642955+sunzhongkai588@users.noreply.github.com>
…part (PaddlePaddle#58244) * support tensor.to and layer.astype * add UT and comments * update * update com * update dtype * fix example test * update example * add some ut to fix ci-coverage * fix codestyle * fix codestyle * update * add ut to test layer params' and buffers' type * update test * fix doc * Update python/paddle/base/dygraph/tensor_patch_methods.py Co-authored-by: zachary sun <70642955+sunzhongkai588@users.noreply.github.com> * update doc --------- Co-authored-by: zachary sun <70642955+sunzhongkai588@users.noreply.github.com>
PR types
New features
PR changes
APIs
Description
RFC: PaddlePaddle/community#690