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 No.7】为 Paddle 新增 apply API -part #59374

Merged
merged 19 commits into from
Dec 26, 2023

Conversation

yangguohao
Copy link
Contributor

@yangguohao yangguohao commented Nov 26, 2023

PR types

New features

PR changes

APIs

Description

add tensor.apply for Paddle
RFC:PaddlePaddle/community#761

Copy link

paddle-bot bot commented Nov 26, 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.

@luotao1
Copy link
Contributor

luotao1 commented Dec 19, 2023

image 如果这部分单测测到了,可以补充下本地截图

@yangguohao
Copy link
Contributor Author

image 如果这部分单测测到了,可以补充下本地截图

添加了单测

@yangguohao
Copy link
Contributor Author

@luotao1 @jeff41404

Comment on lines 399 to 404
>>> x = paddle.to_tensor(5.)
>>> f = lambda x: 3*x+2
>>> x.apply_(f)
>>> print(x)
Tensor(shape=[], dtype=float32, place=Place(cpu), stop_gradient=True,
17.)
Copy link
Contributor

Choose a reason for hiding this comment

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

can the shape of the input data in example code be larger, such as [3, 3]

Copy link
Contributor

Choose a reason for hiding this comment

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

and use tensor in GPU

Copy link
Contributor

Choose a reason for hiding this comment

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

are we support other data types? eg float16, bfloat16 and float64, should add more case in example code

Copy link
Contributor

Choose a reason for hiding this comment

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

same issue in example code in def apply below

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 add the related example code


class TestTensorApplyAPI(unittest.TestCase):
def setUp(self):
self.x = paddle.to_tensor([1, 2, 3, 4, 5], stop_gradient=True)
Copy link
Contributor

Choose a reason for hiding this comment

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

we need test input tensor in both CPU and GPU

Copy link
Contributor

Choose a reason for hiding this comment

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

are we support other data types? eg float16, bfloat16 and float64. if yes, should add more case in here

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 add the test case

jeff41404
jeff41404 previously approved these changes Dec 21, 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

@luotao1
Copy link
Contributor

luotao1 commented Dec 21, 2023

请提交对应的中文文档

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.

代码示例没过,检查一下 CI-Static-check 的报错log

@yangguohao
Copy link
Contributor Author

代码示例没过,检查一下 CI-Static-check 的报错log

我发现好像 CI 里 paddle.seed 固定种子数后输出的随机值和我电脑本地的输出不一样,打印的时候会出现问题。

sunzhongkai588
sunzhongkai588 previously approved these changes Dec 22, 2023
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

@luotao1
Copy link
Contributor

luotao1 commented Dec 22, 2023

@yangguohao 请解决下冲突

@yangguohao
Copy link
Contributor Author

@yangguohao 请解决下冲突

done 等 CI 完应该就 ok 了

@luotao1 luotao1 changed the title 【Hackathon No.7】为 Paddle 新增 apply API 【Hackathon No.7】为 Paddle 新增 apply API -part Dec 26, 2023
@luotao1 luotao1 merged commit 9fab1fe into PaddlePaddle:develop Dec 26, 2023
Wanglongzhi2001 pushed a commit to Wanglongzhi2001/Paddle that referenced this pull request Jan 7, 2024
* add tensor apply

* fix

* fix 2023-11-27

* fix

* fix V2

* add apply in Variable

* add apply in newir

* add test

* fix

* fix2

* fix example code

* change shape

* fix docs

* fix docs
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.

4 participants