diff --git a/python/paddle/fluid/tests/unittests/autograd/test_orig2prim.py b/python/paddle/fluid/tests/unittests/autograd/test_orig2prim.py index 275e5f1bee8487b705243f56768bd8ff96dad757..fe7b37941b4c0b2bfc79612526fe957921473a08 100644 --- a/python/paddle/fluid/tests/unittests/autograd/test_orig2prim.py +++ b/python/paddle/fluid/tests/unittests/autograd/test_orig2prim.py @@ -462,9 +462,7 @@ class TestPNormOrig2Prim1(TestElementWiseAddOrig2Prim): } self.orig2prim_args = (X, ) - self.all_ops = [ - 'p_norm', 'reshape_p', 'sqrt_p', 'reduce_sum_p', 'mul_p' - ] + self.all_ops = ['p_norm', 'reshape_p', 'abs_p', 'reduce_sum_p'] self.out_map = {0: self.output['Out']} diff --git a/python/paddle/incubate/autograd/primrules.py b/python/paddle/incubate/autograd/primrules.py index 73058912761af70494bdbb4dff521a594ce1cde6..3be0816864f0f1a70f8bae08cbd6876bfe6561bb 100644 --- a/python/paddle/incubate/autograd/primrules.py +++ b/python/paddle/incubate/autograd/primrules.py @@ -344,7 +344,7 @@ def p_norm_orig2prim(op, x): if abs(op.attr('porder') - 2.0) < 1e-5: return sqrt(reduce_sum(mul(x, x), axis=[0])) elif abs(op.attr('porder') - 1.0) < 1e-5: - return reduce_sum(sqrt(mul(x, x)), axis=[0]) + return reduce_sum(primops.abs(x), axis=[0]) else: raise RuntimeError('Only support lower l2/l1 norm currently')