From def71d38ea08b76927055e568488bff086958cd8 Mon Sep 17 00:00:00 2001 From: Weilong Wu Date: Thu, 1 Sep 2022 20:07:33 +0800 Subject: [PATCH] [Eager] fix norm interface under different mode (#45642) --- python/paddle/fluid/layers/nn.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/python/paddle/fluid/layers/nn.py b/python/paddle/fluid/layers/nn.py index 8474ff1379a..4a17ad0b4ca 100755 --- a/python/paddle/fluid/layers/nn.py +++ b/python/paddle/fluid/layers/nn.py @@ -5310,8 +5310,11 @@ def l2_normalize(x, axis, epsilon=1e-12, name=None): if len(x.shape) == 1: axis = 0 if _non_static_mode(): - _, out = _legacy_C_ops.norm(x, 'axis', 1 if axis is None else axis, - 'epsilon', epsilon) + if in_dygraph_mode(): + out, _ = _C_ops.norm(x, 1 if axis is None else axis, epsilon, False) + elif _in_legacy_dygraph(): + _, out = _legacy_C_ops.norm(x, 'axis', 1 if axis is None else axis, + 'epsilon', epsilon) return out check_variable_and_dtype(x, "X", ("float16", "float32", "float64"), "norm") -- GitLab