diff --git a/python/paddle/fluid/tests/unittests/eager_op_test.py b/python/paddle/fluid/tests/unittests/eager_op_test.py index fe782a9c9966a1f91c07736e00273ab4401d91f6..acdc87827f6aade5ee1e826e142d3c36053e3ffe 100644 --- a/python/paddle/fluid/tests/unittests/eager_op_test.py +++ b/python/paddle/fluid/tests/unittests/eager_op_test.py @@ -930,7 +930,14 @@ class OpTest(unittest.TestCase): args, len(inputs_sig) ) ret_tuple = python_api(*args) - return construct_output_dict_by_kernel_sig(ret_tuple, outputs_sig) + result = construct_output_dict_by_kernel_sig(ret_tuple, outputs_sig) + if hasattr(self, "python_out_sig_sub_name"): + for key in self.python_out_sig_sub_name.keys(): + for i in range(len(self.python_out_sig_sub_name[key])): + result[key][0][i].name = self.python_out_sig_sub_name[ + key + ][i] + return result with fluid.dygraph.base.guard(place=place): block = fluid.default_main_program().global_block() @@ -965,7 +972,11 @@ class OpTest(unittest.TestCase): dygraph_tensor_outputs, attrs_outputs, ) - if not kernel_sig: + if not kernel_sig or ( + len(kernel_sig[0]) == 0 + and len(kernel_sig[1]) == 0 + and len(kernel_sig[2]) == 0 + ): return None if not hasattr(self, "python_api"): print(kernel_sig) @@ -1514,13 +1525,23 @@ class OpTest(unittest.TestCase): core._set_prim_all_enabled(False) core.set_prim_eager_enabled(False) + if hasattr(self, "use_custom_device") and self.use_custom_device(): + check_dygraph = False + def find_imperative_actual(target_name, dygraph_outs, place): for name in dygraph_outs: if name == target_name: return dygraph_outs[name][0] var_list = dygraph_outs[name] for i, var in enumerate(var_list): - if var.name == target_name: + if isinstance(var, list): + for tensor in var: + if tensor.name == target_name: + return tensor + elif ( + isinstance(var, paddle.Tensor) + and var.name == target_name + ): return dygraph_outs[name][i] self.assertTrue( False, @@ -1653,6 +1674,8 @@ class OpTest(unittest.TestCase): actual_np, expect_np = self.convert_uint16_to_float_ifneed( actual_np, expect_np ) + # modify there for fp32 check + # NOTE(zhiqiu): np.allclose([], [1.]) returns True # see details: https://stackoverflow.com/questions/38331703/why-does-numpys-broadcasting-sometimes-allow-comparing-arrays-of-different-leng if expect_np.size == 0: @@ -1768,19 +1791,18 @@ class OpTest(unittest.TestCase): place, no_check_set=no_check_set ) self.outputs = dygraph_outs - if self.op_test.is_fp16_compared_with_fp32(): self.op_test.enable_cal_ref_output() self.is_python_api_test = True - ref_dygraph_outs = self.op_test._calc_python_api_output( + self.ref_outputs = self.op_test._calc_python_api_output( place ) - if ref_dygraph_outs is None: + if self.ref_outputs is None: self.is_python_api_test = False - ref_dygraph_outs = self.op_test._calc_dygraph_output( + # missing KernelSignature, fall back to eager middle output. + self.ref_outputs = self.op_test._calc_dygraph_output( place, no_check_set=no_check_set ) - self.ref_outputs = ref_dygraph_outs self.op_test.disable_cal_ref_output() def _compare_numpy(self, name, actual_np, expect_np): @@ -1911,7 +1933,7 @@ class OpTest(unittest.TestCase): else: atol = 2 if atol < 2 else atol else: - atol = 1e-1 if atol < 1e-1 else atol + atol = 1e-2 if atol < 1e-2 else atol if self.is_float16_op(): atol = 1e-3 if atol < 1e-3 else atol @@ -2050,6 +2072,9 @@ class OpTest(unittest.TestCase): if self.is_xpu_op(): self.__class__.use_xpu = True + if hasattr(self, "use_custom_device") and self.use_custom_device(): + check_dygraph = False + places = self._get_places() for place in places: res = self.check_output_with_place( @@ -2072,6 +2097,7 @@ class OpTest(unittest.TestCase): self.check_compile_vs_runtime(fetch_list, outs) def check_output_customized(self, checker, custom_place=None): + self.__class__.op_type = self.op_type places = self._get_places() if custom_place: places.append(custom_place) @@ -2160,7 +2186,10 @@ class OpTest(unittest.TestCase): else: abs_a = 1 if abs_a < 1e-3 else abs_a - diff_mat = np.abs(a - b) / abs_a + if self.dtype == np.bool_: + diff_mat = np.abs(a ^ b) / abs_a + else: + diff_mat = np.abs(a - b) / abs_a max_diff = np.max(diff_mat) def err_msg(): @@ -2205,6 +2234,9 @@ class OpTest(unittest.TestCase): only_check_prim=False, atol=1e-5, ): + if hasattr(self, "use_custom_device") and self.use_custom_device(): + check_dygraph = False + self._check_grad_helper() places = self._get_places() for place in places: @@ -2241,6 +2273,9 @@ class OpTest(unittest.TestCase): numeric_place=None, atol=1e-5, ): + if hasattr(self, "use_custom_device") and self.use_custom_device(): + check_dygraph = False + core._set_prim_all_enabled(False) core.set_prim_eager_enabled(False) if check_prim: @@ -2337,19 +2372,31 @@ class OpTest(unittest.TestCase): if numeric_place is None: numeric_place = place - numeric_grads = user_defined_grads or [ - get_numeric_gradient( - numeric_place, - self.scope, - self.op, - self.inputs, - input_to_check, + if user_defined_grads is None and self.is_fp16_compared_with_fp32(): + self.enable_cal_ref_output() + numeric_grads = self._get_gradient( + inputs_to_check, + place, output_names, - delta=numeric_grad_delta, - in_place=in_place, + no_grad_set, + user_defined_grad_outputs, ) - for input_to_check in inputs_to_check - ] + self.disable_cal_ref_output() + else: + numeric_grads = user_defined_grads or [ + get_numeric_gradient( + numeric_place, + self.scope, + self.op, + self.inputs, + input_to_check, + output_names, + delta=numeric_grad_delta, + in_place=in_place, + ) + for input_to_check in inputs_to_check + ] + analytic_grads = self._get_gradient( inputs_to_check, place, @@ -2429,8 +2476,14 @@ class OpTest(unittest.TestCase): else: for output_vars_index in output_vars: for output_vars_selected in output_vars[output_vars_index]: - if output_vars_selected.name == name: - return output_vars_selected + if isinstance(output_vars_selected, list): + for tensor in output_vars_selected: + if tensor.name == name: + return [tensor] + elif isinstance(output_vars_selected, paddle.Tensor): + if output_vars_selected.name == name: + return [output_vars_selected] + raise AssertionError(name, " not in outputs:", output_vars.keys()) def _get_dygraph_grad( self, @@ -2441,6 +2494,9 @@ class OpTest(unittest.TestCase): no_grad_set=None, check_dygraph=True, ): + if hasattr(self, "use_custom_device") and self.use_custom_device(): + check_dygraph = False + with fluid.dygraph.base.guard(place=place): block = fluid.default_main_program().global_block() diff --git a/python/paddle/fluid/tests/unittests/op_test_xpu.py b/python/paddle/fluid/tests/unittests/op_test_xpu.py index 6ede8ce71c035954255b98631ccb70f48ceae857..a3f24fab91148d9e4f9d794172a45d8de4f0b2df 100644 --- a/python/paddle/fluid/tests/unittests/op_test_xpu.py +++ b/python/paddle/fluid/tests/unittests/op_test_xpu.py @@ -13,7 +13,7 @@ # limitations under the License. import numpy as np -from op_test import OpTest +from eager_op_test import OpTest from testsuite import append_loss_ops, create_op, set_input from white_list import no_grad_set_white_list, op_threshold_white_list from xpu.get_test_cover_info import ( @@ -71,7 +71,6 @@ class XPUOpTest(OpTest): equal_nan=False, check_dygraph=True, inplace_atol=None, - check_eager=False, ): place = paddle.XPUPlace(0) self.check_output_with_place( @@ -81,7 +80,6 @@ class XPUOpTest(OpTest): equal_nan, check_dygraph, inplace_atol, - check_eager, ) def check_output_with_place( @@ -92,7 +90,6 @@ class XPUOpTest(OpTest): equal_nan=False, check_dygraph=True, inplace_atol=None, - check_eager=False, ): self.infer_dtype_from_inputs_outputs(self.inputs, self.outputs) if self.dtype == np.float64: @@ -120,7 +117,6 @@ class XPUOpTest(OpTest): user_defined_grad_outputs=None, check_dygraph=True, numeric_place=None, - check_eager=False, ): place = paddle.XPUPlace(0) self.check_grad_with_place( @@ -135,7 +131,6 @@ class XPUOpTest(OpTest): user_defined_grad_outputs, check_dygraph, numeric_place, - check_eager, ) def check_grad_with_place( @@ -151,7 +146,6 @@ class XPUOpTest(OpTest): user_defined_grad_outputs=None, check_dygraph=True, numeric_place=None, - check_eager=False, ): if hasattr(self, 'op_type_need_check_grad'): xpu_version = core.get_xpu_device_version(0) diff --git a/python/paddle/fluid/tests/unittests/xpu/test_activation_op_xpu.py b/python/paddle/fluid/tests/unittests/xpu/test_activation_op_xpu.py index e21153151d4c47ecbbeee8f8ce0576ebbb1e23ca..9645fbb7d003331362771c16dacfb730bfc2ffdb 100644 --- a/python/paddle/fluid/tests/unittests/xpu/test_activation_op_xpu.py +++ b/python/paddle/fluid/tests/unittests/xpu/test_activation_op_xpu.py @@ -19,7 +19,7 @@ import numpy as np sys.path.append("..") -from op_test import OpTest +from eager_op_test import OpTest from op_test_xpu import XPUOpTest from xpu.get_test_cover_info import ( XPUOpTestWrapper, diff --git a/python/paddle/fluid/tests/unittests/xpu/test_atan_op_xpu.py b/python/paddle/fluid/tests/unittests/xpu/test_atan_op_xpu.py index 5cd35ffbfcf4f7e07402c20a1ccf1e6611c0c7c1..bb02e1320da15cc7b86553778cf6d2cf27b4f030 100644 --- a/python/paddle/fluid/tests/unittests/xpu/test_atan_op_xpu.py +++ b/python/paddle/fluid/tests/unittests/xpu/test_atan_op_xpu.py @@ -40,7 +40,6 @@ class XPUTestAtanOp(XPUOpTestWrapper): def setUp(self): self.set_xpu() self.op_type = "atan" - self.eager_mode = True # override self.init_input_shape() @@ -62,9 +61,7 @@ class XPUTestAtanOp(XPUOpTestWrapper): self.check_output_with_place(self.place) def test_check_grad(self): - self.check_grad_with_place( - self.place, ['X'], 'Out', check_eager=self.eager_mode - ) + self.check_grad_with_place(self.place, ['X'], 'Out') class Test1x1(TestAtanOp): def init_input_shape(self): diff --git a/python/paddle/fluid/tests/unittests/xpu/test_bitwise_op_xpu.py b/python/paddle/fluid/tests/unittests/xpu/test_bitwise_op_xpu.py index 7bd11bed1a8b761cd1520a344518fb5703e99d65..8fcf5a7af7811a9fb8734ba7f708af0115770cfd 100644 --- a/python/paddle/fluid/tests/unittests/xpu/test_bitwise_op_xpu.py +++ b/python/paddle/fluid/tests/unittests/xpu/test_bitwise_op_xpu.py @@ -19,7 +19,7 @@ import numpy as np sys.path.append("..") -from op_test import OpTest +from eager_op_test import OpTest from op_test_xpu import XPUOpTest from xpu.get_test_cover_info import ( XPUOpTestWrapper, diff --git a/python/paddle/fluid/tests/unittests/xpu/test_clip_op_xpu.py b/python/paddle/fluid/tests/unittests/xpu/test_clip_op_xpu.py index 5aa2d78d343b40d273a891adf0ea7b6cd6bad4d2..767aaf068553ce49bf876ac8b837224b1bb189b6 100644 --- a/python/paddle/fluid/tests/unittests/xpu/test_clip_op_xpu.py +++ b/python/paddle/fluid/tests/unittests/xpu/test_clip_op_xpu.py @@ -97,7 +97,7 @@ class XPUTestClipOp(XPUOpTestWrapper): if core.is_compiled_with_xpu(): paddle.enable_static() self.check_grad_with_place( - self.place, ['X'], 'Out', check_eager=True + self.place, ['X'], 'Out', check_dygraph=True ) paddle.disable_static() diff --git a/python/paddle/fluid/tests/unittests/xpu/test_concat_op_xpu.py b/python/paddle/fluid/tests/unittests/xpu/test_concat_op_xpu.py index c3f3e644481f3aa0c60469eefc02466e3ce68caf..5867858a97b4d9d67a6f29bb4148131833a19232 100644 --- a/python/paddle/fluid/tests/unittests/xpu/test_concat_op_xpu.py +++ b/python/paddle/fluid/tests/unittests/xpu/test_concat_op_xpu.py @@ -18,7 +18,7 @@ sys.path.append("..") import unittest import numpy as np -from op_test import skip_check_grad_ci +from eager_op_test import skip_check_grad_ci from op_test_xpu import XPUOpTest from xpu.get_test_cover_info import ( XPUOpTestWrapper, diff --git a/python/paddle/fluid/tests/unittests/xpu/test_diag_v2_op_xpu.py b/python/paddle/fluid/tests/unittests/xpu/test_diag_v2_op_xpu.py index 87890d4d81399d8dc423ce57f650d391c97e7d74..27002b340075042c867ce5b80793f0d9edc5acf5 100644 --- a/python/paddle/fluid/tests/unittests/xpu/test_diag_v2_op_xpu.py +++ b/python/paddle/fluid/tests/unittests/xpu/test_diag_v2_op_xpu.py @@ -58,11 +58,11 @@ class XPUTestDiagV2Op(XPUOpTestWrapper): def test_check_output(self): paddle.enable_static() - self.check_output(check_eager=False) + self.check_output(check_dygraph=False) def test_check_grad(self): paddle.enable_static() - self.check_grad(['X'], 'Out', check_eager=False) + self.check_grad(['X'], 'Out', check_dygraph=False) def init_config(self): pass diff --git a/python/paddle/fluid/tests/unittests/xpu/test_diagonal_op_xpu.py b/python/paddle/fluid/tests/unittests/xpu/test_diagonal_op_xpu.py index 968623157cbae06b7872ec151ed9d44cd0ed483f..001cd727a081c65975a6c76e6c01abe1521b2aa1 100644 --- a/python/paddle/fluid/tests/unittests/xpu/test_diagonal_op_xpu.py +++ b/python/paddle/fluid/tests/unittests/xpu/test_diagonal_op_xpu.py @@ -20,7 +20,7 @@ import numpy as np import paddle sys.path.append("..") -from op_test import skip_check_grad_ci +from eager_op_test import skip_check_grad_ci from op_test_xpu import XPUOpTest from xpu.get_test_cover_info import ( XPUOpTestWrapper, diff --git a/python/paddle/fluid/tests/unittests/xpu/test_elementwise_add_op_xpu.py b/python/paddle/fluid/tests/unittests/xpu/test_elementwise_add_op_xpu.py index 5e2fbebf22773cca74f93a48d401f1f5363e95d7..74a5d4e4c0421a5cd545af28c5a36ea3f15dc7e5 100644 --- a/python/paddle/fluid/tests/unittests/xpu/test_elementwise_add_op_xpu.py +++ b/python/paddle/fluid/tests/unittests/xpu/test_elementwise_add_op_xpu.py @@ -19,7 +19,7 @@ import numpy as np sys.path.append("..") import unittest -from op_test import OpTest, skip_check_grad_ci +from eager_op_test import OpTest, skip_check_grad_ci from op_test_xpu import XPUOpTest from xpu.get_test_cover_info import ( XPUOpTestWrapper, diff --git a/python/paddle/fluid/tests/unittests/xpu/test_elementwise_add_op_xpu_kp.py b/python/paddle/fluid/tests/unittests/xpu/test_elementwise_add_op_xpu_kp.py index 7ddc852b5e7021507771667a306c0732b5d4fe9c..5b058a586268da1f5d763d92944e1b865d4b766c 100644 --- a/python/paddle/fluid/tests/unittests/xpu/test_elementwise_add_op_xpu_kp.py +++ b/python/paddle/fluid/tests/unittests/xpu/test_elementwise_add_op_xpu_kp.py @@ -19,7 +19,7 @@ import numpy as np sys.path.append("..") import unittest -from op_test import OpTest, skip_check_grad_ci +from eager_op_test import OpTest, skip_check_grad_ci from op_test_xpu import XPUOpTest import paddle diff --git a/python/paddle/fluid/tests/unittests/xpu/test_elementwise_div_op_xpu.py b/python/paddle/fluid/tests/unittests/xpu/test_elementwise_div_op_xpu.py index ef1936d2de4871461c745dc5d8858983a2357063..36fcea45464b8686043c0e78944ef103ba9e477b 100644 --- a/python/paddle/fluid/tests/unittests/xpu/test_elementwise_div_op_xpu.py +++ b/python/paddle/fluid/tests/unittests/xpu/test_elementwise_div_op_xpu.py @@ -17,7 +17,7 @@ sys.path.append("..") import unittest import numpy as np -from op_test import skip_check_grad_ci +from eager_op_test import skip_check_grad_ci from op_test_xpu import XPUOpTest from xpu.get_test_cover_info import ( XPUOpTestWrapper, diff --git a/python/paddle/fluid/tests/unittests/xpu/test_elementwise_floordiv_op_xpu.py b/python/paddle/fluid/tests/unittests/xpu/test_elementwise_floordiv_op_xpu.py index 9b01c005bd06a71ba141442edc33cfd616f7809d..83c476a213ac0ddd5a43d7aae91aa77e7a18d3c7 100644 --- a/python/paddle/fluid/tests/unittests/xpu/test_elementwise_floordiv_op_xpu.py +++ b/python/paddle/fluid/tests/unittests/xpu/test_elementwise_floordiv_op_xpu.py @@ -17,7 +17,7 @@ sys.path.append("..") import unittest import numpy as np -from op_test import OpTest +from eager_op_test import OpTest from op_test_xpu import XPUOpTest from xpu.get_test_cover_info import ( XPUOpTestWrapper, diff --git a/python/paddle/fluid/tests/unittests/xpu/test_elementwise_max_op_xpu.py b/python/paddle/fluid/tests/unittests/xpu/test_elementwise_max_op_xpu.py index 1d3e996bfd9e18436feecd2b92b5016515f8afb2..49f49a3a97e25992bc128cd100bd34e02eaf4fd9 100644 --- a/python/paddle/fluid/tests/unittests/xpu/test_elementwise_max_op_xpu.py +++ b/python/paddle/fluid/tests/unittests/xpu/test_elementwise_max_op_xpu.py @@ -17,7 +17,7 @@ sys.path.append("..") import unittest import numpy as np -from op_test import skip_check_grad_ci +from eager_op_test import skip_check_grad_ci from op_test_xpu import XPUOpTest from xpu.get_test_cover_info import ( XPUOpTestWrapper, diff --git a/python/paddle/fluid/tests/unittests/xpu/test_elementwise_min_op_xpu.py b/python/paddle/fluid/tests/unittests/xpu/test_elementwise_min_op_xpu.py index 2764157ead4756e89ec8128c2b0f25380a38bd5e..64a10d435cc3bb8d826c140e45e3717bfbd3d7e8 100644 --- a/python/paddle/fluid/tests/unittests/xpu/test_elementwise_min_op_xpu.py +++ b/python/paddle/fluid/tests/unittests/xpu/test_elementwise_min_op_xpu.py @@ -17,7 +17,7 @@ sys.path.append("..") import unittest import numpy as np -from op_test import skip_check_grad_ci +from eager_op_test import skip_check_grad_ci from op_test_xpu import XPUOpTest from xpu.get_test_cover_info import ( XPUOpTestWrapper, diff --git a/python/paddle/fluid/tests/unittests/xpu/test_elementwise_mod_op_xpu.py b/python/paddle/fluid/tests/unittests/xpu/test_elementwise_mod_op_xpu.py index 9b7c59737fc2283f95852f9152ab2f89aba13fa9..fcb7d7e35feada976c306b3c68878bffb5a9fc20 100644 --- a/python/paddle/fluid/tests/unittests/xpu/test_elementwise_mod_op_xpu.py +++ b/python/paddle/fluid/tests/unittests/xpu/test_elementwise_mod_op_xpu.py @@ -17,7 +17,7 @@ sys.path.append("..") import unittest import numpy as np -from op_test import OpTest +from eager_op_test import OpTest from op_test_xpu import XPUOpTest from xpu.get_test_cover_info import ( XPUOpTestWrapper, diff --git a/python/paddle/fluid/tests/unittests/xpu/test_elementwise_mul_op_xpu.py b/python/paddle/fluid/tests/unittests/xpu/test_elementwise_mul_op_xpu.py index 591fe9a5f75b8cfcfd5e86ae5089bba08ff3cead..511cf6bb938360a4da70d7edc3c7c9209822b8fd 100644 --- a/python/paddle/fluid/tests/unittests/xpu/test_elementwise_mul_op_xpu.py +++ b/python/paddle/fluid/tests/unittests/xpu/test_elementwise_mul_op_xpu.py @@ -17,7 +17,7 @@ sys.path.append("..") import unittest import numpy as np -from op_test import OpTest, skip_check_grad_ci +from eager_op_test import OpTest, skip_check_grad_ci from op_test_xpu import XPUOpTest from xpu.get_test_cover_info import ( XPUOpTestWrapper, diff --git a/python/paddle/fluid/tests/unittests/xpu/test_elementwise_pow_op_xpu.py b/python/paddle/fluid/tests/unittests/xpu/test_elementwise_pow_op_xpu.py index 4e1b9a641218842b823b6ec7ab01326a94f77263..9b38f992ec390af29a9dbfe45b20c0fba7434441 100644 --- a/python/paddle/fluid/tests/unittests/xpu/test_elementwise_pow_op_xpu.py +++ b/python/paddle/fluid/tests/unittests/xpu/test_elementwise_pow_op_xpu.py @@ -17,7 +17,7 @@ sys.path.append("..") import unittest import numpy as np -from op_test import OpTest, skip_check_grad_ci +from eager_op_test import OpTest, skip_check_grad_ci from op_test_xpu import XPUOpTest from xpu.get_test_cover_info import ( XPUOpTestWrapper, diff --git a/python/paddle/fluid/tests/unittests/xpu/test_elementwise_sub_op_xpu.py b/python/paddle/fluid/tests/unittests/xpu/test_elementwise_sub_op_xpu.py index 7c2676f23af8f1277f05ed37cfaf5a5c08952150..5b731ef32bb0d0c2b03101050dcbcb47df2cd1be 100644 --- a/python/paddle/fluid/tests/unittests/xpu/test_elementwise_sub_op_xpu.py +++ b/python/paddle/fluid/tests/unittests/xpu/test_elementwise_sub_op_xpu.py @@ -19,7 +19,7 @@ import numpy as np sys.path.append("..") import unittest -from op_test import skip_check_grad_ci +from eager_op_test import skip_check_grad_ci from op_test_xpu import XPUOpTest from xpu.get_test_cover_info import ( XPUOpTestWrapper, diff --git a/python/paddle/fluid/tests/unittests/xpu/test_fill_constant_op_xpu.py b/python/paddle/fluid/tests/unittests/xpu/test_fill_constant_op_xpu.py index 3f7c1cf68b740bdb6b3762635528ff86e0c57caa..086376f960cc179136d18a0413c751329606875b 100644 --- a/python/paddle/fluid/tests/unittests/xpu/test_fill_constant_op_xpu.py +++ b/python/paddle/fluid/tests/unittests/xpu/test_fill_constant_op_xpu.py @@ -18,7 +18,7 @@ sys.path.append("..") import unittest import numpy as np -from op_test import convert_float_to_uint16 +from eager_op_test import convert_float_to_uint16 from op_test_xpu import XPUOpTest from xpu.get_test_cover_info import ( XPUOpTestWrapper, diff --git a/python/paddle/fluid/tests/unittests/xpu/test_fill_diagonal_tensor_op_xpu.py b/python/paddle/fluid/tests/unittests/xpu/test_fill_diagonal_tensor_op_xpu.py index 3a3dd013981fa0821618c9a57beb86adfe9364c0..3fbdf7abe6d1412f835f22f1dced399b87c0600a 100644 --- a/python/paddle/fluid/tests/unittests/xpu/test_fill_diagonal_tensor_op_xpu.py +++ b/python/paddle/fluid/tests/unittests/xpu/test_fill_diagonal_tensor_op_xpu.py @@ -20,7 +20,7 @@ import numpy as np import paddle sys.path.append("..") -from op_test import skip_check_grad_ci +from eager_op_test import skip_check_grad_ci from op_test_xpu import XPUOpTest from xpu.get_test_cover_info import ( XPUOpTestWrapper, diff --git a/python/paddle/fluid/tests/unittests/xpu/test_fused_resnet_basic_block_op_xpu.py b/python/paddle/fluid/tests/unittests/xpu/test_fused_resnet_basic_block_op_xpu.py index 1764400403f268c42fe05f6f9c0cd1c2fdfdef22..37490fd0b023f98a2e6bd12bb1bc0c9c8def5c8d 100644 --- a/python/paddle/fluid/tests/unittests/xpu/test_fused_resnet_basic_block_op_xpu.py +++ b/python/paddle/fluid/tests/unittests/xpu/test_fused_resnet_basic_block_op_xpu.py @@ -18,7 +18,7 @@ sys.path.append("..") import unittest import numpy as np -from op_test import OpTest +from eager_op_test import OpTest from xpu.get_test_cover_info import ( XPUOpTestWrapper, create_test_class, diff --git a/python/paddle/fluid/tests/unittests/xpu/test_gather_nd_op_xpu.py b/python/paddle/fluid/tests/unittests/xpu/test_gather_nd_op_xpu.py index 45251d5d0c05f381e6c6e5b451b63eae4c7e4223..a22c10e0fec56eb96fe05fdf7ccea060753d8b1f 100644 --- a/python/paddle/fluid/tests/unittests/xpu/test_gather_nd_op_xpu.py +++ b/python/paddle/fluid/tests/unittests/xpu/test_gather_nd_op_xpu.py @@ -52,7 +52,7 @@ class XPUTestGatherNd(XPUOpTestWrapper): self.check_output_with_place(self.place) def test_check_grad(self): - self.check_grad(['X'], 'Out', check_eager=False) + self.check_grad(['X'], 'Out', check_dygraph=False) def init_data(self): self.xnp = np.random.random((5, 20)).astype(self.in_type) diff --git a/python/paddle/fluid/tests/unittests/xpu/test_group_norm_op_xpu.py b/python/paddle/fluid/tests/unittests/xpu/test_group_norm_op_xpu.py index 7ff43265890dcec7e99c5c3d2275e6e2fd69d966..c583a952856c1278687ac753830bafd33e68f88a 100644 --- a/python/paddle/fluid/tests/unittests/xpu/test_group_norm_op_xpu.py +++ b/python/paddle/fluid/tests/unittests/xpu/test_group_norm_op_xpu.py @@ -19,7 +19,7 @@ import numpy as np sys.path.append("..") -from op_test import OpTest +from eager_op_test import OpTest from op_test_xpu import XPUOpTest from xpu.get_test_cover_info import ( XPUOpTestWrapper, diff --git a/python/paddle/fluid/tests/unittests/xpu/test_huber_loss_op_xpu.py b/python/paddle/fluid/tests/unittests/xpu/test_huber_loss_op_xpu.py index 09d9dbd5071fb3684951097c7f5ec4df82734dc8..2a51e6ea950142f8a7edf8314d03b8d6d8a90507 100644 --- a/python/paddle/fluid/tests/unittests/xpu/test_huber_loss_op_xpu.py +++ b/python/paddle/fluid/tests/unittests/xpu/test_huber_loss_op_xpu.py @@ -19,7 +19,7 @@ import numpy as np sys.path.append("..") -from op_test import OpTest +from eager_op_test import OpTest from op_test_xpu import XPUOpTest from xpu.get_test_cover_info import ( XPUOpTestWrapper, diff --git a/python/paddle/fluid/tests/unittests/xpu/test_kldiv_loss_op_xpu.py b/python/paddle/fluid/tests/unittests/xpu/test_kldiv_loss_op_xpu.py index f77c3fd2303175f39d699a6340789b7549efc66c..5d72a91417af2bd8370e0e12015aecd20bae8527 100644 --- a/python/paddle/fluid/tests/unittests/xpu/test_kldiv_loss_op_xpu.py +++ b/python/paddle/fluid/tests/unittests/xpu/test_kldiv_loss_op_xpu.py @@ -72,7 +72,7 @@ class XPUTestKLDivLossOp(XPUOpTestWrapper): self.outputs = {'Loss': loss.astype('float32')} def test_check_output(self): - self.check_output(check_eager=True) + self.check_output(check_dygraph=True) def test_check_grad(self): self.check_grad_with_place( @@ -80,7 +80,7 @@ class XPUTestKLDivLossOp(XPUOpTestWrapper): ['X'], 'Loss', no_grad_set=set(["Target"]), - check_eager=True, + check_dygraph=True, ) def initTestCase(self): diff --git a/python/paddle/fluid/tests/unittests/xpu/test_log_loss_op_xpu.py b/python/paddle/fluid/tests/unittests/xpu/test_log_loss_op_xpu.py index 00461e6f103d739d1839f44c174df959bc401a40..e68a2cb75471e65a72b0d98e015a0ed471671b34 100644 --- a/python/paddle/fluid/tests/unittests/xpu/test_log_loss_op_xpu.py +++ b/python/paddle/fluid/tests/unittests/xpu/test_log_loss_op_xpu.py @@ -18,7 +18,7 @@ sys.path.append("..") import unittest import numpy as np -from op_test import OpTest +from eager_op_test import OpTest import paddle diff --git a/python/paddle/fluid/tests/unittests/xpu/test_log_softmax_op_xpu.py b/python/paddle/fluid/tests/unittests/xpu/test_log_softmax_op_xpu.py index 36b4809b52ce49c6e6c27c2acf0d58b941d77d24..fdaaadcae81e194a9eedfc4caf96fef15c892730 100644 --- a/python/paddle/fluid/tests/unittests/xpu/test_log_softmax_op_xpu.py +++ b/python/paddle/fluid/tests/unittests/xpu/test_log_softmax_op_xpu.py @@ -91,14 +91,14 @@ class XPUTestLogSoftmaxOp(XPUOpTestWrapper): pass def test_check_output(self): - self.check_output(check_eager=True) + self.check_output(check_dygraph=True) def test_check_grad(self): self.check_grad( ['X'], ['Out'], user_defined_grads=[self.x_grad], - check_eager=True, + check_dygraph=True, ) diff --git a/python/paddle/fluid/tests/unittests/xpu/test_logical_op_xpu.py b/python/paddle/fluid/tests/unittests/xpu/test_logical_op_xpu.py index 8783fb3bb411704f13fd49d719adbdacaa2722a4..b07327283746d0d16ef008938716261d15c00a33 100755 --- a/python/paddle/fluid/tests/unittests/xpu/test_logical_op_xpu.py +++ b/python/paddle/fluid/tests/unittests/xpu/test_logical_op_xpu.py @@ -19,7 +19,7 @@ import numpy as np sys.path.append("..") -from op_test import OpTest +from eager_op_test import OpTest from op_test_xpu import XPUOpTest from xpu.get_test_cover_info import ( XPUOpTestWrapper, diff --git a/python/paddle/fluid/tests/unittests/xpu/test_pad3d_op_xpu.py b/python/paddle/fluid/tests/unittests/xpu/test_pad3d_op_xpu.py index 228d8f99a9ac2adebd111f66a95f0008e1fcfe48..1c502c9465a33d0074235d91af0d5944d7896002 100644 --- a/python/paddle/fluid/tests/unittests/xpu/test_pad3d_op_xpu.py +++ b/python/paddle/fluid/tests/unittests/xpu/test_pad3d_op_xpu.py @@ -94,10 +94,10 @@ class XPUTestPad3dOp(XPUOpTestWrapper): self.outputs = {'Out': out} def test_check_output(self): - self.check_output(check_eager=True) + self.check_output(check_dygraph=True) def test_check_grad_normal(self): - self.check_grad(['X'], 'Out', check_eager=True) + self.check_grad(['X'], 'Out', check_dygraph=True) def initTestCase(self): self.shape = (2, 3, 4, 5, 6) diff --git a/python/paddle/fluid/tests/unittests/xpu/test_pixel_shuffle_op_xpu.py b/python/paddle/fluid/tests/unittests/xpu/test_pixel_shuffle_op_xpu.py index 299fe38018c9b0b42bc2be7dc5753c3aa73c98b9..6674cf33ebb04a3818aa2391bf6ab11ee4ee2554 100644 --- a/python/paddle/fluid/tests/unittests/xpu/test_pixel_shuffle_op_xpu.py +++ b/python/paddle/fluid/tests/unittests/xpu/test_pixel_shuffle_op_xpu.py @@ -78,7 +78,6 @@ class XPUTestPixelShuffleOp(XPUOpTestWrapper): self.set_xpu() self.op_type = "pixel_shuffle" self.init_dtype() - self.eager_mode = True # override self.init_input_shape() @@ -109,9 +108,7 @@ class XPUTestPixelShuffleOp(XPUOpTestWrapper): self.check_output_with_place(self.place) def test_check_grad(self): - self.check_grad_with_place( - self.place, ['X'], 'Out', check_eager=self.eager_mode - ) + self.check_grad_with_place(self.place, ['X'], 'Out') class TestNHWC(TestPixelShuffleOp): def init_input_shape(self): diff --git a/python/paddle/fluid/tests/unittests/xpu/test_prelu_op_xpu.py b/python/paddle/fluid/tests/unittests/xpu/test_prelu_op_xpu.py index 043d5436d9fd8b9f82ccf210a3d359aec0a129f8..f60ceea3168999aa73ead646b00a5acc8e9f4a1b 100644 --- a/python/paddle/fluid/tests/unittests/xpu/test_prelu_op_xpu.py +++ b/python/paddle/fluid/tests/unittests/xpu/test_prelu_op_xpu.py @@ -43,7 +43,6 @@ class XPUTestPReluOp(XPUOpTestWrapper): self.set_xpu() self.op_type = "prelu" self.init_dtype() - self.eager_mode = True # override self.init_input_shape() @@ -70,8 +69,6 @@ class XPUTestPReluOp(XPUOpTestWrapper): ) else: self.alpha = np.random.uniform(-1, -0.5, [1] + self.x_shape[1:]) - # eager check don't support mode = 'all' - self.eager_mode = False self.alpha = self.alpha.astype(self.dtype) self.inputs = {'X': self.x, 'Alpha': self.alpha} @@ -115,7 +112,7 @@ class XPUTestPReluOp(XPUOpTestWrapper): def test_check_grad(self): self.check_grad_with_place( - self.place, ['X', 'Alpha'], 'Out', check_eager=self.eager_mode + self.place, ['X', 'Alpha'], 'Out', check_dygraph=False ) class TestModeChannelNHWC(TestPReluOp): diff --git a/python/paddle/fluid/tests/unittests/xpu/test_refactor_op_xpu.py b/python/paddle/fluid/tests/unittests/xpu/test_refactor_op_xpu.py index 1b424546d6432b61657c9fc6102fa92aceab7441..55f32c876c74a1e7476154d00dd5621dc7b3dcc5 100644 --- a/python/paddle/fluid/tests/unittests/xpu/test_refactor_op_xpu.py +++ b/python/paddle/fluid/tests/unittests/xpu/test_refactor_op_xpu.py @@ -19,7 +19,7 @@ import numpy as np sys.path.append("..") -from op_test import OpTest +from eager_op_test import OpTest from op_test_xpu import XPUOpTest from xpu.get_test_cover_info import ( XPUOpTestWrapper, diff --git a/python/paddle/fluid/tests/unittests/xpu/test_stack_op_xpu.py b/python/paddle/fluid/tests/unittests/xpu/test_stack_op_xpu.py index 86bbfb6a8ad20b920e18bb5aa241f71715162b62..8702b11e2321a12119127c0d733c0f0f80ceb56e 100644 --- a/python/paddle/fluid/tests/unittests/xpu/test_stack_op_xpu.py +++ b/python/paddle/fluid/tests/unittests/xpu/test_stack_op_xpu.py @@ -18,7 +18,7 @@ sys.path.append("..") import unittest import numpy as np -from op_test import skip_check_grad_ci +from eager_op_test import skip_check_grad_ci from op_test_xpu import XPUOpTest from xpu.get_test_cover_info import ( XPUOpTestWrapper, diff --git a/python/paddle/fluid/tests/unittests/xpu/test_temporal_shift_op_xpu.py b/python/paddle/fluid/tests/unittests/xpu/test_temporal_shift_op_xpu.py index 44b8e0dcb5e1de1b670624d3c9228c585f5b23d7..5af40a0c40f467684a6e4e431b9e262e80c85ef1 100644 --- a/python/paddle/fluid/tests/unittests/xpu/test_temporal_shift_op_xpu.py +++ b/python/paddle/fluid/tests/unittests/xpu/test_temporal_shift_op_xpu.py @@ -83,10 +83,10 @@ class XPUTestTemporalShiftOp(XPUOpTestWrapper): self.python_out_sig = ["Out"] def test_check_output(self): - self.check_output(check_eager=True) + self.check_output(check_dygraph=True) def test_check_grad(self): - self.check_grad(['X'], 'Out', check_eager=True) + self.check_grad(['X'], 'Out', check_dygraph=True) def initTestCase(self): self.x_shape = (6, 4, 4, 4) diff --git a/python/paddle/fluid/tests/unittests/xpu/test_warpctc_op_xpu.py b/python/paddle/fluid/tests/unittests/xpu/test_warpctc_op_xpu.py index 3cda4eaac1840b50db5d1ecfb00ede324124bacf..d09db48cffc51d5e17f4864d7fb3b00859984435 100644 --- a/python/paddle/fluid/tests/unittests/xpu/test_warpctc_op_xpu.py +++ b/python/paddle/fluid/tests/unittests/xpu/test_warpctc_op_xpu.py @@ -311,7 +311,7 @@ class XPUTestWarpCTCOp(XPUOpTestWrapper): } def test_check_output(self): - self.check_output(check_eager=False) + self.check_output(check_dygraph=False) def test_check_grad(self): self.outputs['WarpCTCGrad'] = self.gradient