From 14306420e1c56e8086671ac2c97c40f9c59d0d5a Mon Sep 17 00:00:00 2001 From: zhhsplendid Date: Mon, 21 Sep 2020 10:51:19 +0000 Subject: [PATCH] Add convert_ifelse, test=develop --- .../fluid/dygraph/dygraph_to_static/ifelse_transformer.py | 4 ++-- python/paddle/jit/dygraph_to_static/convert_operators.py | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/python/paddle/fluid/dygraph/dygraph_to_static/ifelse_transformer.py b/python/paddle/fluid/dygraph/dygraph_to_static/ifelse_transformer.py index 997c6cad76d..ef8871a5fc5 100644 --- a/python/paddle/fluid/dygraph/dygraph_to_static/ifelse_transformer.py +++ b/python/paddle/fluid/dygraph/dygraph_to_static/ifelse_transformer.py @@ -460,7 +460,7 @@ def create_convert_ifelse_node(return_name_ids, false_func, is_if_expr=False): """ - Create `fluid.dygraph.dygraph_to_static.convert_operators.convert_ifelse( + Create `paddle.jit.dygraph_to_static.convert_operators.convert_ifelse( pred, true_fn, false_fn, true_args, false_args, return_vars)` to replace original `python if/else` statement. """ @@ -491,7 +491,7 @@ def create_convert_ifelse_node(return_name_ids, return_vars = create_name_nodes(return_name_ids) convert_ifelse_layer = gast.parse( - 'fluid.dygraph.dygraph_to_static.convert_operators.convert_ifelse(' + 'paddle.jit.dygraph_to_static.convert_operators.convert_ifelse(' '{pred}, {true_fn}, {false_fn}, {true_args}, {false_args}, {return_vars})'. format( pred=ast_to_source_code(pred), diff --git a/python/paddle/jit/dygraph_to_static/convert_operators.py b/python/paddle/jit/dygraph_to_static/convert_operators.py index 2b6f67212e5..d8ba9318074 100644 --- a/python/paddle/jit/dygraph_to_static/convert_operators.py +++ b/python/paddle/jit/dygraph_to_static/convert_operators.py @@ -15,6 +15,7 @@ from __future__ import print_function from ...fluid.dygraph.dygraph_to_static.convert_operators import cast_bool_if_necessary #DEFINE_ALIAS from ...fluid.dygraph.dygraph_to_static.convert_operators import convert_assert #DEFINE_ALIAS +from ...fluid.dygraph.dygraph_to_static.convert_operators import convert_ifelse #DEFINE_ALIAS from ...fluid.dygraph.dygraph_to_static.convert_operators import convert_len #DEFINE_ALIAS from ...fluid.dygraph.dygraph_to_static.convert_operators import convert_logical_and #DEFINE_ALIAS from ...fluid.dygraph.dygraph_to_static.convert_operators import convert_logical_not #DEFINE_ALIAS -- GitLab