Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
5a103150
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
5a103150
编写于
4月 18, 2022
作者:
A
Aurelius84
提交者:
GitHub
4月 18, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[Eager] Add _fallback_legacy_dygraph for npu/xpu/rocm (#41774)
* [Eager] add _fallback_legacy_dygraph for npu/xpu/rocm * fix import
上级
2d4fe163
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
41 addition
and
2 deletion
+41
-2
python/paddle/fluid/framework.py
python/paddle/fluid/framework.py
+41
-2
未找到文件。
python/paddle/fluid/framework.py
浏览文件 @
5a103150
...
@@ -166,6 +166,40 @@ def _in_eager_without_dygraph_check():
...
@@ -166,6 +166,40 @@ def _in_eager_without_dygraph_check():
return
_in_eager_mode_
return
_in_eager_mode_
# FIXME(dev): We haven't fully verified eager mode on XPU/NPU et.al but
# only GPU/CPU. Remove this after we improve this feature.
_is_first_import_
=
True
def
_fallback_legacy_dygraph
():
global
_in_eager_mode_
global
_is_first_import_
need_fallback
=
False
# Only enable eager on CPU/GPU
is_not_support
=
core
.
is_compiled_with_xpu
()
or
core
.
is_compiled_with_npu
(
)
or
core
.
is_compiled_with_ipu
()
or
core
.
is_compiled_with_mlu
(
)
or
core
.
is_compiled_with_rocm
()
if
_in_eager_mode_
and
is_not_support
:
# switch into legacy dygraph mode
warnings
.
warn
(
"We will fallback into legacy dygraph on NPU/XPU/MLU/IPU/ROCM devices. Because we only support new eager dygraph mode on CPU/GPU currently. "
)
_in_eager_mode_
=
False
if
not
_is_first_import_
:
_enable_legacy_dygraph
()
need_fallback
=
True
need_fallback
=
False
_is_first_import_
=
False
return
need_fallback
# switch into legacy mode if need while import paddle
_fallback_legacy_dygraph
()
def
in_dygraph_mode
():
def
in_dygraph_mode
():
"""
"""
...
@@ -206,10 +240,15 @@ def _non_static_mode():
...
@@ -206,10 +240,15 @@ def _non_static_mode():
@
signature_safe_contextmanager
@
signature_safe_contextmanager
def
_test_eager_guard
(
place
=
None
):
def
_test_eager_guard
(
place
=
None
):
# FIXME(dev): We haven't fully verified eager mode on XPU/NPU et.al but
# only GPU/CPU. Remove this after we improve this feature.
already_fallback
=
_fallback_legacy_dygraph
()
if
not
already_fallback
:
_disable_legacy_dygraph
()
_disable_legacy_dygraph
()
try
:
try
:
yield
yield
finally
:
finally
:
if
not
already_fallback
:
_enable_legacy_dygraph
()
_enable_legacy_dygraph
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录