-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
4efabdc
to
4178851
Compare
4178851
to
a4ccbaa
Compare
>>> 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.) |
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.
can the shape of the input data in example code be larger, such as [3, 3]
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.
and use tensor in GPU
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.
are we support other data types? eg float16
, bfloat16
and float64
, should add more case in example code
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 in example code in def apply
below
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 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) |
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.
we need test input tensor in both CPU and GPU
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.
are we support other data types? eg float16, bfloat16 and float64. if yes, should add more case in here
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 add the test case
32fe7c8
to
fca8389
Compare
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
请提交对应的中文文档 |
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.
代码示例没过,检查一下 CI-Static-check 的报错log
我发现好像 CI 里 paddle.seed 固定种子数后输出的随机值和我电脑本地的输出不一样,打印的时候会出现问题。 |
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
@yangguohao 请解决下冲突 |
done 等 CI 完应该就 ok 了 |
* 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
PR types
New features
PR changes
APIs
Description
add tensor.apply for Paddle
RFC:PaddlePaddle/community#761