From 559cae7699b40e8bda994541bc65b78cf17e6f6b Mon Sep 17 00:00:00 2001 From: Eric Lunderberg Date: Wed, 13 Mar 2024 16:57:39 -0500 Subject: [PATCH] Lint fixes --- python/tvm/relax/frontend/nn/core.py | 8 ++++---- python/tvm/relax/frontend/nn/exporter.py | 10 ---------- python/tvm/relax/frontend/nn/replace_implementation.py | 4 +++- python/tvm/relax/frontend/nn/spec.py | 4 ++-- 4 files changed, 9 insertions(+), 17 deletions(-) diff --git a/python/tvm/relax/frontend/nn/core.py b/python/tvm/relax/frontend/nn/core.py index 306180c1cedc7..3b133c2043ea7 100644 --- a/python/tvm/relax/frontend/nn/core.py +++ b/python/tvm/relax/frontend/nn/core.py @@ -599,10 +599,10 @@ def wrap_nested(expr: rx.Expr, name: str) -> Union[Tensor, Sequence[Tensor]]: # struct info for a nested expression should be doable in # a free function, without requiring an active # BlockBuilder and an active scope. - bb = BlockBuilder() - with bb.function("dummy_scope", params=[]): - expr = bb.normalize(expr) - bb.emit_func_output([]) + builder = BlockBuilder() + with builder.function("dummy_scope", params=[]): + expr = builder.normalize(expr) + builder.emit_func_output([]) else: expr = BlockBuilder.current().emit(expr, name) if isinstance(expr.struct_info_, TensorStructInfo): diff --git a/python/tvm/relax/frontend/nn/exporter.py b/python/tvm/relax/frontend/nn/exporter.py index 136ab986081f5..6882dd8edac5e 100644 --- a/python/tvm/relax/frontend/nn/exporter.py +++ b/python/tvm/relax/frontend/nn/exporter.py @@ -162,8 +162,6 @@ def _emit_method( # pylint: disable=too-many-locals,too-many-branches,too-many- effects: typing.Optional[typing.List[typing.Tuple[str, core.Effect]]], ): # pylint: disable=protected-access - # symbolic shape's name mapping to its tir.Var for reuse - str2var_params: typing.Dict[str, tir.Var] = {} def _unwrap_ret(expr: typing.Any) -> typing.Any: if isinstance(expr, (core.Tensor, core.Object)): @@ -189,14 +187,6 @@ def _convert_input(arg): raise TypeError(f"Unsupported input type: {type(arg)}") def _params(mode: str) -> typing.List[rx.Var]: - def _get_var(shape_var: tir.Var) -> tir.Var: - name = shape_var.name - if name in str2var_params: - return str2var_params[name] - var = tir.Var(name, "int64") - str2var_params[name] = var - return var - param_vars: typing.List[rx.Var] = [ rx.Var(name, rx.TensorStructInfo(param.shape, param.dtype)) for name, param in params ] diff --git a/python/tvm/relax/frontend/nn/replace_implementation.py b/python/tvm/relax/frontend/nn/replace_implementation.py index c5c1365028649..9f6838b9e154c 100644 --- a/python/tvm/relax/frontend/nn/replace_implementation.py +++ b/python/tvm/relax/frontend/nn/replace_implementation.py @@ -14,6 +14,8 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. +"""Pattern matching in SLM""" + import inspect from typing import Dict, Tuple, List @@ -116,7 +118,7 @@ def transform(mod, _context): return transform -def _no_op_init__(self): +def _no_op_init__(self): # pylint: ignore=unused-argument pass diff --git a/python/tvm/relax/frontend/nn/spec.py b/python/tvm/relax/frontend/nn/spec.py index 1a1e80d97e5c9..015963134c4c5 100644 --- a/python/tvm/relax/frontend/nn/spec.py +++ b/python/tvm/relax/frontend/nn/spec.py @@ -18,6 +18,8 @@ import inspect import typing +import tvm + if typing.TYPE_CHECKING: from .core import Module as nn_module_class @@ -26,8 +28,6 @@ ModuleSpecType = typing.Union["ModuleSpec", typing.Dict[str, MethodSpecType]] SpecAny = typing.Union["Object", "Int", "Tensor", "Tuple"] -import tvm - class Int: # pylint: disable=too-few-public-methods """An integer input"""