-
Notifications
You must be signed in to change notification settings - Fork 5.9k
add layer.to api #32040
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
add layer.to api #32040
Conversation
|
Thanks for your contribution! |
| for key, buf in self._buffers.items(): | ||
| self._buffers[key] = func(buf, place, dtype, blocking) | ||
|
|
||
| def to(self, place=None, dtype=None, blocking=None): |
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.
这里是不是需要支持,用户输入“cuda”,可以自动判断当前cuda place id,从而to到相应的place。
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.
place参数的取值已经可以 支持paddle.set_device 所支持的取值。
paddle/fluid/pybind/imperative.cc
Outdated
| } | ||
|
|
||
| static void InitVarBaseFromTensorWithArgDefault( | ||
|
|
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.
remove this blank line
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/device.py
Outdated
| x2 = paddle.zeros(name='x2', shape=[1, 2], dtype='int32') | ||
| data = paddle.stack([x1,x2], axis=1) | ||
| """ | ||
| def _make_device(device): |
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.
maybe _convert_to_place is a better name?
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
| Cast the parameters and buffers of Layer by the give place, dtype and blocking. | ||
| Parameters: | ||
| place(str|paddle.CPUPlace|paddle.CUDAPlace()|paddle.CUDAPinnedPlace()|None, optional): The device place of the Layer which want to be stored. |
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.
统一下,paddle.CPUPlace后面要不要也加括号?
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.
The device place of the Layer,device和place有重复的意思,改成The device of the Layer?
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.
参数名要不要直接使用device?和set_deivce API统一?
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.
All Done
ead7476 to
bc85ae4
Compare
febf2f6 to
fff1241
Compare
fff1241 to
bc85ae4
Compare
1cd85c7 to
ead7476
Compare
| Parameters: | ||
| device(str|paddle.CPUPlace()|paddle.CUDAPlace()|paddle.CUDAPinnedPlace()|None, optional): The device of the Layer which want to be stored. | ||
| If None, the place is the same with the origin Tensor. If device is string, it can be ``cpu``, ``gpu:x`` and ``xpu:x``, where ``x`` is the |
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.
place -> device?
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.
origin是不是改为original比较合适?
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, thanks.
| If None, the place is the same with the origin Tensor. If device is string, it can be ``cpu``, ``gpu:x`` and ``xpu:x``, where ``x`` is the | ||
| index of the GPUs or XPUs. Default: None. | ||
| dtype(str|core.VarDesc.VarType|None, optional): The type of the data. If None, the dtype is the same with the origin Tensor. Default: None. |
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.
同上
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, thanks.
chenwhql
left a comment
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
ForFishes
left a comment
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
| Cast the parameters and buffers of Layer by the give device, dtype and blocking. | ||
| Parameters: | ||
| device(str|paddle.CPUPlace()|paddle.CUDAPlace()|paddle.CUDAPinnedPlace()|None, optional): The device of the Layer which want to be stored. |
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.
paddle.XPUPlace()
0f62fa0
TCChenlong
left a comment
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
PR types
New features
PR changes
APIs
Describe
add layer.to api