From 00f32af342594066a442988c6612362682b2e363 Mon Sep 17 00:00:00 2001 From: Weilong Wu Date: Tue, 20 Sep 2022 19:19:23 +0800 Subject: [PATCH] [Eager, Performance optimization] optimize isclose and allclose interface (#46221) --- python/paddle/tensor/logic.py | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/python/paddle/tensor/logic.py b/python/paddle/tensor/logic.py index 3eb142f13c..e8b699b1f0 100755 --- a/python/paddle/tensor/logic.py +++ b/python/paddle/tensor/logic.py @@ -393,12 +393,7 @@ def allclose(x, y, rtol=1e-05, atol=1e-08, equal_nan=False, name=None): """ if in_dygraph_mode(): - # NOTE(dev): Pass tol as Tensor to fix precision loss problem, because - # C++ backend will cast it into float32 if passing float from python. - as_tensor = lambda x: paddle.to_tensor( - [x], dtype='float64', place='cpu') - return _C_ops.allclose(x, y, as_tensor(rtol), as_tensor(atol), - equal_nan) + return _C_ops.allclose(x, y, rtol, atol, equal_nan) if _in_legacy_dygraph(): return _legacy_C_ops.allclose(x, y, 'rtol', str(rtol), 'atol', str(atol), 'equal_nan', equal_nan) @@ -998,11 +993,7 @@ def isclose(x, y, rtol=1e-05, atol=1e-08, equal_nan=False, name=None): """ if in_dygraph_mode(): - # NOTE(dev): Pass tol as Tensor to fix precision loss problem, because - # C++ backend will cast it into float32 if passing float from python. - as_tensor = lambda x: paddle.to_tensor( - [x], dtype='float64', place='cpu') - return _C_ops.isclose(x, y, as_tensor(rtol), as_tensor(atol), equal_nan) + return _C_ops.isclose(x, y, rtol, atol, equal_nan) if _in_legacy_dygraph(): return _legacy_C_ops.isclose(x, y, 'rtol', str(rtol), 'atol', str(atol), 'equal_nan', equal_nan) -- GitLab