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 #6305

Merged
merged 7 commits into from Nov 15, 2023

Conversation

YibinLiu666
Copy link
Contributor

docs/api/paddle/Tensor_cn.rst Outdated Show resolved Hide resolved
Comment on lines 2367 to 2394
.. code-block:: python
import paddle
tensorx = paddle.to_tensor([1,2,3])
print(tensorx)
# Tensor(shape=[3], dtype=int64, place=Place(gpu:0), stop_gradient=True,
# [1, 2, 3])

tensorx = tensorx.to("cpu")
print(tensorx.place)
# Place(cpu)

tensorx = tensorx.to("float32")
print(tensorx.dtype)
# paddle.float32

tensorx = tensorx.to("gpu", "int16")
print(tensorx)
# Tensor(shape=[3], dtype=int16, place=Place(gpu:0), stop_gradient=True,
#     [1, 2, 3])

tensor2 = paddle.to_tensor([4,5,6])
print(tensor2)
# Tensor(shape=[3], dtype=int64, place=Place(gpu:0), stop_gradient=True,
#     [4, 5, 6])
tensor2 = tensor2.to(tensorx)
print(tensor2)
# Tensor(shape=[3], dtype=int16, place=Place(gpu:0), stop_gradient=True,
#     [4, 5, 6])
Copy link
Collaborator

Choose a reason for hiding this comment

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

代码示例请用 copy-from 的形式

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

docs/api/paddle/nn/Layer_cn.rst Outdated Show resolved Hide resolved
docs/api/paddle/nn/Overview_cn.rst Outdated Show resolved Hide resolved
YibinLiu666 and others added 4 commits November 14, 2023 15:41
Co-authored-by: zachary sun <70642955+sunzhongkai588@users.noreply.github.com>
Co-authored-by: zachary sun <70642955+sunzhongkai588@users.noreply.github.com>
Co-authored-by: zachary sun <70642955+sunzhongkai588@users.noreply.github.com>
Copy link
Collaborator

@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.

其他没啥问题

docs/api/paddle/nn/Layer_cn.rst Outdated Show resolved Hide resolved
Co-authored-by: zachary sun <70642955+sunzhongkai588@users.noreply.github.com>
Copy link
Collaborator

@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 luotao1 merged commit 30451ba into PaddlePaddle:develop Nov 15, 2023
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor PaddlePaddle Hackathon 飞桨黑客松活动issue与PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants