From 987d94a97c82238ccca8366976d89e8198985471 Mon Sep 17 00:00:00 2001 From: Zhenghai Zhang <65210872+ccsuzzh@users.noreply.github.com> Date: Tue, 4 Jul 2023 08:44:37 +0800 Subject: [PATCH] [CodeStyle][CINN] fix Flake8 lint errors (pycodestyle rules) (#55074) * fix Flake8 lint errors(pycodestyle) * remove cinn files in per-file-ignores --- .flake8 | 18 ------------------ test/cinn/op_mappers/test_argsort_op.py | 2 +- test/cinn/ops/test_fill_constant_op.py | 4 ++-- test/cinn/ops/test_zero_dim_tensor.py | 8 ++++---- test/cinn/test_utils.py | 4 ++-- 5 files changed, 9 insertions(+), 27 deletions(-) diff --git a/.flake8 b/.flake8 index 8916c0d8998a1..ed87df8fb1b6f 100644 --- a/.flake8 +++ b/.flake8 @@ -27,21 +27,3 @@ ignore = per-file-ignores = # These files need tabs for testing. test/dygraph_to_static/test_error.py:E101,W191 - # Temporarily ignore CINN files, it will fix later - python/cinn/**: - E265, - test/cinn/**: - E126, - E231, - E251, - E265, - E266, - E401, - E711, - W291, - W504, - paddle/cinn/**: - E265, - tools/cinn/**: - E265, - E401, diff --git a/test/cinn/op_mappers/test_argsort_op.py b/test/cinn/op_mappers/test_argsort_op.py index d41cee91be93a..a4aad29a4c6eb 100644 --- a/test/cinn/op_mappers/test_argsort_op.py +++ b/test/cinn/op_mappers/test_argsort_op.py @@ -47,7 +47,7 @@ def set_op_outputs(self): return {'Out': ['int64'], 'Indices': ['int64']} def skip_check_outputs(self): - #'Out' is never used in Paddle API + # 'Out' is never used in Paddle API return {"Out"} def test_check_results(self): diff --git a/test/cinn/ops/test_fill_constant_op.py b/test/cinn/ops/test_fill_constant_op.py index 1c69f5574b2cc..1ccfc448b18eb 100644 --- a/test/cinn/ops/test_fill_constant_op.py +++ b/test/cinn/ops/test_fill_constant_op.py @@ -46,7 +46,7 @@ def prepare_inputs(self): self.value = eval(f"{dtype}(0)") def build_paddle_program(self, target): - if self.dtype == None: + if self.dtype is None: x = np.full(self.shape, self.value) x = paddle.to_tensor(x) else: @@ -56,7 +56,7 @@ def build_paddle_program(self, target): def build_cinn_program(self, target): builder = NetBuilder("fill_constant") - if self.dtype == None: + if self.dtype is None: x = builder.fill_constant(self.shape, self.value, "out") else: x = builder.fill_constant(self.shape, self.value, "out", self.dtype) diff --git a/test/cinn/ops/test_zero_dim_tensor.py b/test/cinn/ops/test_zero_dim_tensor.py index c6a01e3bdd78b..28d8cd94aaa90 100644 --- a/test/cinn/ops/test_zero_dim_tensor.py +++ b/test/cinn/ops/test_zero_dim_tensor.py @@ -37,7 +37,7 @@ def cinn_dtype_convert(dtype_str): ################################## -#### TestElementwiseAddGrad #### +# TestElementwiseAddGrad # ################################## # 1) x is 0D, y is 0D @OpTestTool.skip_if( @@ -109,7 +109,7 @@ def init_input(self): ################################## -#### TestElementwiseBinaryOp #### +# TestElementwiseBinaryOp # ################################## @OpTestTool.skip_if( not is_compiled_with_cuda(), "x86 test will be skipped due to timeout." @@ -469,7 +469,7 @@ def cinn_func(self, builder, *args): ###################### -#### TestUnaryOp #### +# TestUnaryOp # ###################### @OpTestTool.skip_if( not is_compiled_with_cuda(), "x86 test will be skipped due to timeout." @@ -585,7 +585,7 @@ def cinn_func(self, builder, x): ####################### -#### TestSundryOp #### +# TestSundryOp # ####################### @OpTestTool.skip_if( not is_compiled_with_cuda(), "x86 test will be skipped due to timeout." diff --git a/test/cinn/test_utils.py b/test/cinn/test_utils.py index ec29b28f9a1f3..45dd9ae629945 100755 --- a/test/cinn/test_utils.py +++ b/test/cinn/test_utils.py @@ -97,7 +97,7 @@ def to_test_op( ) for in_data in temp_inputs: args.append(runtime.cinn_pod_value_t(in_data)) - if output_shapes == None: + if output_shapes is None: correct_result, output_shapes = self.create_target_data( inputs_data, attrs ) @@ -142,7 +142,7 @@ def to_test_op( fn(args) out_result = out[len(out) - 1].numpy() - if out_index != None: + if out_index is not None: out_result = out[out_index].numpy() np.testing.assert_allclose(out_result, correct_result, atol=1e-4)