Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
acbb5dbe
P
Paddle
项目概览
机器未来
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
acbb5dbe
编写于
4月 28, 2022
作者:
R
ronnywang
提交者:
GitHub
4月 28, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[CustomDevice] add amp support (#42035)
上级
c7a258fe
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
11 addition
and
4 deletion
+11
-4
paddle/fluid/imperative/amp_auto_cast.cc
paddle/fluid/imperative/amp_auto_cast.cc
+1
-0
python/paddle/fluid/dygraph/amp/auto_cast.py
python/paddle/fluid/dygraph/amp/auto_cast.py
+7
-2
python/paddle/fluid/dygraph/amp/loss_scaler.py
python/paddle/fluid/dygraph/amp/loss_scaler.py
+3
-2
未找到文件。
paddle/fluid/imperative/amp_auto_cast.cc
浏览文件 @
acbb5dbe
...
@@ -220,6 +220,7 @@ inline bool NeedCast(const std::shared_ptr<VarType>& var) {
...
@@ -220,6 +220,7 @@ inline bool NeedCast(const std::shared_ptr<VarType>& var) {
paddle
::
platform
::
is_cuda_pinned_place
(
place
)
||
paddle
::
platform
::
is_cuda_pinned_place
(
place
)
||
paddle
::
platform
::
is_xpu_place
(
place
)
||
paddle
::
platform
::
is_xpu_place
(
place
)
||
paddle
::
platform
::
is_mlu_place
(
place
)
||
paddle
::
platform
::
is_mlu_place
(
place
)
||
paddle
::
platform
::
is_custom_place
(
place
)
||
paddle
::
platform
::
is_npu_place
(
place
)
||
paddle
::
platform
::
is_npu_place
(
place
)
||
paddle
::
platform
::
is_npu_pinned_place
(
place
))
{
paddle
::
platform
::
is_npu_pinned_place
(
place
))
{
// CudaPinndePlace is added for varbase created by dataloader
// CudaPinndePlace is added for varbase created by dataloader
...
...
python/paddle/fluid/dygraph/amp/auto_cast.py
浏览文件 @
acbb5dbe
...
@@ -276,9 +276,10 @@ def amp_guard(enable=True,
...
@@ -276,9 +276,10 @@ def amp_guard(enable=True,
if
enable
and
not
(
tracer
.
_expected_place
.
is_gpu_place
()
or
if
enable
and
not
(
tracer
.
_expected_place
.
is_gpu_place
()
or
tracer
.
_expected_place
.
is_xpu_place
()
or
tracer
.
_expected_place
.
is_xpu_place
()
or
tracer
.
_expected_place
.
is_mlu_place
()
or
tracer
.
_expected_place
.
is_mlu_place
()
or
tracer
.
_expected_place
.
is_npu_place
()):
tracer
.
_expected_place
.
is_npu_place
()
or
tracer
.
_expected_place
.
is_custom_place
()):
warnings
.
warn
(
warnings
.
warn
(
'amp_guard can only be enabled on CUDAPlace, XPUPlace, MLUPlace,
and NPU
Place, current place is %s, so it makes no effect.'
'amp_guard can only be enabled on CUDAPlace, XPUPlace, MLUPlace,
NPUPlace, and Custom
Place, current place is %s, so it makes no effect.'
%
tracer
.
_expected_place
)
%
tracer
.
_expected_place
)
enable
=
False
enable
=
False
# For npu:
# For npu:
...
@@ -293,6 +294,10 @@ def amp_guard(enable=True,
...
@@ -293,6 +294,10 @@ def amp_guard(enable=True,
if
tracer
.
_expected_place
.
is_mlu_place
()
and
(
dtype
==
'bfloat16'
):
if
tracer
.
_expected_place
.
is_mlu_place
()
and
(
dtype
==
'bfloat16'
):
warnings
.
warn
(
'MLUPlace only support float16 amp.'
)
warnings
.
warn
(
'MLUPlace only support float16 amp.'
)
enable
=
False
enable
=
False
# For custom device:
if
tracer
.
_expected_place
.
is_custom_place
()
and
(
dtype
==
'bfloat16'
):
warnings
.
warn
(
'CustomPlace only support float16 amp.'
)
enable
=
False
# For gpu float16: Compute Capability should >= 7.
# For gpu float16: Compute Capability should >= 7.
# For gpu bfloat16: Compute Capability should >= 8 & CUDA Version should >= 11.
# For gpu bfloat16: Compute Capability should >= 8 & CUDA Version should >= 11.
if
tracer
.
_expected_place
.
is_gpu_place
():
if
tracer
.
_expected_place
.
is_gpu_place
():
...
...
python/paddle/fluid/dygraph/amp/loss_scaler.py
浏览文件 @
acbb5dbe
...
@@ -107,9 +107,10 @@ class AmpScaler(object):
...
@@ -107,9 +107,10 @@ class AmpScaler(object):
if
enable
and
not
(
tracer
.
_expected_place
.
is_gpu_place
()
or
if
enable
and
not
(
tracer
.
_expected_place
.
is_gpu_place
()
or
tracer
.
_expected_place
.
is_xpu_place
()
or
tracer
.
_expected_place
.
is_xpu_place
()
or
tracer
.
_expected_place
.
is_mlu_place
()
or
tracer
.
_expected_place
.
is_mlu_place
()
or
tracer
.
_expected_place
.
is_npu_place
()):
tracer
.
_expected_place
.
is_npu_place
()
or
tracer
.
_expected_place
.
is_custom_place
()):
warnings
.
warn
(
warnings
.
warn
(
'AmpScaler can only be enabled on CUDAPlace, XPUPlace, MLUPlace
and NPU
Place, current place is %s, so it makes no effect.'
'AmpScaler can only be enabled on CUDAPlace, XPUPlace, MLUPlace
, NPUPlace and Custom
Place, current place is %s, so it makes no effect.'
%
tracer
.
_expected_place
)
%
tracer
.
_expected_place
)
enable
=
False
enable
=
False
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录