Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
57c02ed1
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看板
提交
57c02ed1
编写于
9月 27, 2020
作者:
Z
zhhsplendid
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Modify paths, test=develop
上级
c2a5f5a8
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
28 addition
and
32 deletion
+28
-32
python/paddle/fluid/tests/unittests/dygraph_to_static/test_program_translator.py
...ts/unittests/dygraph_to_static/test_program_translator.py
+18
-24
python/paddle/fluid/tests/unittests/dygraph_to_static/test_tensor_shape.py
...id/tests/unittests/dygraph_to_static/test_tensor_shape.py
+6
-6
python/paddle/jit/__init__.py
python/paddle/jit/__init__.py
+1
-1
python/paddle/jit/dy2static/__init__.py
python/paddle/jit/dy2static/__init__.py
+2
-0
python/paddle/jit/dy2static/convert_call_func.py
python/paddle/jit/dy2static/convert_call_func.py
+0
-0
python/paddle/jit/dy2static/convert_operators.py
python/paddle/jit/dy2static/convert_operators.py
+1
-1
python/paddle/jit/dy2static/variable_trans_func.py
python/paddle/jit/dy2static/variable_trans_func.py
+0
-0
未找到文件。
python/paddle/fluid/tests/unittests/dygraph_to_static/test_program_translator.py
浏览文件 @
57c02ed1
...
...
@@ -78,7 +78,7 @@ class StaticCode1():
x_v
=
x_v
+
1
return
x_v
x_v
=
paddle
.
jit
.
dy
graph_to_static
.
convert_operators
.
convert_ifelse
(
x_v
=
paddle
.
jit
.
dy
2static
.
convert_ifelse
(
fluid
.
layers
.
mean
(
x_v
)[
0
]
>
5
,
true_fn_0
,
false_fn_0
,
(
x_v
,
),
(
x_v
,
),
(
x_v
,
))
...
...
@@ -92,8 +92,7 @@ class StaticCode1():
def
false_fn_1
(
__return_0
,
__return_value_0
):
return
__return_0
,
__return_value_0
__return_0
,
__return_value_0
=
(
paddle
.
jit
.
dygraph_to_static
.
convert_operators
.
convert_ifelse
(
__return_0
,
__return_value_0
=
(
paddle
.
jit
.
dy2static
.
convert_ifelse
(
label
is
not
None
,
true_fn_1
,
false_fn_1
,
(
__return_0
,
__return_value_0
,
label
,
x_v
),
(
__return_0
,
__return_value_0
),
(
__return_0
,
__return_value_0
)))
...
...
@@ -107,11 +106,9 @@ class StaticCode1():
def
false_fn_2
(
__return_1
,
__return_value_0
):
return
__return_1
,
__return_value_0
__return_1
,
__return_value_0
=
(
paddle
.
jit
.
dygraph_to_static
.
convert_operators
.
convert_ifelse
(
paddle
.
jit
.
dygraph_to_static
.
convert_operators
.
convert_logical_not
(
__return_0
),
true_fn_2
,
false_fn_2
,
(
__return_1
,
__return_value_0
,
x_v
),
__return_1
,
__return_value_0
=
(
paddle
.
jit
.
dy2static
.
convert_ifelse
(
paddle
.
jit
.
dy2static
.
convert_logical_not
(
__return_0
),
true_fn_2
,
false_fn_2
,
(
__return_1
,
__return_value_0
,
x_v
),
(
__return_1
,
__return_value_0
),
(
__return_1
,
__return_value_0
)))
return
__return_value_0
...
...
@@ -133,7 +130,7 @@ class StaticCode2():
x_v
=
x_v
+
1
return
x_v
x_v
=
paddle
.
jit
.
dy
graph_to_static
.
convert_operators
.
convert_ifelse
(
x_v
=
paddle
.
jit
.
dy
2static
.
convert_ifelse
(
fluid
.
layers
.
mean
(
x_v
)[
0
]
>
5
,
true_fn_3
,
false_fn_3
,
(
x_v
,
),
(
x_v
,
),
(
x_v
,
))
...
...
@@ -147,8 +144,7 @@ class StaticCode2():
def
false_fn_4
(
__return_2
,
__return_value_1
):
return
__return_2
,
__return_value_1
__return_2
,
__return_value_1
=
(
paddle
.
jit
.
dygraph_to_static
.
convert_operators
.
convert_ifelse
(
__return_2
,
__return_value_1
=
(
paddle
.
jit
.
dy2static
.
convert_ifelse
(
label
is
not
None
,
true_fn_4
,
false_fn_4
,
(
__return_2
,
__return_value_1
,
label
,
x_v
),
(
__return_2
,
__return_value_1
),
(
__return_2
,
__return_value_1
)))
...
...
@@ -162,11 +158,9 @@ class StaticCode2():
def
false_fn_5
(
__return_3
,
__return_value_1
):
return
__return_3
,
__return_value_1
__return_3
,
__return_value_1
=
(
paddle
.
jit
.
dygraph_to_static
.
convert_operators
.
convert_ifelse
(
paddle
.
jit
.
dygraph_to_static
.
convert_operators
.
convert_logical_not
(
__return_2
),
true_fn_5
,
false_fn_5
,
(
__return_3
,
__return_value_1
,
x_v
),
__return_3
,
__return_value_1
=
(
paddle
.
jit
.
dy2static
.
convert_ifelse
(
paddle
.
jit
.
dy2static
.
convert_logical_not
(
__return_2
),
true_fn_5
,
false_fn_5
,
(
__return_3
,
__return_value_1
,
x_v
),
(
__return_3
,
__return_value_1
),
(
__return_3
,
__return_value_1
)))
return
__return_value_1
...
...
python/paddle/fluid/tests/unittests/dygraph_to_static/test_tensor_shape.py
浏览文件 @
57c02ed1
...
...
@@ -52,7 +52,7 @@ def dyfunc_tensor_shape_4(x):
def
dyfunc_tensor_shape_5
(
x
):
# `res = fluid.layers.reshape(x, shape=(-1, s))` to
# `res = fluid.layers.reshape(x, shape=(-1,
# paddle.jit.dy
graph_to_static.convert_operators
.convert_var_shape(x)[0]))`
# paddle.jit.dy
2static
.convert_var_shape(x)[0]))`
x
=
fluid
.
dygraph
.
to_variable
(
x
)
s
=
x
.
shape
[
0
]
res
=
fluid
.
layers
.
reshape
(
x
,
shape
=
(
-
1
,
s
))
...
...
@@ -65,7 +65,7 @@ def dyfunc_with_if_1(x):
x_shape_0
=
x
.
shape
[
0
]
if
x_shape_0
<
1
:
# `res.shape[0]` is transformed into
# `paddle.jit.dy
graph_to_static.convert_operators
.convert_var_shape(res)[0]`
# `paddle.jit.dy
2static
.convert_var_shape(res)[0]`
if
res
.
shape
[
0
]
>
1
:
res
=
fluid
.
layers
.
fill_constant
(
value
=
2
,
shape
=
x
.
shape
,
dtype
=
"int32"
)
...
...
@@ -89,7 +89,7 @@ def dyfunc_with_if_2(x):
def
dyfunc_with_for_1
(
x
):
x
=
fluid
.
dygraph
.
to_variable
(
x
)
res
=
fluid
.
layers
.
fill_constant
(
value
=
0
,
shape
=
[
1
],
dtype
=
"int32"
)
# `x.shape[0]` is transformed into `paddle.jit.dy
graph_to_static.convert_operators
.convert_var_shape(x)[0]`
# `x.shape[0]` is transformed into `paddle.jit.dy
2static
.convert_var_shape(x)[0]`
for
i
in
range
(
x
.
shape
[
0
]):
res
+=
1
return
res
...
...
@@ -100,7 +100,7 @@ def dyfunc_with_for_2(x):
x_shape_0
=
x
.
shape
[
0
]
res
=
fluid
.
layers
.
fill_constant
(
value
=
0
,
shape
=
[
1
],
dtype
=
"int32"
)
# `x_shape_0` is transformed into `paddle.jit.dy
graph_to_static.convert_operators
.convert_var_shape(x)[0]`
# `x_shape_0` is transformed into `paddle.jit.dy
2static
.convert_var_shape(x)[0]`
for
i
in
range
(
x_shape_0
):
res
+=
1
return
res
...
...
@@ -124,7 +124,7 @@ def dyfunc_with_for_3(x):
def
dyfunc_with_while_1
(
x
):
x
=
fluid
.
dygraph
.
to_variable
(
x
)
res
=
fluid
.
layers
.
fill_constant
(
value
=
0
,
shape
=
[
1
],
dtype
=
"int32"
)
# `x.shape[0]` is transformed into `paddle.jit.dy
graph_to_static.convert_operators
.convert_var_shape(x)[0]`
# `x.shape[0]` is transformed into `paddle.jit.dy
2static
.convert_var_shape(x)[0]`
i
=
1
while
i
<
x
.
shape
[
0
]:
res
+=
1
...
...
@@ -137,7 +137,7 @@ def dyfunc_with_while_2(x):
x_shape_0
=
x
.
shape
[
0
]
res
=
fluid
.
layers
.
fill_constant
(
value
=
0
,
shape
=
[
1
],
dtype
=
"int32"
)
i
=
1
# `x_shape_0` is transformed into `paddle.jit.dy
graph_to_static.convert_operators
.convert_var_shape(x)[0]`
# `x_shape_0` is transformed into `paddle.jit.dy
2static
.convert_var_shape(x)[0]`
while
i
<
x_shape_0
:
res
+=
1
i
=
i
+
2
...
...
python/paddle/jit/__init__.py
浏览文件 @
57c02ed1
...
...
@@ -23,7 +23,7 @@ from ..fluid.dygraph.jit import declarative as to_static #DEFINE_ALIAS
from
..fluid.dygraph
import
ProgramTranslator
#DEFINE_ALIAS
from
..fluid.dygraph.io
import
TranslatedLayer
#DEFINE_ALIAS
from
.
import
dy
graph_to_
static
from
.
import
dy
2
static
__all__
=
[
'save'
,
'load'
,
'TracedLayer'
,
'to_static'
,
'ProgramTranslator'
,
...
...
python/paddle/jit/dy
graph_to_
static/__init__.py
→
python/paddle/jit/dy
2
static/__init__.py
浏览文件 @
57c02ed1
...
...
@@ -15,6 +15,7 @@
from
__future__
import
print_function
from
.
import
convert_operators
from
.convert_operators
import
*
from
.
import
convert_call_func
from
.convert_call_func
import
*
...
...
@@ -23,5 +24,6 @@ from . import variable_trans_func
from
.variable_trans_func
import
*
__all__
=
[]
__all__
+=
convert_operators
.
__all__
__all__
+=
convert_call_func
.
__all__
__all__
+=
variable_trans_func
.
__all__
python/paddle/jit/dy
graph_to_
static/convert_call_func.py
→
python/paddle/jit/dy
2
static/convert_call_func.py
浏览文件 @
57c02ed1
文件已移动
python/paddle/jit/dy
graph_to_
static/convert_operators.py
→
python/paddle/jit/dy
2
static/convert_operators.py
浏览文件 @
57c02ed1
...
...
@@ -28,6 +28,6 @@ from ...fluid.dygraph.dygraph_to_static.convert_operators import convert_while_l
__all__
=
[
'cast_bool_if_necessary'
,
'convert_assert'
,
'convert_ifelse'
,
'convert_len'
,
'convert_logical_and'
,
'convert_logical_not'
,
'convert_logical_or'
,
'convert_
logical_
print'
,
'convert_var_dtype'
,
'convert_var_shape'
,
'convert_print'
,
'convert_var_dtype'
,
'convert_var_shape'
,
'convert_while_loop'
]
python/paddle/jit/dy
graph_to_
static/variable_trans_func.py
→
python/paddle/jit/dy
2
static/variable_trans_func.py
浏览文件 @
57c02ed1
文件已移动
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录