未验证 提交 993c163e 编写于 作者: G gouzil 提交者: GitHub

[CodeStyle][CINN] fix Ruff lint errors (pylint rules) (#54990)

* [codestyle] fix ruff PLR0402

* [codestyle] fix ruff PLC0414

* [codestyle] fix ruff PLE1205
上级 2bcc8b84
...@@ -107,12 +107,7 @@ ignore = [ ...@@ -107,12 +107,7 @@ ignore = [
"F403", "F403",
"F632", "F632",
"F811", "F811",
"PLR0402",
"PLC0414",
"PLE1205",
] ]
"tools/cinn/**" = [ "tools/cinn/**" = [
"F401", "F401",
"PLR0402",
] ]
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
import numpy as np import numpy as np
import paddle import paddle
import paddle.static as static from paddle import static
def conv2d_native(inputs_data, input_shape, filter_size, attrs, is_depthwise): def conv2d_native(inputs_data, input_shape, filter_size, attrs, is_depthwise):
......
...@@ -19,8 +19,7 @@ import numpy ...@@ -19,8 +19,7 @@ import numpy
import numpy as np import numpy as np
import paddle import paddle
import paddle.fluid as fluid from paddle import fluid, static
import paddle.static as static
size = 30 size = 30
paddle.enable_static() paddle.enable_static()
......
...@@ -21,8 +21,7 @@ import numpy ...@@ -21,8 +21,7 @@ import numpy
import numpy as np import numpy as np
import paddle import paddle
import paddle.fluid as fluid from paddle import fluid, static
import paddle.static as static
size = 64 size = 64
num_layers = 6 num_layers = 6
......
...@@ -19,8 +19,7 @@ import numpy ...@@ -19,8 +19,7 @@ import numpy
import numpy as np import numpy as np
import paddle import paddle
import paddle.fluid as fluid from paddle import fluid, static
import paddle.static as static
paddle.enable_static() paddle.enable_static()
......
...@@ -308,7 +308,7 @@ class OpMapperTest(OpTest): ...@@ -308,7 +308,7 @@ class OpMapperTest(OpTest):
if results[i] is not None and len(results[i].shape) == 0: if results[i] is not None and len(results[i].shape) == 0:
results[i] = results[i].reshape(1) results[i] = results[i].reshape(1)
logger.debug(msg="Paddle result:") logger.debug("Paddle result:")
self.paddle_outputs = self.__remove_skip_outputs(results) self.paddle_outputs = self.__remove_skip_outputs(results)
def build_cinn_program(self, target): def build_cinn_program(self, target):
...@@ -398,7 +398,7 @@ class OpMapperTest(OpTest): ...@@ -398,7 +398,7 @@ class OpMapperTest(OpTest):
scope=scope, scope=scope,
) )
logger.debug(msg="CINN result:") logger.debug("CINN result:")
self.cinn_outputs = self.__remove_skip_outputs(results) self.cinn_outputs = self.__remove_skip_outputs(results)
@staticmethod @staticmethod
......
...@@ -19,7 +19,7 @@ from op_test import OpTest, OpTestTool ...@@ -19,7 +19,7 @@ from op_test import OpTest, OpTestTool
from op_test_helper import TestCaseHelper from op_test_helper import TestCaseHelper
import paddle import paddle
import paddle.nn as nn from paddle import nn
@OpTestTool.skip_if( @OpTestTool.skip_if(
......
...@@ -25,8 +25,7 @@ from cinn.framework import * ...@@ -25,8 +25,7 @@ from cinn.framework import *
from cinn.frontend import * from cinn.frontend import *
import paddle import paddle
import paddle.fluid as fluid from paddle import fluid, static
import paddle.static as static
assert len(sys.argv) == 3 assert len(sys.argv) == 3
enable_gpu = sys.argv.pop() enable_gpu = sys.argv.pop()
......
...@@ -25,8 +25,8 @@ from cinn.common import * ...@@ -25,8 +25,8 @@ from cinn.common import *
from cinn.framework import * from cinn.framework import *
from cinn.frontend import * from cinn.frontend import *
import paddle as paddle import paddle
import paddle.fluid as fluid from paddle import fluid
enable_gpu = sys.argv.pop() enable_gpu = sys.argv.pop()
model_dir = sys.argv.pop() model_dir = sys.argv.pop()
......
...@@ -25,8 +25,8 @@ from cinn.common import * ...@@ -25,8 +25,8 @@ from cinn.common import *
from cinn.framework import * from cinn.framework import *
from cinn.frontend import * from cinn.frontend import *
import paddle as paddle import paddle
import paddle.fluid as fluid from paddle import fluid
enable_gpu = sys.argv.pop() enable_gpu = sys.argv.pop()
model_dir = sys.argv.pop() model_dir = sys.argv.pop()
......
...@@ -25,7 +25,7 @@ from cinn.framework import * ...@@ -25,7 +25,7 @@ from cinn.framework import *
from cinn.frontend import * from cinn.frontend import *
import paddle import paddle
import paddle.fluid as fluid from paddle import fluid
assert len(sys.argv) == 1 + 2 + 1 # model and enable_gpu count assert len(sys.argv) == 1 + 2 + 1 # model and enable_gpu count
enable_gpu = sys.argv.pop() enable_gpu = sys.argv.pop()
......
...@@ -25,8 +25,8 @@ from cinn.common import * ...@@ -25,8 +25,8 @@ from cinn.common import *
from cinn.framework import * from cinn.framework import *
from cinn.frontend import * from cinn.frontend import *
import paddle as paddle import paddle
import paddle.fluid as fluid from paddle import fluid
enable_gpu = sys.argv.pop() enable_gpu = sys.argv.pop()
model_dir = sys.argv.pop() model_dir = sys.argv.pop()
......
...@@ -25,8 +25,8 @@ from cinn.common import * ...@@ -25,8 +25,8 @@ from cinn.common import *
from cinn.framework import * from cinn.framework import *
from cinn.frontend import * from cinn.frontend import *
import paddle as paddle import paddle
import paddle.fluid as fluid from paddle import fluid
enable_gpu = sys.argv.pop() enable_gpu = sys.argv.pop()
model_dir = sys.argv.pop() model_dir = sys.argv.pop()
......
...@@ -25,7 +25,7 @@ from cinn.framework import * ...@@ -25,7 +25,7 @@ from cinn.framework import *
from cinn.frontend import * from cinn.frontend import *
import paddle import paddle
import paddle.static as static from paddle import static
enable_gpu = sys.argv.pop() enable_gpu = sys.argv.pop()
......
...@@ -25,7 +25,7 @@ from cinn.framework import * ...@@ -25,7 +25,7 @@ from cinn.framework import *
from cinn.frontend import * from cinn.frontend import *
import paddle import paddle
import paddle.static as static from paddle import static
assert len(sys.argv) == 2 assert len(sys.argv) == 2
enable_gpu = sys.argv.pop() enable_gpu = sys.argv.pop()
......
...@@ -26,7 +26,7 @@ from cinn import common, framework, frontend, ir, lang, runtime ...@@ -26,7 +26,7 @@ from cinn import common, framework, frontend, ir, lang, runtime
from cinn.poly import create_stages from cinn.poly import create_stages
from test_utils import SingleOpTester from test_utils import SingleOpTester
import paddle as paddle import paddle
class OpTest_relu(SingleOpTester): class OpTest_relu(SingleOpTester):
......
...@@ -26,7 +26,7 @@ from cinn.poly import create_stages ...@@ -26,7 +26,7 @@ from cinn.poly import create_stages
from test_utils import SingleOpTester from test_utils import SingleOpTester
import paddle import paddle
import paddle.static as static from paddle import static
os.environ["KMP_DUPLICATE_LIB_OK"] = "TRUE" os.environ["KMP_DUPLICATE_LIB_OK"] = "TRUE"
......
...@@ -24,8 +24,8 @@ from cinn.common import * ...@@ -24,8 +24,8 @@ from cinn.common import *
from cinn.framework import * from cinn.framework import *
from cinn.frontend import * from cinn.frontend import *
import paddle as paddle import paddle
import paddle.fluid as fluid from paddle import fluid
enable_gpu = sys.argv.pop() enable_gpu = sys.argv.pop()
model_dir = sys.argv.pop() model_dir = sys.argv.pop()
......
...@@ -25,8 +25,8 @@ from cinn.common import * ...@@ -25,8 +25,8 @@ from cinn.common import *
from cinn.framework import * from cinn.framework import *
from cinn.frontend import * from cinn.frontend import *
import paddle as paddle import paddle
import paddle.fluid as fluid from paddle import fluid
enable_gpu = sys.argv.pop() enable_gpu = sys.argv.pop()
model_dir = sys.argv.pop() model_dir = sys.argv.pop()
......
...@@ -25,8 +25,8 @@ from cinn.common import * ...@@ -25,8 +25,8 @@ from cinn.common import *
from cinn.framework import * from cinn.framework import *
from cinn.frontend import * from cinn.frontend import *
import paddle as paddle import paddle
import paddle.fluid as fluid from paddle import fluid
enable_gpu = sys.argv.pop() enable_gpu = sys.argv.pop()
model_dir = sys.argv.pop() model_dir = sys.argv.pop()
......
...@@ -25,8 +25,8 @@ from cinn.common import * ...@@ -25,8 +25,8 @@ from cinn.common import *
from cinn.framework import * from cinn.framework import *
from cinn.frontend import * from cinn.frontend import *
import paddle as paddle import paddle
import paddle.fluid as fluid from paddle import fluid
enable_gpu = sys.argv.pop() enable_gpu = sys.argv.pop()
model_dir = sys.argv.pop() model_dir = sys.argv.pop()
......
...@@ -19,8 +19,7 @@ import numpy ...@@ -19,8 +19,7 @@ import numpy
import numpy as np import numpy as np
import paddle import paddle
import paddle.fluid as fluid from paddle import fluid, static
import paddle.static as static
# For paddlepaddle version >=2.0rc, we need to set paddle.enable_static() # For paddlepaddle version >=2.0rc, we need to set paddle.enable_static()
paddle.enable_static() paddle.enable_static()
......
...@@ -20,8 +20,7 @@ import time ...@@ -20,8 +20,7 @@ import time
import numpy as np import numpy as np
import paddle import paddle
import paddle.fluid as fluid from paddle import fluid, static
import paddle.static as static
from paddle.fluid.core import AnalysisConfig, create_paddle_predictor from paddle.fluid.core import AnalysisConfig, create_paddle_predictor
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册