From c4d955b552263bf81b393e9d466f1e0511cc659e Mon Sep 17 00:00:00 2001 From: tqchen Date: Sun, 22 Feb 2026 16:22:25 +0000 Subject: [PATCH] [CI] Add GitHub Actions lint workflow This PR adds a GitHub Actions workflow that runs pre-commit hooks and removes the need on jenkins to do lint --- .asf.yaml | 1 - .github/workflows/lint.yml | 42 ++++++ pyproject.toml | 3 + python/tvm/script/ir_builder/relax/ir.py | 62 ++++----- python/tvm/script/parser/core/doc_core.py | 154 +++++++++++----------- python/tvm/script/parser/ir/__init__.py | 6 +- 6 files changed, 156 insertions(+), 112 deletions(-) create mode 100644 .github/workflows/lint.yml diff --git a/.asf.yaml b/.asf.yaml index f949c65a464b..c629d7775646 100644 --- a/.asf.yaml +++ b/.asf.yaml @@ -62,7 +62,6 @@ github: - cpu/pr-head - docker/pr-head - gpu/pr-head - - lint/pr-head - wasm/pr-head required_pull_request_reviews: diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 000000000000..17fa38339f81 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,42 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +name: Lint + +on: + push: + branches: [main] + pull_request: + branches: [main] + +concurrency: + group: Lint-${{ github.event.pull_request.number || github.sha }} + cancel-in-progress: true + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + fetch-depth: 0 + fetch-tags: true + - name: Set up uv + uses: astral-sh/setup-uv@b75a909f75acd358c2196fb9a5f1299a9a8868a4 # v6.7.0 + - name: Set up Python environment + run: uv sync --group lint --no-install-project + - uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1 diff --git a/pyproject.toml b/pyproject.toml index 38eb7475fbfc..a3b4c6d61896 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -287,3 +287,6 @@ ignore_errors = true [[tool.mypy.overrides]] module = ["python.tvm.runtime.*"] ignore_errors = true + +[dependency-groups] +lint = ["pre-commit"] diff --git a/python/tvm/script/ir_builder/relax/ir.py b/python/tvm/script/ir_builder/relax/ir.py index 0be2d38909b5..6bff4ef76a26 100644 --- a/python/tvm/script/ir_builder/relax/ir.py +++ b/python/tvm/script/ir_builder/relax/ir.py @@ -792,26 +792,27 @@ def dtype(value: Union[py_str, DataType]) -> Expr: __all__ = [ "Else", + "ExternFunc", "If", "SeqExpr", + "ShapeExpr", "Then", "TupleGetItem", - "ExternFunc", "abs", "acos", "acosh", - "asin", - "asinh", - "atan", - "atanh", "add", "arange", "arg", "argmax", "argmin", "argsort", + "asin", + "asinh", "assert_op", "astype", + "atan", + "atanh", "bitwise_and", "bitwise_not", "bitwise_or", @@ -819,40 +820,42 @@ def dtype(value: Union[py_str, DataType]) -> Expr: "broadcast_to", "bucketize", "builtin", + "call_builtin_with_ctx", + "call_dps_packed", "call_inplace_packed", "call_packed", "call_pure_packed", + "call_py_func", "call_tir", "call_tir_inplace", "call_tir_with_grad", - "call_dps_packed", - "call_py_func", - "call_builtin_with_ctx", + "ccl", "ceil", "clip", "collapse_sum_like", "collapse_sum_to", "concat", + "const", "cos", "cosh", - "const", "cpu", "cuda", "cumprod", "cumsum", - "einsum", - "scatter_elements", - "scatter_nd", "dataflow", + "dequantize", "device", "divide", "dtype", + "dynamic_strided_slice", + "einsum", "emit", + "emit_match_cast", "emit_te", "emit_var_binding", - "emit_match_cast", "emit_with_sinfo", "equal", + "erf", "ewise_fma", "exp", "expand_dims", @@ -879,8 +882,8 @@ def dtype(value: Union[py_str, DataType]) -> Expr: "hamming_window", "hexagon", "hint_on_device", - "index_put", "image", + "index_put", "index_tensor", "invoke_closure", "invoke_pure_closure", @@ -913,66 +916,67 @@ def dtype(value: Union[py_str, DataType]) -> Expr: "multinomial_from_uniform", "multiply", "negative", + "nn", "nonzero", "not_equal", "null_value", + "one_hot", "ones", "ones_like", - "one_hot", "opencl", - "output", "outer", + "output", "permute_dims", "power", "prim_value", "print", "prod", "quantize", - "dequantize", "repeat", "reshape", "rewriter", "right_shift", - "tensor_to_shape", - "shape_to_tensor", "rocm", "round", "rsqrt", + "scatter_elements", + "scatter_nd", "shape", "shape_of", - "ShapeExpr", - "size", - "std", - "str", - "sum", + "shape_to_tensor", "sigmoid", "sign", "sin", "sinh", + "size", "slice_scatter", "sort", "split", + "sqrt", "square", "squeeze", - "sqrt", "stack", + "std", "stop_lift_params", "str", + "str", "strided_slice", - "dynamic_strided_slice", "subtract", + "sum", "take", "tan", "tanh", + "tensor_to_shape", "tile", - "topk", "to_vdevice", + "topk", "tril", "triu", "trunc", "tuple", "unique", "variance", + "vision", "vm", "vpi", "vulkan", @@ -981,8 +985,4 @@ def dtype(value: Union[py_str, DataType]) -> Expr: "wrap_param", "zeros", "zeros_like", - "nn", - "ccl", - "erf", - "vision", ] diff --git a/python/tvm/script/parser/core/doc_core.py b/python/tvm/script/parser/core/doc_core.py index 344ac8cf878f..a4966d4dc4d6 100644 --- a/python/tvm/script/parser/core/doc_core.py +++ b/python/tvm/script/parser/core/doc_core.py @@ -952,103 +952,103 @@ def __init__(self, context_expr, optional_vars): __all__ = [ "AST", - "mod", - "Module", - "Interactive", - "Expression", - "stmt", - "FunctionDef", - "ClassDef", - "Return", - "Delete", - "Assign", - "AugAssign", + "Add", + "And", "AnnAssign", - "For", - "While", - "If", - "With", - "Raise", - "Try", "Assert", - "Import", - "ImportFrom", - "Global", - "Nonlocal", - "Expr", - "Pass", + "Assign", + "Attribute", + "AugAssign", + "BinOp", + "BitAnd", + "BitOr", + "BitXor", + "BoolOp", "Break", + "Call", + "ClassDef", + "Compare", + "Constant", "Continue", - "expr", - "BoolOp", - "BinOp", - "UnaryOp", - "Lambda", - "IfExp", + "Del", + "Delete", "Dict", - "Set", - "ListComp", - "SetComp", "DictComp", - "GeneratorExp", - "Yield", - "YieldFrom", - "Compare", - "Call", + "Div", + "Eq", + "ExceptHandler", + "Expr", + "Expression", + "FloorDiv", + "For", "FormattedValue", + "FunctionDef", + "GeneratorExp", + "Global", + "Gt", + "GtE", + "If", + "IfExp", + "Import", + "ImportFrom", + "In", + "Interactive", + "Invert", + "Is", + "IsNot", "JoinedStr", - "Constant", - "NamedExpr", - "Attribute", - "Slice", - "Subscript", - "Starred", - "Name", + "LShift", + "Lambda", "List", - "Tuple", - "expr_context", - "Del", + "ListComp", "Load", - "Store", - "boolop", - "And", - "Or", - "operator", - "Add", - "BitAnd", - "BitOr", - "BitXor", - "Div", - "FloorDiv", - "LShift", + "Lt", + "LtE", + "MatMult", "Mod", + "Module", "Mult", - "MatMult", + "Name", + "NamedExpr", + "Nonlocal", + "Not", + "NotEq", + "NotIn", + "Or", + "Pass", "Pow", "RShift", + "Raise", + "Return", + "Set", + "SetComp", + "Slice", + "Starred", + "Store", "Sub", - "unaryop", - "Invert", - "Not", + "Subscript", + "Try", + "Tuple", "UAdd", "USub", + "UnaryOp", + "While", + "With", + "Yield", + "YieldFrom", + "alias", + "arg", + "arguments", + "boolop", "cmpop", - "Eq", - "Gt", - "GtE", - "In", - "Is", - "IsNot", - "Lt", - "LtE", - "NotEq", - "NotIn", "comprehension", "excepthandler", - "ExceptHandler", - "arguments", - "arg", + "expr", + "expr_context", "keyword", - "alias", + "mod", + "operator", + "stmt", + "unaryop", "withitem", ] diff --git a/python/tvm/script/parser/ir/__init__.py b/python/tvm/script/parser/ir/__init__.py index fd4de5b3adc5..0d81bd75e271 100644 --- a/python/tvm/script/parser/ir/__init__.py +++ b/python/tvm/script/parser/ir/__init__.py @@ -24,12 +24,12 @@ __all__ = [ + "Range", + "dummy_global_info", "ir_module", + "lookup_vdevice", "module_attrs", "module_global_infos", - "dummy_global_info", - "Range", - "lookup_vdevice", "pyfunc", "vdevice", ]