@ -62,10 +62,7 @@ def get_source_code(func):
class StaticCode1 ( ) :
class StaticCode1 ( ) :
# TODO: Transform return statement
def dyfunc_with_if_else ( x_v , label = None ) :
def dyfunc_with_if_else ( x_v , label = None ) :
__return_1 = paddle . fluid . layers . fill_constant ( shape = [ 1 ] , dtype = ' bool ' , value = False )
__return_0 = paddle . fluid . layers . fill_constant ( shape = [ 1 ] , dtype = ' bool ' , value = False )
__return_value_init_0 = paddle . fluid . layers . fill_constant (
__return_value_init_0 = paddle . fluid . layers . fill_constant (
shape = [ 1 ] , dtype = ' float64 ' , value = 0.0 )
shape = [ 1 ] , dtype = ' float64 ' , value = 0.0 )
__return_value_0 = __return_value_init_0
__return_value_0 = __return_value_init_0
@ -81,11 +78,13 @@ class StaticCode1():
x_v = paddle . jit . dy2static . convert_ifelse (
x_v = paddle . jit . dy2static . convert_ifelse (
fluid . layers . mean ( x_v ) [ 0 ] > 5 , true_fn_0 , false_fn_0 , ( x_v , ) ,
fluid . layers . mean ( x_v ) [ 0 ] > 5 , true_fn_0 , false_fn_0 , ( x_v , ) ,
( x_v , ) , ( x_v , ) )
( x_v , ) , ( x_v , ) )
__return_0 = paddle . jit . dy2static . create_bool_as_type ( label is not None ,
False )
def true_fn_1 ( __return_0 , __return_value_0 , label , x_v ) :
def true_fn_1 ( __return_0 , __return_value_0 , label , x_v ) :
loss = fluid . layers . cross_entropy ( x_v , label )
loss = fluid . layers . cross_entropy ( x_v , label )
__return_0 = paddle . fluid. layers . fill_constant (
__return_0 = paddle . jit. dy2static . create_bool_as_type (
shape= [ 1 ] , dtype = ' bool ' , value = True )
label is not None , True )
__return_value_0 = loss
__return_value_0 = loss
return __return_0 , __return_value_0
return __return_0 , __return_value_0
@ -97,27 +96,25 @@ class StaticCode1():
( __return_0 , __return_value_0 , label , x_v ) ,
( __return_0 , __return_value_0 , label , x_v ) ,
( __return_0 , __return_value_0 ) , ( __return_0 , __return_value_0 ) ) )
( __return_0 , __return_value_0 ) , ( __return_0 , __return_value_0 ) ) )
def true_fn_2 ( __return_ 1 , __return_value_0 , x_v ) :
def true_fn_2 ( __return_ 0 , __return_value_0 , x_v ) :
__return_1 = paddle . fluid. layers . fill_constant (
__return_1 = paddle . jit. dy2static . create_bool_as_type (
shape= [ 1 ] , dtype = ' bool ' , value = True )
paddle. jit . dy2static . convert_logical_not ( __return_0 ) , True )
__return_value_0 = x_v
__return_value_0 = x_v
return __return_ 1, __return_ value_0
return __return_ value_0
def false_fn_2 ( __return_ 1, __return_ value_0) :
def false_fn_2 ( __return_ value_0) :
return __return_ 1, __return_ value_0
return __return_ value_0
__return_ 1, __return_ value_0 = ( paddle . jit . dy2static . convert_ifelse (
__return_ value_0 = paddle . jit . dy2static . convert_ifelse (
paddle . jit . dy2static . convert_logical_not ( __return_0 ) , true_fn_2 ,
paddle . jit . dy2static . convert_logical_not ( __return_0 ) , true_fn_2 ,
false_fn_2 , ( __return_ 1, __return_value_0 , x_v ) ,
false_fn_2 , ( __return_ 0, __return_value_0 ,
( __return_1 , __return_value_0 ) , ( __return_1 , __return_value_0 ) ) )
x_v ) , ( __return_value_0 , ) , ( __return_value_0 , ) )
return __return_value_0
return __return_value_0
class StaticCode2 ( ) :
class StaticCode2 ( ) :
# TODO: Transform return statement
# TODO: Transform return statement
def dyfunc_with_if_else ( x_v , label = None ) :
def dyfunc_with_if_else ( x_v , label = None ) :
__return_3 = paddle . fluid . layers . fill_constant ( shape = [ 1 ] , dtype = ' bool ' , value = False )
__return_2 = paddle . fluid . layers . fill_constant ( shape = [ 1 ] , dtype = ' bool ' , value = False )
__return_value_init_1 = paddle . fluid . layers . fill_constant (
__return_value_init_1 = paddle . fluid . layers . fill_constant (
shape = [ 1 ] , dtype = ' float64 ' , value = 0.0 )
shape = [ 1 ] , dtype = ' float64 ' , value = 0.0 )
__return_value_1 = __return_value_init_1
__return_value_1 = __return_value_init_1
@ -133,35 +130,37 @@ class StaticCode2():
x_v = paddle . jit . dy2static . convert_ifelse (
x_v = paddle . jit . dy2static . convert_ifelse (
fluid . layers . mean ( x_v ) [ 0 ] > 5 , true_fn_3 , false_fn_3 , ( x_v , ) ,
fluid . layers . mean ( x_v ) [ 0 ] > 5 , true_fn_3 , false_fn_3 , ( x_v , ) ,
( x_v , ) , ( x_v , ) )
( x_v , ) , ( x_v , ) )
__return_2 = paddle . jit . dy2static . create_bool_as_type ( label is not None ,
False )
def true_fn_4 ( __return_2 , __return_value_1 , label , x_v ) :
def true_fn_4 ( __return_2 , __return_value_1 , label , x_v ) :
loss = fluid . layers . cross_entropy ( x_v , label )
loss = fluid . layers . cross_entropy ( x_v , label )
__return_2 = paddle . fluid. layers . fill_constant (
__return_2 = paddle . jit. dy2static . create_bool_as_type (
shape= [ 1 ] , dtype = ' bool ' , value = True )
label is not None , True )
__return_value_1 = loss
__return_value_1 = loss
return __return_2 , __return_value_1
return __return_2 , __return_value_1
def false_fn_4 ( __return_2 , __return_value_1 ) :
def false_fn_4 ( __return_2 , __return_value_1 ) :
return __return_2 , __return_value_1
return __return_2 , __return_value_1
__return_2 , __return_value_1 = ( paddle . jit . dy2static . convert_ifelse (
__return_2 , __return_value_1 = paddle . jit . dy2static . convert_ifelse (
label is not None , true_fn_4 , false_fn_4 ,
label is not None , true_fn_4 , false_fn_4 , (
( __return_2 , __return_value_1 , label , x_v ) ,
__return_2 , __return_value_1 , label , x_v ) ,
( __return_2 , __return_value_1 ) , ( __return_2 , __return_value_1 ) ) )
( __return_2 , __return_value_1 ) , ( __return_2 , __return_value_1 ) )
def true_fn_5 ( __return_ 3 , __return_value_1 , x_v ) :
def true_fn_5 ( __return_ 2 , __return_value_1 , x_v ) :
__return_3 = paddle . fluid. layers . fill_constant (
__return_3 = paddle . jit. dy2static . create_bool_as_type (
shape= [ 1 ] , dtype = ' bool ' , value = True )
paddle. jit . dy2static . convert_logical_not ( __return_2 ) , True )
__return_value_1 = x_v
__return_value_1 = x_v
return __return_ 3, __return_ value_1
return __return_ value_1
def false_fn_5 ( __return_ 3, __return_ value_1) :
def false_fn_5 ( __return_ value_1) :
return __return_ 3, __return_ value_1
return __return_ value_1
__return_ 3, __return_ value_1 = ( paddle . jit . dy2static . convert_ifelse (
__return_ value_1 = paddle . jit . dy2static . convert_ifelse (
paddle . jit . dy2static . convert_logical_not ( __return_2 ) , true_fn_5 ,
paddle . jit . dy2static . convert_logical_not ( __return_2 ) , true_fn_5 ,
false_fn_5 , ( __return_ 3, __return_value_1 , x_v ) ,
false_fn_5 , ( __return_ 2, __return_value_1 ,
( __return_3 , __return_value_1 ) , ( __return_3 , __return_value_1 ) ) )
x_v ) , ( __return_value_1 , ) , ( __return_value_1 , ) )
return __return_value_1
return __return_value_1