Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Crayon鑫
Paddle
提交
f9c9d50e
P
Paddle
项目概览
Crayon鑫
/
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看板
未验证
提交
f9c9d50e
编写于
4月 10, 2020
作者:
L
liym27
提交者:
GitHub
4月 10, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Return VarBase of ProgramTranslator.get_output instead of numpy.ndarray. test=develop (#23663)
上级
01a78323
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
6 addition
and
3 deletion
+6
-3
python/paddle/fluid/dygraph/dygraph_to_static/program_translator.py
...dle/fluid/dygraph/dygraph_to_static/program_translator.py
+3
-0
python/paddle/fluid/tests/unittests/dygraph_to_static/test_cache_program.py
...d/tests/unittests/dygraph_to_static/test_cache_program.py
+2
-2
python/paddle/fluid/tests/unittests/dygraph_to_static/test_fetch_feed.py
...luid/tests/unittests/dygraph_to_static/test_fetch_feed.py
+1
-1
未找到文件。
python/paddle/fluid/dygraph/dygraph_to_static/program_translator.py
浏览文件 @
f9c9d50e
...
...
@@ -24,6 +24,7 @@ from collections import defaultdict
from
paddle.fluid
import
framework
from
paddle.fluid
import
core
,
executor
from
paddle.fluid.dygraph
import
guard
,
to_variable
from
paddle.fluid.dygraph.dygraph_to_static.ast_transformer
import
convert_to_static
from
paddle.fluid.dygraph.dygraph_to_static.ast_transformer
import
DygraphToStaticAst
from
paddle.fluid.dygraph.dygraph_to_static.utils
import
ast_to_source_code
...
...
@@ -285,6 +286,8 @@ class ProgramTranslator(object):
*
args
,
**
kwargs
)
if
not
program_cache
.
in_build_process
:
outputs
=
self
.
run
(
*
args
,
**
kwargs
)
with
guard
():
outputs
=
[
to_variable
(
x
)
for
x
in
outputs
]
return
outputs
def
get_func
(
self
,
dygraph_func
):
...
...
python/paddle/fluid/tests/unittests/dygraph_to_static/test_cache_program.py
浏览文件 @
f9c9d50e
...
...
@@ -50,7 +50,7 @@ class TestCacheProgram(unittest.TestCase):
])
if
batch_id
>
0
:
self
.
assertTrue
(
np
.
allclose
(
prev_out
[
0
]
,
cur_out
[
0
]
),
np
.
allclose
(
prev_out
[
0
]
.
numpy
(),
cur_out
[
0
].
numpy
()
),
msg
=
'Output in previous batch is {}
\n
Output in current batch is
\n
{}'
.
format
(
prev_out
,
cur_out
))
self
.
assertEqual
(
prev_ops
,
cur_ops
)
...
...
@@ -81,7 +81,7 @@ class TestCacheProgramWithOptimizer(unittest.TestCase):
for
batch_id
in
range
(
self
.
batch_num
):
pred
,
avg_loss
=
static_net
(
self
.
data
)
loss_data
.
append
(
np
.
array
(
avg_loss
))
loss_data
.
append
(
np
.
array
(
avg_loss
.
numpy
()
))
return
loss_data
...
...
python/paddle/fluid/tests/unittests/dygraph_to_static/test_fetch_feed.py
浏览文件 @
f9c9d50e
...
...
@@ -82,7 +82,7 @@ class TestPool2D(unittest.TestCase):
with
fluid
.
program_guard
(
main_prog
,
startup_prog
):
dy_layer
=
self
.
dygraph_class
()
out
=
dy_layer
(
x
=
self
.
data
)
return
out
[
0
]
return
out
[
0
]
.
numpy
()
def
test_static_output
(
self
):
dygraph_res
=
self
.
run_dygraph_mode
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录