diff --git a/test/legacy_test/test_adadelta_op.py b/test/legacy_test/test_adadelta_op.py index 9202d6e2aa80fa..c7ae043fbac6f0 100644 --- a/test/legacy_test/test_adadelta_op.py +++ b/test/legacy_test/test_adadelta_op.py @@ -236,7 +236,7 @@ def test_adadelta_dygraph(self): adam.clear_gradients() -class TestAdadeltaOpMultiPrecison(unittest.TestCase): +class TestAdadeltaOpMultiPrecision(unittest.TestCase): def _test_adadelta_op_dygraph_place_amp(self, place, use_amp=False): import paddle diff --git a/test/legacy_test/test_adagrad_op.py b/test/legacy_test/test_adagrad_op.py index b1aab3c903248b..4d356e89d4784c 100644 --- a/test/legacy_test/test_adagrad_op.py +++ b/test/legacy_test/test_adagrad_op.py @@ -130,7 +130,7 @@ def check_with_place(self, place): param_array = np.full((height, row_numel), 5.0).astype("float32") param.set(param_array, place) - # create and initialize LeraningRate Variable + # create and initialize LearningRate Variable lr = scope.var('LearningRate').get_tensor() lr_array = np.full((1), 2.0).astype("float32") lr.set(lr_array, place) @@ -211,7 +211,7 @@ def test_sparse_adagrad(self): self.check_with_place(place) -class TestAdagradOpMultiPrecison(unittest.TestCase): +class TestAdagradOpMultiPrecision(unittest.TestCase): def _test_adagrad_op_dygraph_place_amp(self, place, use_amp=False): import paddle diff --git a/test/legacy_test/test_adam_op.py b/test/legacy_test/test_adam_op.py index 9a4e3c15553b54..0fc8c80190814b 100644 --- a/test/legacy_test/test_adam_op.py +++ b/test/legacy_test/test_adam_op.py @@ -758,7 +758,7 @@ def test_adam_op_with_state_dict(self): state_dict = adam.state_dict() adam.set_state_dict(state_dict) - # leanrning_rate is Tensor + # learning_rate is Tensor with self.assertRaises(TypeError): learning_rate = np.array([0.01]).astype("float32") learning_rate = paddle.to_tensor(learning_rate) diff --git a/test/legacy_test/test_adamax_op.py b/test/legacy_test/test_adamax_op.py index 4087e753982669..48549d6275a9f4 100644 --- a/test/legacy_test/test_adamax_op.py +++ b/test/legacy_test/test_adamax_op.py @@ -239,7 +239,7 @@ def test_adamax_op_invalid_input(self): ) -class TestAdamaxOpMultiPrecison(unittest.TestCase): +class TestAdamaxOpMultiPrecision(unittest.TestCase): def _test_adamax_op_dygraph_place_amp(self, place, use_amp=False): import paddle diff --git a/test/legacy_test/test_adamw_op.py b/test/legacy_test/test_adamw_op.py index 752e8076d3b144..1c901e8d4baf57 100644 --- a/test/legacy_test/test_adamw_op.py +++ b/test/legacy_test/test_adamw_op.py @@ -404,7 +404,7 @@ def test_adamw_op_dygraph_bypassing_step(self): adam.clear_gradients() -class TestAdamWOpMultiPrecisonWithMainGrad(unittest.TestCase): +class TestAdamWOpMultiPrecisionWithMainGrad(unittest.TestCase): def _test_adamw_op_dygraph_place_amp_with_maingrad( self, place, shape, use_main_grad ): @@ -543,7 +543,7 @@ def test_main(self): ) -class TestAdamWOpMultiPrecison(unittest.TestCase): +class TestAdamWOpMultiPrecision(unittest.TestCase): def _test_adamw_op_dygraph_place_amp(self, place, use_amp=False): paddle.disable_static() paddle.seed(10) diff --git a/test/legacy_test/test_add_n_op.py b/test/legacy_test/test_add_n_op.py index e543b4f05c74bc..60981b9cd02f0a 100644 --- a/test/legacy_test/test_add_n_op.py +++ b/test/legacy_test/test_add_n_op.py @@ -70,15 +70,15 @@ def test_add_n_api(self): if not paddle.is_compiled_with_cuda(): return dtypes = ['float32', 'complex64', 'complex128'] - for dtyte in dtypes: - if dtyte == 'complex64' or dtyte == 'complex128': + for dtype in dtypes: + if dtype == 'complex64' or dtype == 'complex128': self.x_np = ( np.random.random([self.l, 16, 256]) + 1j * np.random.random([self.l, 16, 256]) - ).astype(dtyte) + ).astype(dtype) - y_np_32, x_g_np_32 = self.check_main(self.x_np, dtyte) - y_np_gt = np.sum(self.x_np, axis=0).astype(dtyte) + y_np_32, x_g_np_32 = self.check_main(self.x_np, dtype) + y_np_gt = np.sum(self.x_np, axis=0).astype(dtype) np.testing.assert_allclose(y_np_32, y_np_gt, rtol=1e-06) diff --git a/test/legacy_test/test_arange.py b/test/legacy_test/test_arange.py index bb4bb0f430b68f..fbcc6eb421da50 100644 --- a/test/legacy_test/test_arange.py +++ b/test/legacy_test/test_arange.py @@ -59,7 +59,7 @@ def init_config(self): self.case = (0, 5, 1) -class TestFloa16ArangeOp(TestArangeOp): +class TestFloat16ArangeOp(TestArangeOp): def init_config(self): self.dtype = np.float16 self.python_api = paddle.arange diff --git a/test/legacy_test/test_backward.py b/test/legacy_test/test_backward.py index 2ae9ede04987a5..04aeadc0382133 100644 --- a/test/legacy_test/test_backward.py +++ b/test/legacy_test/test_backward.py @@ -378,12 +378,12 @@ def callback(block, context): class TestGradientsWithOptimizer(unittest.TestCase): - def _check_grad_op_name(self, forward_list, optimiezed_list): + def _check_grad_op_name(self, forward_list, optimized_list): backward_list = [op + "_grad" for op in reversed(forward_list)] - idx = optimiezed_list.index(backward_list[0], len(backward_list)) + idx = optimized_list.index(backward_list[0], len(backward_list)) self.assertListEqual( - backward_list, optimiezed_list[idx : idx + len(backward_list)] + backward_list, optimized_list[idx : idx + len(backward_list)] ) def test_gradient_with_optimizer(self): diff --git a/test/legacy_test/test_bicubic_interp_v2_op.py b/test/legacy_test/test_bicubic_interp_v2_op.py index 86b998c635648b..d2d0092f1e9f63 100644 --- a/test/legacy_test/test_bicubic_interp_v2_op.py +++ b/test/legacy_test/test_bicubic_interp_v2_op.py @@ -674,7 +674,7 @@ def test_case(self): class TestBicubicOpError(unittest.TestCase): def test_imperative_errors(self): - # the input of interpoalte must be Variable. + # the input of interpolate must be Variable. x1 = base.create_lod_tensor( np.array([-1, 3, 5, 5]), [[1, 1, 1, 1]], base.CPUPlace() ) @@ -687,7 +687,7 @@ def test_mode_type(): ) out = interpolate( - x, size=[12, 12], mode='UNKONWN', align_corners=False + x, size=[12, 12], mode='UNKNOWN', align_corners=False ) def test_input_shape(): @@ -696,7 +696,7 @@ def test_input_shape(): x, size=[12, 12], mode='BICUBIC', align_corners=False ) - def test_align_corcers(): + def test_align_corners(): x = paddle.static.data( name="x", shape=[2, 3, 6, 6], dtype="float32" ) @@ -887,7 +887,7 @@ def test_input_shape_1(): self.assertRaises(ValueError, test_mode_type) self.assertRaises(ValueError, test_input_shape) - self.assertRaises(TypeError, test_align_corcers) + self.assertRaises(TypeError, test_align_corners) self.assertRaises(ValueError, test_attr_data_format) self.assertRaises(TypeError, test_actual_shape) self.assertRaises(ValueError, test_scale_value) diff --git a/test/legacy_test/test_checkpoint_saver.py b/test/legacy_test/test_checkpoint_saver.py index 643ea78816579d..0390d4f8c60f03 100644 --- a/test/legacy_test/test_checkpoint_saver.py +++ b/test/legacy_test/test_checkpoint_saver.py @@ -18,7 +18,7 @@ from paddle.distributed.fleet.utils.fs import HDFSClient -class CheckpointerSaverTest(unittest.TestCase): +class CheckpointSaverTest(unittest.TestCase): def test(self): fs = HDFSClient("/usr/local/hadoop-2.7.7", None) dir_path = "./checkpointsaver_test" diff --git a/test/legacy_test/test_collective_api_base.py b/test/legacy_test/test_collective_api_base.py index 8f6a382297a1f1..f71b524344aec7 100644 --- a/test/legacy_test/test_collective_api_base.py +++ b/test/legacy_test/test_collective_api_base.py @@ -611,19 +611,19 @@ def convertbf16(origin): result1 = [] result2 = [] - def is_empyt_list(x): + def is_empty_list(x): if isinstance(x, list) and len(x) == 0: return True return False for i in range(tot_expert): for arr in output1[i]: - if is_empyt_list(arr): + if is_empty_list(arr): continue result1.append(arr) for i in range(tot_expert): for arr in output2[i]: - if is_empyt_list(arr): + if is_empty_list(arr): continue result2.append(arr) diff --git a/test/legacy_test/test_conv2d_api.py b/test/legacy_test/test_conv2d_api.py index 9d2398a5782caf..433dafbcd7fed2 100644 --- a/test/legacy_test/test_conv2d_api.py +++ b/test/legacy_test/test_conv2d_api.py @@ -201,7 +201,7 @@ def run_5(): self.assertRaises(ValueError, run_5) - # ValueError: channel dimmention + # ValueError: channel dimension x = paddle.static.data( name="x", shape=[2, 5, 5, -1], diff --git a/test/legacy_test/test_conv3d_layer.py b/test/legacy_test/test_conv3d_layer.py index d514f56c2631aa..55c4c569568aa0 100644 --- a/test/legacy_test/test_conv3d_layer.py +++ b/test/legacy_test/test_conv3d_layer.py @@ -27,7 +27,7 @@ def __init__( self, methodName='runTest', batch_size=4, - spartial_shape=(8, 8, 8), + spatial_shape=(8, 8, 8), num_channels=6, num_filters=8, filter_size=3, @@ -43,7 +43,7 @@ def __init__( self.batch_size = batch_size self.num_channels = num_channels self.num_filters = num_filters - self.spartial_shape = spartial_shape + self.spatial_shape = spatial_shape self.filter_size = filter_size self.padding = padding @@ -58,13 +58,13 @@ def setUp(self): self.channel_last = self.data_format == "NDHWC" if self.channel_last: input_shape = ( - (self.batch_size,) + self.spartial_shape + (self.num_channels,) + (self.batch_size,) + self.spatial_shape + (self.num_channels,) ) else: input_shape = ( self.batch_size, self.num_channels, - ) + self.spartial_shape + ) + self.spatial_shape self.input = np.random.randn(*input_shape).astype(self.dtype) if isinstance(self.filter_size, int): diff --git a/test/legacy_test/test_conv3d_op.py b/test/legacy_test/test_conv3d_op.py index cfa39de9220757..cd0d6449020ca0 100644 --- a/test/legacy_test/test_conv3d_op.py +++ b/test/legacy_test/test_conv3d_op.py @@ -1212,7 +1212,7 @@ def run_5(): self.assertRaises(ValueError, run_5) - # ValueError: channel dimmention + # ValueError: channel dimension x = paddle.static.data( name="x", shape=[2, 5, 5, 5, -1], diff --git a/test/legacy_test/test_conv3d_transpose_layer.py b/test/legacy_test/test_conv3d_transpose_layer.py index 7624253ba6031b..910513f6b4176b 100644 --- a/test/legacy_test/test_conv3d_transpose_layer.py +++ b/test/legacy_test/test_conv3d_transpose_layer.py @@ -27,7 +27,7 @@ def __init__( self, methodName='runTest', batch_size=2, - spartial_shape=(8, 8, 8), + spatial_shape=(8, 8, 8), num_channels=6, num_filters=8, filter_size=3, @@ -44,7 +44,7 @@ def __init__( self.batch_size = batch_size self.num_channels = num_channels self.num_filters = num_filters - self.spartial_shape = spartial_shape + self.spatial_shape = spatial_shape self.filter_size = filter_size self.output_size = output_size @@ -60,13 +60,13 @@ def setUp(self): self.channel_last = self.data_format == "NDHWC" if self.channel_last: input_shape = ( - (self.batch_size,) + self.spartial_shape + (self.num_channels,) + (self.batch_size,) + self.spatial_shape + (self.num_channels,) ) else: input_shape = ( self.batch_size, self.num_channels, - ) + self.spartial_shape + ) + self.spatial_shape self.input = np.random.randn(*input_shape).astype(self.dtype) if isinstance(self.filter_size, int): diff --git a/test/legacy_test/test_fused_attention_op_api.py b/test/legacy_test/test_fused_attention_op_api.py index 1570c0b0dd7335..e3ea9491e37820 100644 --- a/test/legacy_test/test_fused_attention_op_api.py +++ b/test/legacy_test/test_fused_attention_op_api.py @@ -53,9 +53,9 @@ def layer_norm(x, has_scale, has_bias, weight, bias, epsilon=1e-05): batch_size, src_len, d_model = x.shape x = x.reshape((batch_size * src_len, d_model)) mu = np.mean(x, axis=1, keepdims=True) - sigma_squar = np.sum(np.square(x - mu), axis=1) / d_model + sigma_square = np.sum(np.square(x - mu), axis=1) / d_model x1_up = x - mu - x1_down_1 = sigma_squar + epsilon + x1_down_1 = sigma_square + epsilon x1_down = np.sqrt(x1_down_1) x1_down = x1_down.reshape((x1_down.shape[0], 1)) x1 = x1_up / x1_down diff --git a/test/legacy_test/test_fused_bias_dropout_residual_layer_norm_op_api.py b/test/legacy_test/test_fused_bias_dropout_residual_layer_norm_op_api.py index dae2f2ba61c886..9efa1cd354cb3b 100644 --- a/test/legacy_test/test_fused_bias_dropout_residual_layer_norm_op_api.py +++ b/test/legacy_test/test_fused_bias_dropout_residual_layer_norm_op_api.py @@ -27,9 +27,9 @@ def layer_norm(x, has_scale, has_bias, weight, bias, epsilon=1e-05): batch_size, src_len, d_model = x.shape x = x.reshape((batch_size * src_len, d_model)) mu = np.mean(x, axis=1, keepdims=True) - sigma_squar = np.sum(np.square(x - mu), axis=1) / d_model + sigma_square = np.sum(np.square(x - mu), axis=1) / d_model x1_up = x - mu - x1_down_1 = sigma_squar + epsilon + x1_down_1 = sigma_square + epsilon x1_down = np.sqrt(x1_down_1) x1_down = x1_down.reshape((x1_down.shape[0], 1)) x1 = x1_up / x1_down diff --git a/test/legacy_test/test_log_softmax.py b/test/legacy_test/test_log_softmax.py index 64be97bb1aba15..494ba127032e42 100644 --- a/test/legacy_test/test_log_softmax.py +++ b/test/legacy_test/test_log_softmax.py @@ -194,7 +194,7 @@ def check_api(self, axis=-1): out = exe.run(feed={'x': self.x}, fetch_list=[y]) np.testing.assert_allclose(out[0], ref_out, rtol=1e-05) - # test dygrapg api + # test dygraph api paddle.disable_static() x = paddle.to_tensor(self.x) y = logsoftmax(x) diff --git a/test/legacy_test/test_paddle_save_load_binary.py b/test/legacy_test/test_paddle_save_load_binary.py index df7304cf1d19e5..22b62e082cc94a 100644 --- a/test/legacy_test/test_paddle_save_load_binary.py +++ b/test/legacy_test/test_paddle_save_load_binary.py @@ -94,7 +94,7 @@ def test_replace_save_load_vars(self): t = np.array( base.global_scope().find_var(var.name).get_tensor() ) - # make sure all the paramerter or optimizer var have been update + # make sure all the parameter or optimizer var have been update self.assertTrue(np.sum(np.abs(t)) != 0) base_map[var.name] = t # test for replace_save_vars/io.load_vars diff --git a/test/legacy_test/test_scatter_nd_op.py b/test/legacy_test/test_scatter_nd_op.py index 4936ccdb8989f2..531b865a7c50bd 100644 --- a/test/legacy_test/test_scatter_nd_op.py +++ b/test/legacy_test/test_scatter_nd_op.py @@ -29,16 +29,16 @@ def numpy_scatter_nd(ref, index, updates, fun): index_shape = index.shape end_size = index_shape[-1] - remain_numl = 1 + remain_numel = 1 for i in range(len(index_shape) - 1): - remain_numl *= index_shape[i] + remain_numel *= index_shape[i] slice_size = 1 for i in range(end_size, len(ref_shape)): slice_size *= ref_shape[i] - flat_index = index.reshape([remain_numl] + list(index_shape[-1:])) - flat_updates = updates.reshape((remain_numl, slice_size)) + flat_index = index.reshape([remain_numel] + list(index_shape[-1:])) + flat_updates = updates.reshape((remain_numel, slice_size)) flat_output = ref.reshape(list(ref_shape[:end_size]) + [slice_size]) for i_up, i_out in enumerate(flat_index): diff --git a/test/legacy_test/test_set_value_op.py b/test/legacy_test/test_set_value_op.py index c289185e58d212..4113805c663b49 100644 --- a/test/legacy_test/test_set_value_op.py +++ b/test/legacy_test/test_set_value_op.py @@ -265,7 +265,7 @@ def _get_answer(self): # 1.2.3 step < 0 -class TestSetValueItemSliceNegetiveStep(TestSetValueApi): +class TestSetValueItemSliceNegativeStep(TestSetValueApi): def set_shape(self): self.shape = [5, 2] @@ -283,7 +283,7 @@ def _get_answer(self): self.data[5:2:-1] = self.value -class TestSetValueItemSliceNegetiveStep2(TestSetValueApi): +class TestSetValueItemSliceNegativeStep2(TestSetValueApi): def set_shape(self): self.shape = [5] @@ -301,7 +301,7 @@ def _get_answer(self): self.data[1::-1] = self.value -class TestSetValueItemSliceNegetiveStep3(TestSetValueApi): +class TestSetValueItemSliceNegativeStep3(TestSetValueApi): def set_shape(self): self.shape = [3] @@ -319,7 +319,7 @@ def _get_answer(self): self.data[::-1] = self.value -class TestSetValueItemSliceNegetiveStep4(TestSetValueApi): +class TestSetValueItemSliceNegativeStep4(TestSetValueApi): def set_shape(self): self.shape = [3, 4, 5] @@ -1504,14 +1504,14 @@ def set_value(t, value): np.testing.assert_array_equal( inps.grad.numpy(), input_grad, - err_msg='The gradient of value should be \n{},\n but reveived {}'.format( + err_msg='The gradient of value should be \n{},\n but received {}'.format( input_grad, inps.grad.numpy() ), ) np.testing.assert_array_equal( value.grad.numpy(), value_grad, - err_msg='The gradient of input should be \n{},\n but reveived {}'.format( + err_msg='The gradient of input should be \n{},\n but received {}'.format( value_grad, value.grad.numpy() ), ) @@ -1538,14 +1538,14 @@ def set_value(t, value): np.testing.assert_array_equal( inps2.grad.numpy(), input_grad2, - err_msg='The gradient of value should be \n{},\n but reveived {}'.format( + err_msg='The gradient of value should be \n{},\n but received {}'.format( input_grad, inps2.grad.numpy() ), ) np.testing.assert_array_equal( value2.grad.numpy(), value_grad2, - err_msg='The gradient of input should be \n{},\n but reveived {}'.format( + err_msg='The gradient of input should be \n{},\n but received {}'.format( value_grad, value2.grad.numpy() ), ) @@ -1592,14 +1592,14 @@ def set_value3(t, value): np.testing.assert_array_equal( inps.grad.numpy(), input_grad, - err_msg='The gradient of value should be \n{},\n but reveived {}'.format( + err_msg='The gradient of value should be \n{},\n but received {}'.format( input_grad, inps.grad.numpy() ), ) np.testing.assert_array_equal( value.grad.numpy(), value_grad, - err_msg='The gradient of input should be \n{},\n but reveived {}'.format( + err_msg='The gradient of input should be \n{},\n but received {}'.format( value_grad, value.grad.numpy() ), ) @@ -1640,14 +1640,14 @@ def set_value4(t, value): np.testing.assert_array_equal( inps.grad.numpy(), input_grad, - err_msg='The gradient of value should be \n{},\n but reveived {}'.format( + err_msg='The gradient of value should be \n{},\n but received {}'.format( input_grad, inps.grad.numpy() ), ) np.testing.assert_array_equal( value.grad.numpy(), value_grad, - err_msg='The gradient of input should be \n{},\n but reveived {}'.format( + err_msg='The gradient of input should be \n{},\n but received {}'.format( value_grad, value.grad.numpy() ), ) @@ -1692,14 +1692,14 @@ def set_value5(t, value): np.testing.assert_array_equal( inps.grad.numpy(), input_grad, - err_msg='The gradient of value should be \n{},\n but reveived {}'.format( + err_msg='The gradient of value should be \n{},\n but received {}'.format( input_grad, inps.grad.numpy() ), ) np.testing.assert_array_equal( value.grad.numpy(), value_grad, - err_msg='The gradient of input should be \n{},\n but reveived {}'.format( + err_msg='The gradient of input should be \n{},\n but received {}'.format( value_grad, value.grad.numpy() ), ) diff --git a/test/legacy_test/test_sgd_op.py b/test/legacy_test/test_sgd_op.py index d71b2971858922..ba7dbb99d1b878 100644 --- a/test/legacy_test/test_sgd_op.py +++ b/test/legacy_test/test_sgd_op.py @@ -85,7 +85,7 @@ def check_with_place(self, place): param_array = np.full((height, self.row_numel), 5.0).astype("float32") param.set(param_array, place) - # create and initialize LeraningRate Variable + # create and initialize LearningRate Variable lr = scope.var('LearningRate').get_tensor() lr_array = np.full((1), 2.0).astype("float32") lr.set(lr_array, place) @@ -170,7 +170,7 @@ def check_with_place(self, place): w_before_optimize = np.array(w_tensor) - # create and initialize LeraningRate Variable + # create and initialize LearningRate Variable lr_value = 0.1 lr = scope.var('LearningRate').get_tensor() lr_array = np.full((1), lr_value).astype("float32") diff --git a/test/legacy_test/test_sgd_op_bf16.py b/test/legacy_test/test_sgd_op_bf16.py index 3baf0a490cbf53..3af7d9c6bc93af 100644 --- a/test/legacy_test/test_sgd_op_bf16.py +++ b/test/legacy_test/test_sgd_op_bf16.py @@ -286,7 +286,7 @@ def _reference(self, data, emb_weight, bf16=False): out_dtype = np.uint16 if bf16 else np.float32 lookup_table_grad = np.zeros(self.w_shape, dtype=out_dtype) - # indexes may dupplicate + # indexes may duplicate if bf16: for i, idx in enumerate(data): idxv = idx[0] diff --git a/test/legacy_test/test_signal.py b/test/legacy_test/test_signal.py index 1d86f15f510951..8d70702a26ad64 100644 --- a/test/legacy_test/test_signal.py +++ b/test/legacy_test/test_signal.py @@ -574,7 +574,7 @@ def decorate(cls): def setUpModule(): global rtol global atol - # All test case will use float64 for compare percision, refs: + # All test case will use float64 for compare precision, refs: # https://github.com/PaddlePaddle/Paddle/wiki/Upgrade-OP-Precision-to-Float64 rtol = { 'float32': 1e-06, diff --git a/test/legacy_test/test_slice_scatter.py b/test/legacy_test/test_slice_scatter.py index 075b5a57418865..bb46ddffb9b94f 100644 --- a/test/legacy_test/test_slice_scatter.py +++ b/test/legacy_test/test_slice_scatter.py @@ -264,7 +264,7 @@ def init_dtype(self): self.dtype = 'float32' -class TestSliceScatterApiBroadcase2D(TestSliceScatterApi): +class TestSliceScatterApiBroadcast2D(TestSliceScatterApi): def init_shape(self): self.x_shape = [8, 9] self.value_shape = [8, 1] @@ -274,12 +274,12 @@ def init_shape(self): self.strides = [2] -class TestSliceScatterApiBroadcase2DFloat32(TestSliceScatterApiBroadcase2D): +class TestSliceScatterApiBroadcast2DFloat32(TestSliceScatterApiBroadcast2D): def init_dtype(self): self.dtype = 'float32' -class TestSliceScatterApiBroadcase3D(TestSliceScatterApi): +class TestSliceScatterApiBroadcast3D(TestSliceScatterApi): def init_shape(self): self.x_shape = [8, 9, 6] self.value_shape = [1, 9, 1] @@ -289,7 +289,7 @@ def init_shape(self): self.strides = [3, 2] -class TestSliceScatterApiBroadcase3DFloat32(TestSliceScatterApiBroadcase3D): +class TestSliceScatterApiBroadcast3DFloat32(TestSliceScatterApiBroadcast3D): def init_dtype(self): self.dtype = 'float32' diff --git a/test/legacy_test/test_softmax_op.py b/test/legacy_test/test_softmax_op.py index 6b9952e569ae5d..1876424cf4d4ba 100644 --- a/test/legacy_test/test_softmax_op.py +++ b/test/legacy_test/test_softmax_op.py @@ -59,7 +59,7 @@ def setUp(self): self.public_python_api = F.softmax self.use_cudnn = False self.use_mkldnn = False - # explicilty use float32 for ROCm, as MIOpen does not yet support float64 + # explicitly use float32 for ROCm, as MIOpen does not yet support float64 self.dtype = np.float32 if core.is_compiled_with_rocm() else np.float64 self.init_kernel_type() self.shape = self.get_x_shape() @@ -142,7 +142,7 @@ def setUp(self): self.public_python_api = F.softmax self.use_cudnn = False self.use_mkldnn = False - # explicilty use float32 for ROCm, as MIOpen does not yet support float64 + # explicitly use float32 for ROCm, as MIOpen does not yet support float64 self.dtype = np.float32 if core.is_compiled_with_rocm() else np.float64 self.init_kernel_type() @@ -190,7 +190,7 @@ def setUp(self): self.prim_op_type = "comp" self.use_cudnn = True self.use_mkldnn = False - # explicilty use float32 for ROCm, as MIOpen does not yet support float64 + # explicitly use float32 for ROCm, as MIOpen does not yet support float64 self.dtype = np.float32 if core.is_compiled_with_rocm() else np.float64 np.random.seed(0) diff --git a/test/legacy_test/test_softmax_with_cross_entropy_op.py b/test/legacy_test/test_softmax_with_cross_entropy_op.py index 62f475cd922a7c..8bafae13efc703 100644 --- a/test/legacy_test/test_softmax_with_cross_entropy_op.py +++ b/test/legacy_test/test_softmax_with_cross_entropy_op.py @@ -99,7 +99,7 @@ def initParams(self): self.python_out_sig = ["Loss", "Softmax"] self.numeric_stable_mode = False self.soft_label = False - # explicilty use float32 for ROCm, as MIOpen does not yet support float64 + # explicitly use float32 for ROCm, as MIOpen does not yet support float64 self.dtype = np.float32 if core.is_compiled_with_rocm() else np.float64 self.axis = -1 self.ignore_index = -1 diff --git a/test/legacy_test/test_sparse_attention_op.py b/test/legacy_test/test_sparse_attention_op.py index 48946522864aa7..24272c5e416b0c 100644 --- a/test/legacy_test/test_sparse_attention_op.py +++ b/test/legacy_test/test_sparse_attention_op.py @@ -438,7 +438,7 @@ def test_dygraph(self): paddle_key = paddle.to_tensor(key, place=self.place) paddle_value = paddle.to_tensor(value, place=self.place) paddle_offset = paddle.to_tensor(offset, place=self.place) - paddle_colunmns = paddle.to_tensor(columns, place=self.place) + paddle_columns = paddle.to_tensor(columns, place=self.place) paddle_kp_mask = paddle.to_tensor(key_padding_mask, place=self.place) paddle_attn_mask = paddle.to_tensor(attn_mask, place=self.place) @@ -448,7 +448,7 @@ def test_dygraph(self): paddle_key, paddle_value, paddle_offset, - paddle_colunmns, + paddle_columns, key_padding_mask=paddle_kp_mask, attn_mask=paddle_attn_mask, ) @@ -469,7 +469,7 @@ def test_dygraph(self): paddle_key, paddle_value, paddle_offset, - paddle_colunmns, + paddle_columns, ) numpy_result, __, __ = ref_batch_sparse_attention( diff --git a/test/legacy_test/test_split_op.py b/test/legacy_test/test_split_op.py index 9311a5f2d99579..0f780b2ddfff63 100644 --- a/test/legacy_test/test_split_op.py +++ b/test/legacy_test/test_split_op.py @@ -567,9 +567,11 @@ def test_out1(self): eager_x2_out = x2.numpy() loss = x0.sum() loss.backward() - manul_grad = np.zeros_like(input_1) - manul_grad[:, :2, :] = 1 - np.testing.assert_allclose(input.gradient(), manul_grad, rtol=1e-05) + manual_grad = np.zeros_like(input_1) + manual_grad[:, :2, :] = 1 + np.testing.assert_allclose( + input.gradient(), manual_grad, rtol=1e-05 + ) np.testing.assert_allclose(ex_x0, eager_x0_out, rtol=1e-05) np.testing.assert_allclose(ex_x1, eager_x1_out, rtol=1e-05) np.testing.assert_allclose(ex_x2, eager_x2_out, rtol=1e-05) @@ -597,9 +599,11 @@ def test_out2(self): eager_x2_out = x2.numpy() loss = x0.sum() loss.backward() - manul_grad = np.zeros_like(input_1) - manul_grad[:, :2, :] = 1 - np.testing.assert_allclose(input.gradient(), manul_grad, rtol=1e-05) + manual_grad = np.zeros_like(input_1) + manual_grad[:, :2, :] = 1 + np.testing.assert_allclose( + input.gradient(), manual_grad, rtol=1e-05 + ) np.testing.assert_allclose(ex_x0, eager_x0_out, rtol=1e-05) np.testing.assert_allclose(ex_x1, eager_x1_out, rtol=1e-05) np.testing.assert_allclose(ex_x2, eager_x2_out, rtol=1e-05) @@ -630,9 +634,11 @@ def test_out1(self): eager_x2_out = x2.numpy() loss = x0.sum() loss.backward() - manul_grad = np.zeros_like(input_1) - manul_grad[:, :2, :] = 1 - np.testing.assert_allclose(input.gradient(), manul_grad, rtol=1e-05) + manual_grad = np.zeros_like(input_1) + manual_grad[:, :2, :] = 1 + np.testing.assert_allclose( + input.gradient(), manual_grad, rtol=1e-05 + ) np.testing.assert_allclose(ex_x0, eager_x0_out, rtol=1e-05) np.testing.assert_allclose(ex_x1, eager_x1_out, rtol=1e-05) np.testing.assert_allclose(ex_x2, eager_x2_out, rtol=1e-05) diff --git a/test/legacy_test/test_static_pylayer.py b/test/legacy_test/test_static_pylayer.py index fd5075a4904aa3..34a5afe577a67a 100644 --- a/test/legacy_test/test_static_pylayer.py +++ b/test/legacy_test/test_static_pylayer.py @@ -133,7 +133,7 @@ def backward_fn(dy): self.assertEqual(x_grad.shape, ()) @test_with_pir_api - def test_return_var_typle(self): + def test_return_var_type(self): def forward_fn(a, b): return 3 * a, -2 * b diff --git a/test/legacy_test/test_static_save_load.py b/test/legacy_test/test_static_save_load.py index ca1adaed4ef0ab..f662ee3f95e699 100644 --- a/test/legacy_test/test_static_save_load.py +++ b/test/legacy_test/test_static_save_load.py @@ -340,7 +340,7 @@ def test_ptb_rnn_cpu_float32(self): t = np.array( base.global_scope().find_var(var.name).get_tensor() ) - # make sure all the paramerter or optimizer var have been update + # make sure all the parameter or optimizer var have been update self.assertTrue(np.sum(np.abs(t)) != 0) base_map[var.name] = t @@ -357,7 +357,7 @@ def test_ptb_rnn_cpu_float32(self): new_t = np.array( base.global_scope().find_var(var.name).get_tensor() ) - # make sure all the paramerter or optimizer var have been set to zero + # make sure all the parameter or optimizer var have been set to zero self.assertTrue(np.sum(np.abs(new_t)) == 0) paddle.static.load( @@ -480,7 +480,7 @@ def test_ptb_rnn_cpu_float32(self): t = np.array( base.global_scope().find_var(var.name).get_tensor() ) - # make sure all the paramerter or optimizer var have been update + # make sure all the parameter or optimizer var have been update self.assertTrue(np.sum(np.abs(t)) != 0) base_map[var.name] = t @@ -497,7 +497,7 @@ def test_ptb_rnn_cpu_float32(self): new_t = np.array( base.global_scope().find_var(var.name).get_tensor() ) - # make sure all the paramerter or optimizer var have been set to zero + # make sure all the parameter or optimizer var have been set to zero self.assertTrue(np.sum(np.abs(new_t)) == 0) paddle.static.load( @@ -613,7 +613,7 @@ def test_ptb_rnn_cpu_float32(self): t = np.array( base.global_scope().find_var(var.name).get_tensor() ) - # make sure all the paramerter or optimizer var have been update + # make sure all the parameter or optimizer var have been update self.assertTrue(np.sum(np.abs(t)) != 0) base_map[var.name] = t @@ -630,7 +630,7 @@ def test_ptb_rnn_cpu_float32(self): new_t = np.array( base.global_scope().find_var(var.name).get_tensor() ) - # make sure all the paramerter or optimizer var have been set to zero + # make sure all the parameter or optimizer var have been set to zero self.assertTrue(np.sum(np.abs(new_t)) == 0) paddle.static.load( @@ -751,7 +751,7 @@ def test_ptb_rnn_cpu_float32(self): t = np.array( base.global_scope().find_var(var.name).get_tensor() ) - # make sure all the paramerter or optimizer var have been update + # make sure all the parameter or optimizer var have been update self.assertTrue(np.sum(np.abs(t)) != 0) base_map[var.name] = t @@ -768,7 +768,7 @@ def test_ptb_rnn_cpu_float32(self): new_t = np.array( base.global_scope().find_var(var.name).get_tensor() ) - # make sure all the paramerter or optimizer var have been set to zero + # make sure all the parameter or optimizer var have been set to zero self.assertTrue(np.sum(np.abs(new_t)) == 0) # base.load(test_program, "./test_1", None ) @@ -807,7 +807,7 @@ def test_ptb_rnn_cpu_float32(self): new_t = np.array( base.global_scope().find_var(var.name).get_tensor() ) - # make sure all the paramerter or optimizer var have been set to zero + # make sure all the parameter or optimizer var have been set to zero self.assertTrue(np.sum(np.abs(new_t)) == 0) paddle.static.set_program_state(test_program, program_state_1) @@ -829,7 +829,7 @@ def test_ptb_rnn_cpu_float32(self): new_t = np.array( base.global_scope().find_var(var.name).get_tensor() ) - # make sure all the paramerter or optimizer var have been set to zero + # make sure all the parameter or optimizer var have been set to zero self.assertTrue(np.sum(np.abs(new_t)) == 0) paddle.static.set_program_state(test_program, program_state_2) @@ -851,7 +851,7 @@ def test_ptb_rnn_cpu_float32(self): new_t = np.array( base.global_scope().find_var(var.name).get_tensor() ) - # make sure all the paramerter or optimizer var have been set to zero + # make sure all the parameter or optimizer var have been set to zero self.assertTrue(np.sum(np.abs(new_t)) == 0) paddle.static.set_program_state(test_program, program_state_3) @@ -954,7 +954,7 @@ def set_var(var, ndarray): t = np.array( base.global_scope().find_var(var.name).get_tensor() ) - # make sure all the paramerter or optimizer var have been update + # make sure all the parameter or optimizer var have been update base_map[var.name] = t for var in program.list_vars(): @@ -1073,7 +1073,7 @@ def test_load_from_old_interface(self): t = np.array( base.global_scope().find_var(var.name).get_tensor() ) - # make sure all the paramerter or optimizer var have been update + # make sure all the parameter or optimizer var have been update self.assertTrue(np.sum(np.abs(t)) != 0) base_map[var.name] = t @@ -1091,7 +1091,7 @@ def test_load_from_old_interface(self): new_t = np.array( base.global_scope().find_var(var.name).get_tensor() ) - # make sure all the paramerter or optimizer var have been set to zero + # make sure all the parameter or optimizer var have been set to zero self.assertTrue(np.sum(np.abs(new_t)) == 0) paddle.static.load( @@ -1214,7 +1214,7 @@ def test_load_from_old_interface_var_list(self): t = np.array( base.global_scope().find_var(var.name).get_tensor() ) - # make sure all the paramerter or optimizer var have been update + # make sure all the parameter or optimizer var have been update self.assertTrue(np.sum(np.abs(t)) != 0) base_map[var.name] = t @@ -1237,7 +1237,7 @@ def test_load_from_old_interface_var_list(self): new_t = np.array( base.global_scope().find_var(var.name).get_tensor() ) - # make sure all the paramerter or optimizer var have been set to zero + # make sure all the parameter or optimizer var have been set to zero self.assertTrue(np.sum(np.abs(new_t)) == 0) paddle.static.load( @@ -1355,7 +1355,7 @@ def test_load_from_old_interface(self): t = np.array( base.global_scope().find_var(var.name).get_tensor() ) - # make sure all the paramerter or optimizer var have been update + # make sure all the parameter or optimizer var have been update self.assertTrue(np.sum(np.abs(t)) != 0) base_map[var.name] = t save_dir = os.path.join(temp_dir.name, "test_path") @@ -1373,7 +1373,7 @@ def test_load_from_old_interface(self): new_t = np.array( base.global_scope().find_var(var.name).get_tensor() ) - # make sure all the paramerter or optimizer var have been set to zero + # make sure all the parameter or optimizer var have been set to zero self.assertTrue(np.sum(np.abs(new_t)) == 0) file_model_path = os.path.join(save_dir, "model_single") @@ -1556,7 +1556,7 @@ def test_ptb_rnn_cpu_float32(self): t = np.array( base.global_scope().find_var(var.name).get_tensor() ) - # make sure all the paramerter or optimizer var have been update + # make sure all the parameter or optimizer var have been update self.assertTrue(np.sum(np.abs(t)) != 0) base_map[var.name] = t save_dir = os.path.join(self.temp_dir.name, "test_program_1") @@ -1571,7 +1571,7 @@ def test_ptb_rnn_cpu_float32(self): new_t = np.array( base.global_scope().find_var(var.name).get_tensor() ) - # make sure all the paramerter or optimizer var have been set to zero + # make sure all the parameter or optimizer var have been set to zero self.assertTrue(np.sum(np.abs(new_t)) == 0) # case 1: load basic @@ -1731,7 +1731,7 @@ def test_ptb_rnn_cpu_float32(self): t = np.array( base.global_scope().find_var(var.name).get_tensor() ) - # make sure all the paramerter or optimizer var have been update + # make sure all the parameter or optimizer var have been update self.assertTrue(np.sum(np.abs(t)) != 0) base_map[var.name] = t @@ -1749,7 +1749,7 @@ def test_ptb_rnn_cpu_float32(self): new_t = np.array( base.global_scope().find_var(var.name).get_tensor() ) - # make sure all the paramerter or optimizer var have been set to zero + # make sure all the parameter or optimizer var have been set to zero self.assertTrue(np.sum(np.abs(new_t)) == 0) # base.load(test_program, "./test_1", None ) @@ -1816,7 +1816,7 @@ def test_pickle_protocol(self): t = np.array( base.global_scope().find_var(var.name).get_tensor() ) - # make sure all the paramerter or optimizer var have been update + # make sure all the parameter or optimizer var have been update self.assertTrue(np.sum(np.abs(t)) != 0) base_map[var.name] = t diff --git a/test/legacy_test/test_static_save_load_bf16.py b/test/legacy_test/test_static_save_load_bf16.py index 1ca1bec7d15e76..bc91f34b3f60c1 100644 --- a/test/legacy_test/test_static_save_load_bf16.py +++ b/test/legacy_test/test_static_save_load_bf16.py @@ -127,7 +127,7 @@ def test_ptb_rnn_cpu_bfloat16(self): t = np.array( base.global_scope().find_var(var.name).get_tensor() ) - # make sure all the paramerter or optimizer var have been update + # make sure all the parameter or optimizer var have been update self.assertTrue(np.sum(np.abs(t)) != 0) base_map[var.name] = t save_dir = os.path.join(self.temp_dir.name, "test_1") @@ -142,7 +142,7 @@ def test_ptb_rnn_cpu_bfloat16(self): new_t = np.array( base.global_scope().find_var(var.name).get_tensor() ) - # make sure all the paramerter or optimizer var have been set to zero + # make sure all the parameter or optimizer var have been set to zero self.assertTrue(np.sum(np.abs(new_t)) == 0) paddle.static.load( diff --git a/test/legacy_test/test_static_save_load_large.py b/test/legacy_test/test_static_save_load_large.py index 2011dd45cfaf82..d0ef10ae3a9abf 100644 --- a/test/legacy_test/test_static_save_load_large.py +++ b/test/legacy_test/test_static_save_load_large.py @@ -49,7 +49,7 @@ def test_large_parameters_static_save(self): t = np.array( base.global_scope().find_var(var.name).get_tensor() ) - # make sure all the paramerter or optimizer var have been update + # make sure all the parameter or optimizer var have been update self.assertTrue(np.sum(np.abs(t)) != 0) base_map[var.name] = t temp_dir = tempfile.TemporaryDirectory() diff --git a/test/legacy_test/test_static_shape_inferrence_for_shape_tensor.py b/test/legacy_test/test_static_shape_inferrence_for_shape_tensor.py index a38fd888819370..eaa910637bbd2a 100644 --- a/test/legacy_test/test_static_shape_inferrence_for_shape_tensor.py +++ b/test/legacy_test/test_static_shape_inferrence_for_shape_tensor.py @@ -17,7 +17,7 @@ import paddle -class StaticShapeInferrenceTest(unittest.TestCase): +class StaticShapeInferenceTest(unittest.TestCase): def test_static_graph(self): paddle.enable_static() data = paddle.static.data(name="x", shape=[-1, 2], dtype='float32') diff --git a/test/legacy_test/test_sum_op.py b/test/legacy_test/test_sum_op.py index cd2f9a4f6cdec1..a2570a566c3488 100644 --- a/test/legacy_test/test_sum_op.py +++ b/test/legacy_test/test_sum_op.py @@ -86,16 +86,16 @@ def setUp(self): self.init_kernel_type() def check_with_place(self, place, inplace): - self.check_input_and_optput( + self.check_input_and_output( core.Scope(), place, inplace, True, True, True ) - self.check_input_and_optput( + self.check_input_and_output( core.Scope(), place, inplace, False, True, True ) - self.check_input_and_optput( + self.check_input_and_output( core.Scope(), place, inplace, False, False, True ) - self.check_input_and_optput( + self.check_input_and_output( core.Scope(), place, inplace, False, False, False ) @@ -108,7 +108,7 @@ def _get_array(self, rows, row_numel): array[i] *= rows[i] return array - def check_input_and_optput( + def check_input_and_output( self, scope, place, @@ -198,7 +198,7 @@ def _get_array(self, rows, row_numel): else: return np.ndarray((0, row_numel), dtype=self.dtype) - def check_input_and_optput( + def check_input_and_output( self, scope, place, diff --git a/test/legacy_test/test_svd_op.py b/test/legacy_test/test_svd_op.py index a74404e4085244..6b41fa7cead8d5 100644 --- a/test/legacy_test/test_svd_op.py +++ b/test/legacy_test/test_svd_op.py @@ -90,7 +90,7 @@ def test_check_grad(self): class TestSvdCheckGrad2(TestSvdOp): - # NOTE(xiongkun03): because we want to construct some full rank matrics, + # NOTE(xiongkun03): because we want to construct some full rank matrices, # so we can't specifize matrices which numel() > 100 no_need_check_grad = True diff --git a/test/legacy_test/test_sync_batch_norm_op.py b/test/legacy_test/test_sync_batch_norm_op.py index 17daa24996b4ff..3b7ea63cb5963e 100644 --- a/test/legacy_test/test_sync_batch_norm_op.py +++ b/test/legacy_test/test_sync_batch_norm_op.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. """ -test for sync bachnorm op. +test for sync batchnorm op. for both FP64 and FP16 input. """ diff --git a/test/legacy_test/test_tensor.py b/test/legacy_test/test_tensor.py index 8c007d46753906..9207d3a181789f 100644 --- a/test/legacy_test/test_tensor.py +++ b/test/legacy_test/test_tensor.py @@ -339,7 +339,7 @@ def test_print_tensor(self): print(tensor) self.assertTrue(isinstance(str(tensor), str)) - def test_tensor_poiter(self): + def test_tensor_pointer(self): place = core.CPUPlace() scope = core.Scope() var = scope.var("test_tensor") diff --git a/test/legacy_test/test_tensor_register_hook.py b/test/legacy_test/test_tensor_register_hook.py index 29c614713dff30..c7826c983adcd7 100644 --- a/test/legacy_test/test_tensor_register_hook.py +++ b/test/legacy_test/test_tensor_register_hook.py @@ -589,7 +589,7 @@ def test_register_backward_hook_for_var_without_gradient(self): x._register_backward_hook(global_void_hook) -class TestRegsiterBackwardFinalHook(unittest.TestCase): +class TestRegisterBackwardFinalHook(unittest.TestCase): def setUp(self): self.devices = ["cpu"] if paddle.is_compiled_with_cuda(): diff --git a/test/legacy_test/test_tensor_uva.py b/test/legacy_test/test_tensor_uva.py index 34d7e59609e0bc..e7b6d03fe8bd93 100644 --- a/test/legacy_test/test_tensor_uva.py +++ b/test/legacy_test/test_tensor_uva.py @@ -53,7 +53,7 @@ def test_uva_tensor_creation(self): np.testing.assert_allclose(tensor.numpy(), data, rtol=1e-05) np.testing.assert_allclose(tensor2.numpy(), data, rtol=1e-05) - def test_uva_tensor_corectness(self): + def test_uva_tensor_correctness(self): if paddle.base.core.is_compiled_with_cuda(): a = np.arange(0, 100, dtype="int32") a = a.reshape([10, 10]) diff --git a/test/legacy_test/test_traced_layer_err_msg.py b/test/legacy_test/test_traced_layer_err_msg.py index 16880dafdcbf75..4927fdea82a549 100644 --- a/test/legacy_test/test_traced_layer_err_msg.py +++ b/test/legacy_test/test_traced_layer_err_msg.py @@ -241,7 +241,7 @@ def test_linear_net_with_none(self): class TestTracedLayerSaveInferenceModel(unittest.TestCase): - """test save_inference_model will automaticlly create non-exist dir""" + """test save_inference_model will automatically create non-exist dir""" def setUp(self): self.temp_dir = tempfile.TemporaryDirectory() diff --git a/test/legacy_test/test_trans_layout_op.py b/test/legacy_test/test_trans_layout_op.py index da59301aacfc3c..b936abc95df954 100644 --- a/test/legacy_test/test_trans_layout_op.py +++ b/test/legacy_test/test_trans_layout_op.py @@ -45,17 +45,17 @@ def test_check_output(self): class LayoutAutoTune(unittest.TestCase): def test_config(self): paddle.base.core.enable_layout_autotune() - if self.use_autoune(): + if self.use_autotune(): self.assertEqual(paddle.base.core.use_layout_autotune(), True) paddle.base.core.disable_layout_autotune() self.assertEqual(paddle.base.core.use_layout_autotune(), False) - self.use_autoune() + self.use_autotune() def setUp(self): paddle.disable_static() - self.use_autoune() + self.use_autotune() - def use_autoune(self): + def use_autotune(self): if paddle.is_compiled_with_cuda(): paddle.incubate.autotune.set_config( config={"layout": {"enable": True}} diff --git a/test/legacy_test/test_transformer_api.py b/test/legacy_test/test_transformer_api.py index 5945ac4a7d5d24..fd55abde22093f 100644 --- a/test/legacy_test/test_transformer_api.py +++ b/test/legacy_test/test_transformer_api.py @@ -252,9 +252,9 @@ def layer_norm(x, normalized_shape, norm, epsilon=1e-05, act=None): batch_size, src_len, d_model = x.shape x = x.reshape((batch_size * src_len, d_model)) mu = np.mean(x, axis=1, keepdims=True) - sigma_squar = np.sum(np.square(x - mu), axis=1) / d_model + sigma_square = np.sum(np.square(x - mu), axis=1) / d_model x1_up = x - mu - x1_down_1 = sigma_squar + epsilon + x1_down_1 = sigma_square + epsilon x1_down = np.sqrt(x1_down_1) x1_down = x1_down.reshape((x1_down.shape[0], 1)) x1 = x1_up / x1_down diff --git a/test/legacy_test/test_tril_triu_op.py b/test/legacy_test/test_tril_triu_op.py index 36a2ddb0383a77..391b7f83f9dc39 100644 --- a/test/legacy_test/test_tril_triu_op.py +++ b/test/legacy_test/test_tril_triu_op.py @@ -116,7 +116,7 @@ def test_check_grad_normal(self): def case_generator(op_type, Xshape, diagonal, expected, dtype): """ Generate testcases with the params shape of X, diagonal and op_type. - If arg`expercted` is 'success', it will register an Optest case and expect to pass. + If arg `expected` is 'success', it will register an OpTest case and expect to pass. Otherwise, it will register an API case and check the expect failure. """ cls_name = ( diff --git a/test/legacy_test/test_truncated_gaussian_random_op.py b/test/legacy_test/test_truncated_gaussian_random_op.py index eb8b502b082d4c..0572d0da6face2 100644 --- a/test/legacy_test/test_truncated_gaussian_random_op.py +++ b/test/legacy_test/test_truncated_gaussian_random_op.py @@ -22,7 +22,7 @@ from paddle.base.executor import Executor -class TestTrunctedGaussianRandomOp(unittest.TestCase): +class TestTruncatedGaussianRandomOp(unittest.TestCase): def setUp(self): self.op_type = "truncated_gaussian_random" self.inputs = {} diff --git a/test/legacy_test/test_vision_models.py b/test/legacy_test/test_vision_models.py index b53f1100305496..150ae03c58fe27 100644 --- a/test/legacy_test/test_vision_models.py +++ b/test/legacy_test/test_vision_models.py @@ -20,7 +20,7 @@ from paddle.vision import models -class TestVisonModels(unittest.TestCase): +class TestVisionModels(unittest.TestCase): def models_infer(self, arch, pretrained=False, batch_norm=False): x = np.array(np.random.random((2, 3, 224, 224)), dtype=np.float32) if batch_norm: diff --git a/test/legacy_test/test_viterbi_decode_op.py b/test/legacy_test/test_viterbi_decode_op.py index 91f79565a2caa7..fd5ff4b61f789e 100644 --- a/test/legacy_test/test_viterbi_decode_op.py +++ b/test/legacy_test/test_viterbi_decode_op.py @@ -31,7 +31,7 @@ def __call__(self, inputs, length): bs, seq_len, n_label = inputs.shape inputs_t = np.transpose(inputs, (1, 0, 2)) trans_exp = np.expand_dims(self.transitions, axis=0) - historys = [] + histories = [] left_length = np.array(length) max_seq_len = np.amax(left_length) left_length = np.expand_dims(left_length, 1) @@ -49,7 +49,7 @@ def __call__(self, inputs, length): alpha_exp = np.expand_dims(alpha, 2) alpha_trn_sum = alpha_exp + trans_exp max_res = np.amax(alpha_trn_sum, 1), np.argmax(alpha_trn_sum, 1) - historys = historys + [max_res[1]] if i >= 1 else [] + histories = histories + [max_res[1]] if i >= 1 else [] alpha_nxt = max_res[0] + logit mask = left_length > 0 alpha = mask * alpha_nxt + (1 - mask) * alpha @@ -61,7 +61,7 @@ def __call__(self, inputs, length): last_ids_update = last_ids * (left_length >= 0) batch_path = [last_ids_update] batch_offset = np.arange(bs) * n_label - for hist in reversed(historys): + for hist in reversed(histories): left_length = left_length + 1 gather_idx = batch_offset + last_ids last_ids_update = np.take(hist, gather_idx) * (left_length > 0) diff --git a/test/legacy_test/test_warpctc_op.py b/test/legacy_test/test_warpctc_op.py index e747f381af608e..9355eeec21ad59 100644 --- a/test/legacy_test/test_warpctc_op.py +++ b/test/legacy_test/test_warpctc_op.py @@ -110,7 +110,7 @@ def forward_a_sequence(self, softmax_a_sequence, labels_a_sequence): required_times = labels_a_sequence.shape[0] old_label = -1 for i in range(labels_a_sequence.shape[0]): - # two contingous labels with the same value + # two contiguous labels with the same value if labels_a_sequence[i, 0] == old_label: required_times = required_times + 1 old_label = labels_a_sequence[i, 0] diff --git a/test/legacy_test/test_where_op.py b/test/legacy_test/test_where_op.py index 16c6020d546506..d88b1b3b3a5a77 100644 --- a/test/legacy_test/test_where_op.py +++ b/test/legacy_test/test_where_op.py @@ -319,7 +319,7 @@ def __test_where_with_broadcast_static(self, cond_shape, x_shape, y_shape): np.testing.assert_array_equal(out[0], expect) def __test_where_with_type_promotion( - self, x_dtype, y_dtype, expeced_dtype=None + self, x_dtype, y_dtype, expected_dtype=None ): paddle.enable_static() main_program = paddle.static.Program() @@ -367,7 +367,7 @@ def __test_where_with_type_promotion( ) expect = np.where(cond_data, x_data_convert, y_data_convert) np.testing.assert_array_equal(out[0], expect) - self.assertEqual(out[0].dtype.__str__(), expeced_dtype) + self.assertEqual(out[0].dtype.__str__(), expected_dtype) else: expect = np.where(cond_data, x_data, y_data) np.testing.assert_array_equal(out[0], expect) diff --git a/test/legacy_test/test_while_loop_op.py b/test/legacy_test/test_while_loop_op.py index ec63375043e05d..3b8123d48df4ce 100644 --- a/test/legacy_test/test_while_loop_op.py +++ b/test/legacy_test/test_while_loop_op.py @@ -684,7 +684,7 @@ def type_error_cond_returns_not_variable(): self.assertRaises(TypeError, type_error_cond_returns_not_variable) - # The type of `cond` returns in Op(while_loop) must be a bollean variable + # The type of `cond` returns in Op(while_loop) must be a boolean variable def type_error_cond_returns_not_boolean(): out = paddle.static.nn.while_loop( cond_returns_not_bool_tensor, body, [data_1d] diff --git a/test/legacy_test/test_while_op.py b/test/legacy_test/test_while_op.py index d763576f9ff3a0..69dc4e1b8c070c 100644 --- a/test/legacy_test/test_while_op.py +++ b/test/legacy_test/test_while_op.py @@ -235,7 +235,7 @@ def body(i, s, x): x = paddle.static.data(shape=[-1], name='x', dtype='float32') func(x) - # NOTE(winter-wang): The while_op in pir mode doesn't need following constrait, so hre only check when in non-pir mode. + # NOTE(winter-wang): The while_op in pir mode doesn't need following constraint, so here only check when in non-pir mode. if not in_pir_mode(): for op in main_program.block(0).ops: if op.type == "while": diff --git a/test/legacy_test/test_zeros_like_op.py b/test/legacy_test/test_zeros_like_op.py index 538556cd4f1fcd..4768a2506f2493 100644 --- a/test/legacy_test/test_zeros_like_op.py +++ b/test/legacy_test/test_zeros_like_op.py @@ -59,7 +59,7 @@ def test_api(self): self.assertEqual((outs[i] == np.zeros(shape, dtype)).all(), True) -class TestZerosLikeImpeartive(unittest.TestCase): +class TestZerosLikeImperative(unittest.TestCase): def test_out(self): shape = [3, 4] place = ( diff --git a/test/mkldnn/test_elementwise_add_mkldnn_op.py b/test/mkldnn/test_elementwise_add_mkldnn_op.py index 9d62f1cf55e977..8b9dded0129bdd 100644 --- a/test/mkldnn/test_elementwise_add_mkldnn_op.py +++ b/test/mkldnn/test_elementwise_add_mkldnn_op.py @@ -102,21 +102,21 @@ def test_check_grad_ignore_x(self): pass -class TestOneDNNlementwiseAddOpZeroDim(TestOneDNNElementwiseAddOp): +class TestOneDNNElementwiseAddOpZeroDim(TestOneDNNElementwiseAddOp): def init_input_output(self): self.x = np.random.random((100,)).astype(self.dtype) self.y = np.array(3.0).astype(self.dtype) self.out = np.add(self.x, self.y) -class TestOneDNNlementwiseAddOpZeroDim2(TestOneDNNElementwiseAddOp): +class TestOneDNNElementwiseAddOpZeroDim2(TestOneDNNElementwiseAddOp): def init_input_output(self): self.x = np.array(3.0).astype(self.dtype) self.y = np.random.random((100,)).astype(self.dtype) self.out = np.add(self.x, self.y) -class TestOneDNNlementwiseAddOpZeroDim3(TestOneDNNElementwiseAddOp): +class TestOneDNNElementwiseAddOpZeroDim3(TestOneDNNElementwiseAddOp): def init_input_output(self): self.x = np.array(3.0).astype(self.dtype) self.y = np.array(3.0).astype(self.dtype) @@ -127,7 +127,7 @@ def init_input_output(self): @skip_check_grad_ci( - reason="oneDNN's int8 elementwise_ops don't implemend grad kernel." + reason="oneDNN's int8 elementwise_ops don't implement grad kernel." ) class TestInt8(TestElementwiseAddOp): def init_kernel_type(self): diff --git a/test/mkldnn/test_fused_vit_attention.py b/test/mkldnn/test_fused_vit_attention.py index 8c4876e4281b25..b980f8bff912a8 100644 --- a/test/mkldnn/test_fused_vit_attention.py +++ b/test/mkldnn/test_fused_vit_attention.py @@ -23,7 +23,7 @@ np.random.seed(0) -def test_fuse_resenet_unit(): +def test_fuse_resnet_unit(): tests = [[1, 4096, 768, 12], [10, 4097, 756, 12], [10, 4097, 756, 12]] for test in tests: batch_size = test[0] @@ -74,4 +74,4 @@ def test_fuse_resenet_unit(): if __name__ == '__main__': - test_fuse_resenet_unit() + test_fuse_resnet_unit() diff --git a/test/mkldnn/test_fusion_gru_bf16_mkldnn_op.py b/test/mkldnn/test_fusion_gru_bf16_mkldnn_op.py index ae44798dce4eb3..fd9925df082e07 100644 --- a/test/mkldnn/test_fusion_gru_bf16_mkldnn_op.py +++ b/test/mkldnn/test_fusion_gru_bf16_mkldnn_op.py @@ -59,7 +59,7 @@ def setUp(self): N = len(self.lod[0]) # fp32 X input for reference implementation and - # corressponding bf16 data as input to GRU oneDNN bf16 kernel + # corresponding bf16 data as input to GRU oneDNN bf16 kernel x_fp32 = np.random.rand(T, self.M).astype('float32') x_bf16 = convert_float_to_uint16(x_fp32)