Skip to content

Commit

Permalink
Modify paths, test=develop
Browse files Browse the repository at this point in the history
  • Loading branch information
zhhsplendid committed Sep 27, 2020
1 parent c2a5f5a commit 57c02ed
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def false_fn_0(x_v):
x_v = x_v + 1
return x_v

x_v = paddle.jit.dygraph_to_static.convert_operators.convert_ifelse(
x_v = paddle.jit.dy2static.convert_ifelse(
fluid.layers.mean(x_v)[0] > 5, true_fn_0, false_fn_0, (x_v, ),
(x_v, ), (x_v, ))

Expand All @@ -92,11 +92,10 @@ def true_fn_1(__return_0, __return_value_0, label, x_v):
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(
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)))
__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)))

def true_fn_2(__return_1, __return_value_0, x_v):
__return_1 = paddle.fill_constant(
Expand All @@ -107,12 +106,10 @@ def true_fn_2(__return_1, __return_value_0, x_v):
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), (__return_1, __return_value_0)))
__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


Expand All @@ -133,7 +130,7 @@ def false_fn_3(x_v):
x_v = x_v + 1
return x_v

x_v = paddle.jit.dygraph_to_static.convert_operators.convert_ifelse(
x_v = paddle.jit.dy2static.convert_ifelse(
fluid.layers.mean(x_v)[0] > 5, true_fn_3, false_fn_3, (x_v, ),
(x_v, ), (x_v, ))

Expand All @@ -147,11 +144,10 @@ def true_fn_4(__return_2, __return_value_1, label, x_v):
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(
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)))
__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)))

def true_fn_5(__return_3, __return_value_1, x_v):
__return_3 = paddle.fill_constant(
Expand All @@ -162,12 +158,10 @@ def true_fn_5(__return_3, __return_value_1, x_v):
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), (__return_3, __return_value_1)))
__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


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.dygraph_to_static.convert_operators.convert_var_shape(x)[0]))`
# paddle.jit.dy2static.convert_var_shape(x)[0]))`
x = fluid.dygraph.to_variable(x)
s = x.shape[0]
res = fluid.layers.reshape(x, shape=(-1, s))
Expand All @@ -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.dygraph_to_static.convert_operators.convert_var_shape(res)[0]`
# `paddle.jit.dy2static.convert_var_shape(res)[0]`
if res.shape[0] > 1:
res = fluid.layers.fill_constant(
value=2, shape=x.shape, dtype="int32")
Expand All @@ -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.dygraph_to_static.convert_operators.convert_var_shape(x)[0]`
# `x.shape[0]` is transformed into `paddle.jit.dy2static.convert_var_shape(x)[0]`
for i in range(x.shape[0]):
res += 1
return res
Expand All @@ -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.dygraph_to_static.convert_operators.convert_var_shape(x)[0]`
# `x_shape_0` is transformed into `paddle.jit.dy2static.convert_var_shape(x)[0]`
for i in range(x_shape_0):
res += 1
return res
Expand All @@ -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.dygraph_to_static.convert_operators.convert_var_shape(x)[0]`
# `x.shape[0]` is transformed into `paddle.jit.dy2static.convert_var_shape(x)[0]`
i = 1
while i < x.shape[0]:
res += 1
Expand All @@ -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.dygraph_to_static.convert_operators.convert_var_shape(x)[0]`
# `x_shape_0` is transformed into `paddle.jit.dy2static.convert_var_shape(x)[0]`
while i < x_shape_0:
res += 1
i = i + 2
Expand Down
2 changes: 1 addition & 1 deletion python/paddle/jit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from ..fluid.dygraph import ProgramTranslator #DEFINE_ALIAS
from ..fluid.dygraph.io import TranslatedLayer #DEFINE_ALIAS

from . import dygraph_to_static
from . import dy2static

__all__ = [
'save', 'load', 'TracedLayer', 'to_static', 'ProgramTranslator',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 *
Expand All @@ -23,5 +24,6 @@
from .variable_trans_func import *

__all__ = []
__all__ += convert_operators.__all__
__all__ += convert_call_func.__all__
__all__ += variable_trans_func.__all__
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@
__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'
]

0 comments on commit 57c02ed

Please sign in to comment.