-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
update 2.0 public api in all left files #33313
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,21 +18,16 @@ | |
from paddle.fluid import core | ||
from paddle.fluid import framework | ||
from paddle.fluid.dygraph.parallel import ParallelEnv | ||
from paddle.fluid.framework import is_compiled_with_cuda #DEFINE_ALIAS | ||
from paddle.fluid.framework import is_compiled_with_rocm #DEFINE_ALIAS | ||
from paddle.fluid.framework import is_compiled_with_cuda # noqa: F401 | ||
from paddle.fluid.framework import is_compiled_with_rocm # noqa: F401 | ||
|
||
__all__ = [ | ||
|
||
__all__ = [ # npqa | ||
'get_cudnn_version', | ||
'set_device', | ||
'get_device', | ||
'XPUPlace', | ||
'is_compiled_with_xpu', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 注意后面Examples: .. code-block:: python里的写法要和最终推荐路径都保持一致,现在比较杂乱,比如有:support_xpu = paddle.device.is_compiled_with_xpu() There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done,已经进行修改 |
||
# 'cpu_places', | ||
# 'CPUPlace', | ||
# 'cuda_pinned_places', | ||
# 'cuda_places', | ||
# 'CUDAPinnedPlace', | ||
# 'CUDAPlace', | ||
'is_compiled_with_cuda', | ||
'is_compiled_with_rocm', | ||
'is_compiled_with_npu' | ||
|
@@ -68,7 +63,7 @@ def is_compiled_with_xpu(): | |
.. code-block:: python | ||
|
||
import paddle | ||
support_xpu = paddle.device.is_compiled_with_xpu() | ||
support_xpu = paddle.is_compiled_with_xpu() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这几个API,考虑到接下来还会增加device相关的api,我建议保留paddle.device层级更好些。 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
""" | ||
return core.is_compiled_with_xpu() | ||
|
||
|
@@ -82,9 +77,10 @@ def XPUPlace(dev_id): | |
|
||
Examples: | ||
.. code-block:: python | ||
|
||
# required: xpu | ||
|
||
import paddle | ||
place = paddle.device.XPUPlace(0) | ||
place = paddle.XPUPlace(0) | ||
""" | ||
return core.XPUPlace(dev_id) | ||
|
||
|
@@ -127,15 +123,13 @@ def _convert_to_place(device): | |
place = core.CPUPlace() | ||
elif lower_device == 'gpu': | ||
if not core.is_compiled_with_cuda(): | ||
raise ValueError( | ||
"The device should not be 'gpu', " \ | ||
"since PaddlePaddle is not compiled with CUDA") | ||
raise ValueError("The device should not be 'gpu', " | ||
"since PaddlePaddle is not compiled with CUDA") | ||
place = core.CUDAPlace(ParallelEnv().dev_id) | ||
elif lower_device == 'xpu': | ||
if not core.is_compiled_with_xpu(): | ||
raise ValueError( | ||
"The device should not be 'xpu', " \ | ||
"since PaddlePaddle is not compiled with XPU") | ||
raise ValueError("The device should not be 'xpu', " | ||
"since PaddlePaddle is not compiled with XPU") | ||
selected_xpus = os.getenv("FLAGS_selected_xpus", "0").split(",") | ||
device_id = int(selected_xpus[0]) | ||
place = core.XPUPlace(device_id) | ||
|
@@ -149,7 +143,7 @@ def _convert_to_place(device): | |
if avaliable_gpu_device: | ||
if not core.is_compiled_with_cuda(): | ||
raise ValueError( | ||
"The device should not be {}, since PaddlePaddle is " \ | ||
"The device should not be {}, since PaddlePaddle is " | ||
"not compiled with CUDA".format(avaliable_gpu_device)) | ||
device_info_list = device.split(':', 1) | ||
device_id = device_info_list[1] | ||
|
@@ -158,7 +152,7 @@ def _convert_to_place(device): | |
if avaliable_xpu_device: | ||
if not core.is_compiled_with_xpu(): | ||
raise ValueError( | ||
"The device should not be {}, since PaddlePaddle is " \ | ||
"The device should not be {}, since PaddlePaddle is " | ||
"not compiled with XPU".format(avaliable_xpu_device)) | ||
device_info_list = device.split(':', 1) | ||
device_id = device_info_list[1] | ||
|
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.
这里是否要改成 from .framework import set_grad_enabled # noqa: F401
或者说set_grad_enabled 如果不公开了,那下面的__all__列表中也要删除set_grad_enabled
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.
这里的set_grad_enabled是重复导入,跟242行重复了。