Skip to content
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

Merged
merged 16 commits into from
Nov 9, 2023

Conversation

YibinLiu666
Copy link
Contributor

PR types

New features

PR changes

APIs

Description

RFC: PaddlePaddle/community#690

@paddle-bot
Copy link

paddle-bot bot commented Oct 19, 2023

你的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.

@YibinLiu666
Copy link
Contributor Author

#57262

@YibinLiu666
Copy link
Contributor Author

@zhwesky2010 目前ci还剩3个没有过,codestyle是因为python/paddle/base/dygraph/tensor_patch_methods.py存在部分方法没有doc,PR-CI-Static-Check没过好像是没有经过审批,PR-CI-Paddle-Doc-Preview 报错FileNotFoundError: [Errno 2] No such file or directory: '/docs/en/develop/api/paddle/audio/backends_en.html',不清楚具体原因。能否麻烦老师帮忙review一下。

@luotao1
Copy link
Contributor

luotao1 commented Nov 2, 2023

codestyle是因为python/paddle/base/dygraph/tensor_patch_methods.py存在部分方法没有doc

image 错误是格式问题,不是没有doc的问题,请根据提示里的precommit命令修改下。

for dtype in valid_dtypes:
net = net.astype(dtype)
typex_str = str(net._dtype)
self.assertEqual((typex_str == "paddle." + dtype), True)
Copy link
Contributor

Choose a reason for hiding this comment

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

测一下 实际parameter参数的dtype吧,这个只测了layer.dtype

Copy link
Contributor Author

Choose a reason for hiding this comment

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

新增了对layer param以及buffer的类型测试

zhwesky2010
zhwesky2010 previously approved these changes Nov 6, 2023
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

@@ -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)
Copy link
Contributor

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) 不更简洁吗,建议后面可以优化下写法

Copy link
Contributor Author

Choose a reason for hiding this comment

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

已经优化写法,麻烦老师有空的时候再次审核一下

zhwesky2010
zhwesky2010 previously approved these changes Nov 7, 2023
Comment on lines 929 to 930
If set str, it can be "bool", "float16", "float32", "float64",
"int8", "int16", "int32", "int64", "uint8", "complex64", "complex128".
Copy link
Contributor

Choose a reason for hiding this comment

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

should add bfloat16?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Comment on lines 998 to 999
"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)
Copy link
Contributor

Choose a reason for hiding this comment

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

should delete uint16?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

jeff41404
jeff41404 previously approved these changes Nov 8, 2023
Copy link
Contributor

@jeff41404 jeff41404 left a comment

Choose a reason for hiding this comment

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

LGTM

YibinLiu666 and others added 2 commits November 8, 2023 12:34
Co-authored-by: zachary sun <70642955+sunzhongkai588@users.noreply.github.com>
Copy link
Contributor

@sunzhongkai588 sunzhongkai588 left a comment

Choose a reason for hiding this comment

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

LGTM, 用 pre-commit 修一下风格检查的问题吧

@YibinLiu666
Copy link
Contributor Author

LGTM, 用 pre-commit 修一下风格检查的问题吧

昨天已经修过了,目前codestyle的CI已经过了

@luotao1 luotao1 changed the title 【Hackathon 5th No.15】 为 Paddle 新增 Tensor.to() 以及 Layer.astype() API 【Hackathon 5th No.15】 为 Paddle 新增 Tensor.to() 以及 Layer.astype() API -part Nov 9, 2023
@luotao1
Copy link
Contributor

luotao1 commented Nov 9, 2023

@YibinLiu666 请提交对应的中文文档

@luotao1 luotao1 merged commit 2927ed9 into PaddlePaddle:develop Nov 9, 2023
27 of 28 checks passed
@luotao1
Copy link
Contributor

luotao1 commented Nov 9, 2023

hi, @YibinLiu666

  • 非常感谢你对飞桨框架的贡献,我们正在运营一个PFCC组织,会通过定期分享技术知识与发布开发者主导任务的形式持续为飞桨框架做贡献,详情可见 https://github.com/luotao1 主页说明。
  • 如果你对PFCC有兴趣,请发送邮件至 ext_paddle_oss@baidu.com,我们会邀请你加入~

danleifeng pushed a commit to danleifeng/Paddle that referenced this pull request Nov 14, 2023
…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>
SecretXV pushed a commit to SecretXV/Paddle that referenced this pull request Nov 28, 2023
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants