未验证 提交 987d94a9 编写于 作者: Z Zhenghai Zhang 提交者: GitHub

[CodeStyle][CINN] fix Flake8 lint errors (pycodestyle rules) (#55074)

* fix Flake8 lint errors(pycodestyle)

* remove cinn files in per-file-ignores
上级 8753088c
...@@ -27,21 +27,3 @@ ignore = ...@@ -27,21 +27,3 @@ ignore =
per-file-ignores = per-file-ignores =
# These files need tabs for testing. # These files need tabs for testing.
test/dygraph_to_static/test_error.py:E101,W191 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,
...@@ -47,7 +47,7 @@ class TestArgSortOp(OpMapperTest): ...@@ -47,7 +47,7 @@ class TestArgSortOp(OpMapperTest):
return {'Out': ['int64'], 'Indices': ['int64']} return {'Out': ['int64'], 'Indices': ['int64']}
def skip_check_outputs(self): def skip_check_outputs(self):
#'Out' is never used in Paddle API # 'Out' is never used in Paddle API
return {"Out"} return {"Out"}
def test_check_results(self): def test_check_results(self):
......
...@@ -46,7 +46,7 @@ class TestFillConstantOp(OpTest): ...@@ -46,7 +46,7 @@ class TestFillConstantOp(OpTest):
self.value = eval(f"{dtype}(0)") self.value = eval(f"{dtype}(0)")
def build_paddle_program(self, target): def build_paddle_program(self, target):
if self.dtype == None: if self.dtype is None:
x = np.full(self.shape, self.value) x = np.full(self.shape, self.value)
x = paddle.to_tensor(x) x = paddle.to_tensor(x)
else: else:
...@@ -56,7 +56,7 @@ class TestFillConstantOp(OpTest): ...@@ -56,7 +56,7 @@ class TestFillConstantOp(OpTest):
def build_cinn_program(self, target): def build_cinn_program(self, target):
builder = NetBuilder("fill_constant") builder = NetBuilder("fill_constant")
if self.dtype == None: if self.dtype is None:
x = builder.fill_constant(self.shape, self.value, "out") x = builder.fill_constant(self.shape, self.value, "out")
else: else:
x = builder.fill_constant(self.shape, self.value, "out", self.dtype) x = builder.fill_constant(self.shape, self.value, "out", self.dtype)
......
...@@ -37,7 +37,7 @@ def cinn_dtype_convert(dtype_str): ...@@ -37,7 +37,7 @@ def cinn_dtype_convert(dtype_str):
################################## ##################################
#### TestElementwiseAddGrad #### # TestElementwiseAddGrad #
################################## ##################################
# 1) x is 0D, y is 0D # 1) x is 0D, y is 0D
@OpTestTool.skip_if( @OpTestTool.skip_if(
...@@ -109,7 +109,7 @@ class TestElementwiseAddGrad1(TestElementwiseAddGrad): ...@@ -109,7 +109,7 @@ class TestElementwiseAddGrad1(TestElementwiseAddGrad):
################################## ##################################
#### TestElementwiseBinaryOp #### # TestElementwiseBinaryOp #
################################## ##################################
@OpTestTool.skip_if( @OpTestTool.skip_if(
not is_compiled_with_cuda(), "x86 test will be skipped due to timeout." not is_compiled_with_cuda(), "x86 test will be skipped due to timeout."
...@@ -469,7 +469,7 @@ create_unit_test( ...@@ -469,7 +469,7 @@ create_unit_test(
###################### ######################
#### TestUnaryOp #### # TestUnaryOp #
###################### ######################
@OpTestTool.skip_if( @OpTestTool.skip_if(
not is_compiled_with_cuda(), "x86 test will be skipped due to timeout." not is_compiled_with_cuda(), "x86 test will be skipped due to timeout."
...@@ -585,7 +585,7 @@ class TestUnaryOp_acosh(TestUnaryOp): ...@@ -585,7 +585,7 @@ class TestUnaryOp_acosh(TestUnaryOp):
####################### #######################
#### TestSundryOp #### # TestSundryOp #
####################### #######################
@OpTestTool.skip_if( @OpTestTool.skip_if(
not is_compiled_with_cuda(), "x86 test will be skipped due to timeout." not is_compiled_with_cuda(), "x86 test will be skipped due to timeout."
......
...@@ -97,7 +97,7 @@ class SingleOpTester(unittest.TestCase): ...@@ -97,7 +97,7 @@ class SingleOpTester(unittest.TestCase):
) )
for in_data in temp_inputs: for in_data in temp_inputs:
args.append(runtime.cinn_pod_value_t(in_data)) 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( correct_result, output_shapes = self.create_target_data(
inputs_data, attrs inputs_data, attrs
) )
...@@ -142,7 +142,7 @@ class SingleOpTester(unittest.TestCase): ...@@ -142,7 +142,7 @@ class SingleOpTester(unittest.TestCase):
fn(args) fn(args)
out_result = out[len(out) - 1].numpy() out_result = out[len(out) - 1].numpy()
if out_index != None: if out_index is not None:
out_result = out[out_index].numpy() out_result = out[out_index].numpy()
np.testing.assert_allclose(out_result, correct_result, atol=1e-4) np.testing.assert_allclose(out_result, correct_result, atol=1e-4)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册