Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
01bdea7c
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 2 年 前同步成功
通知
2325
Star
20933
Fork
5424
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
01bdea7c
编写于
11月 28, 2020
作者:
L
liym27
提交者:
GitHub
11月 28, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[Dy2Stat] Don't conver the function from third library logging (#29161)
上级
a7433cc3
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
26 addition
and
1 deletion
+26
-1
python/paddle/fluid/dygraph/dygraph_to_static/convert_call_func.py
...ddle/fluid/dygraph/dygraph_to_static/convert_call_func.py
+4
-1
python/paddle/fluid/tests/unittests/dygraph_to_static/test_recursive_call.py
.../tests/unittests/dygraph_to_static/test_recursive_call.py
+22
-0
未找到文件。
python/paddle/fluid/dygraph/dygraph_to_static/convert_call_func.py
浏览文件 @
01bdea7c
...
@@ -19,6 +19,7 @@ __all__ = ['convert_call']
...
@@ -19,6 +19,7 @@ __all__ = ['convert_call']
import
collections
import
collections
import
copy
import
copy
import
functools
import
functools
import
logging
import
inspect
import
inspect
import
pdb
import
pdb
import
re
import
re
...
@@ -35,7 +36,9 @@ from paddle.fluid.dygraph.dygraph_to_static.program_translator import unwrap_dec
...
@@ -35,7 +36,9 @@ from paddle.fluid.dygraph.dygraph_to_static.program_translator import unwrap_dec
from
paddle.fluid.dygraph.layers
import
Layer
from
paddle.fluid.dygraph.layers
import
Layer
# TODO(liym27): A better way to do this.
# TODO(liym27): A better way to do this.
BUILTIN_LIKELY_MODULES
=
[
collections
,
pdb
,
copy
,
inspect
,
re
,
six
,
numpy
]
BUILTIN_LIKELY_MODULES
=
[
collections
,
pdb
,
copy
,
inspect
,
re
,
six
,
numpy
,
logging
]
translator_logger
=
TranslatorLogger
()
translator_logger
=
TranslatorLogger
()
...
...
python/paddle/fluid/tests/unittests/dygraph_to_static/test_recursive_call.py
浏览文件 @
01bdea7c
...
@@ -16,6 +16,7 @@ from __future__ import print_function
...
@@ -16,6 +16,7 @@ from __future__ import print_function
import
unittest
import
unittest
import
logging
import
numpy
as
np
import
numpy
as
np
import
paddle.fluid
as
fluid
import
paddle.fluid
as
fluid
...
@@ -49,6 +50,16 @@ def nested_func(x_v):
...
@@ -49,6 +50,16 @@ def nested_func(x_v):
return
res
return
res
@
declarative
def
dyfunc_with_third_library_logging
(
x_v
):
logging
.
info
(
'test dyfunc_with_third_library_logging'
)
if
fluid
.
layers
.
mean
(
x_v
).
numpy
()[
0
]
>
5
:
x_v
=
x_v
-
1
else
:
x_v
=
x_v
+
1
return
x_v
class
TestRecursiveCall1
(
unittest
.
TestCase
):
class
TestRecursiveCall1
(
unittest
.
TestCase
):
def
setUp
(
self
):
def
setUp
(
self
):
self
.
input
=
np
.
random
.
random
([
10
,
16
]).
astype
(
'float32'
)
self
.
input
=
np
.
random
.
random
([
10
,
16
]).
astype
(
'float32'
)
...
@@ -163,5 +174,16 @@ class TestRecursiveCall2(unittest.TestCase):
...
@@ -163,5 +174,16 @@ class TestRecursiveCall2(unittest.TestCase):
static_res
))
static_res
))
class
TestThirdPartyLibrary
(
TestRecursiveCall2
):
def
_run
(
self
):
with
fluid
.
dygraph
.
guard
():
self
.
dygraph_func
=
dyfunc_with_third_library_logging
fluid
.
default_startup_program
.
random_seed
=
SEED
fluid
.
default_main_program
.
random_seed
=
SEED
data
=
fluid
.
dygraph
.
to_variable
(
self
.
input
)
res
=
self
.
dygraph_func
(
data
)
return
res
.
numpy
()
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
unittest
.
main
()
unittest
.
main
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录