Skip to content

Commit

Permalink
Update pylint
Browse files Browse the repository at this point in the history
  • Loading branch information
yongwww committed Apr 24, 2023
1 parent 3733a23 commit dc9c02d
Show file tree
Hide file tree
Showing 92 changed files with 143 additions and 91 deletions.
2 changes: 1 addition & 1 deletion gallery/how_to/tune_with_autotvm/tune_conv2d_cuda.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def conv2d_no_batching(N, H, W, CO, CI, KH, KW, stride, padding):
# see many error reports. As long as you can see non-zero GFLOPS, it is okay.
tuner = autotvm.tuner.XGBTuner(task)
tuner.tune(
n_trial=20,
n_trial=5,
measure_option=measure_option,
callbacks=[autotvm.callback.log_to_file("conv2d.log")],
)
Expand Down
2 changes: 1 addition & 1 deletion gallery/how_to/work_with_relay/build_gcn.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ def prepare_params(g, data):
) # Only support float32 as feature for now

# Generate adjacency matrix
adjacency = nx.to_scipy_sparse_matrix(g)
adjacency = nx.to_scipy_sparse_array(g)
params["g_data"] = adjacency.data.astype("float32")
params["indices"] = adjacency.indices.astype("int32")
params["indptr"] = adjacency.indptr.astype("int32")
Expand Down
3 changes: 2 additions & 1 deletion python/tvm/_ffi/_ctypes/packed_func.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
# specific language governing permissions and limitations
# under the License.
# coding: utf-8
# pylint: disable=invalid-name, protected-access, too-many-branches, global-statement, unused-import
# pylint: disable=invalid-name, protected-access, too-many-branches
# pylint: disable=global-statement, unused-import, using-constant-test
"""Function configuration API."""
import ctypes
import traceback
Expand Down
1 change: 1 addition & 0 deletions python/tvm/arith/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# pylint: disable=invalid-name
"""Arithmetic data structure and utility"""
from enum import IntEnum
import tvm._ffi
Expand Down
2 changes: 1 addition & 1 deletion python/tvm/autotvm/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# pylint: disable=consider-using-enumerate,invalid-name
# pylint: disable=consider-using-enumerate, invalid-name, use-list-literal
"""
Database of MeasureInput/MeasureResult pair.
This can be used for replaying measurement.
Expand Down
1 change: 1 addition & 0 deletions python/tvm/autotvm/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# pylint: disable=global-variable-not-assigned
"""Global configuration/variable scope for autotvm"""


Expand Down
2 changes: 1 addition & 1 deletion python/tvm/autotvm/graph_tuner/pbqp_tuner.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# pylint: disable=invalid-name,too-many-locals
# pylint: disable=invalid-name, too-many-locals, unnecessary-list-index-lookup
"""Partitioned Boolean Quadratic Programming Tuner"""
from ._base import INVALID_LAYOUT_TIME
from .base_graph_tuner import BaseGraphTuner
Expand Down
2 changes: 1 addition & 1 deletion python/tvm/autotvm/task/space.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# specific language governing permissions and limitations
# under the License.
# pylint: disable=too-few-public-methods,invalid-name,unused-argument,arguments-differ
# pylint: disable=consider-using-enumerate,too-many-lines
# pylint: disable=consider-using-enumerate,too-many-lines, invalid-sequence-index
"""
Template configuration space.
Expand Down
2 changes: 1 addition & 1 deletion python/tvm/autotvm/tophub.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# pylint: skip-file
"""
TopHub: Tensor Operator Hub
To get the best performance, we typically need auto-tuning for the specific devices.
TVM releases pre-tuned parameters in TopHub for some common networks and hardware targets.
TVM will download these parameters for you when you call relay.build.
"""
# pylint: disable=invalid-name

import logging
from os import getenv
Expand Down
2 changes: 1 addition & 1 deletion python/tvm/contrib/cutlass/gemm_operation.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# pylint: disable=invalid-name, unused-wildcard-import, wildcard-import
# pylint: disable=invalid-name, unused-wildcard-import, wildcard-import, pointless-exception-statement
"""Generator for CUTLASS GEMM kernels."""
from .library import *

Expand Down
2 changes: 1 addition & 1 deletion python/tvm/contrib/debugger/debug_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ def debug_get_output(self, node, out=None):
elif isinstance(node, int):
node_index = node
else:
raise RuntimeError(f"Require node index or name only.")
raise RuntimeError("Require node index or name only.")

self._debug_get_output(node_index, out)

Expand Down
1 change: 1 addition & 0 deletions python/tvm/contrib/debugger/debug_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# pylint: disable=pointless-exception-statement, unnecessary-list-index-lookup
"""Graph debug results dumping class."""
import collections
import json
Expand Down
1 change: 1 addition & 0 deletions python/tvm/contrib/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# pylint: disable=missing-timeout
"""Helper utility for downloading"""

import logging
Expand Down
1 change: 1 addition & 0 deletions python/tvm/contrib/ethosu/cascader/cascader_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# pylint: disable=invalid-name
"""Object to hold options for the NPU cascader"""
import tvm._ffi

Expand Down
1 change: 1 addition & 0 deletions python/tvm/contrib/hexagon/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# pylint: disable=consider-using-with, unnecessary-ellipsis

"""Defines top-level glue functions for building Hexagon."""

Expand Down
1 change: 1 addition & 0 deletions python/tvm/contrib/hexagon/hexagon_profiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# pylint: disable=consider-using-with

"""Define HexagonProfiler class to enable profiling for Hexagon"""

Expand Down
5 changes: 3 additions & 2 deletions python/tvm/contrib/hexagon/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# pylint: disable=consider-using-from-import

"""Defines a Session class for Hexagon devices."""

Expand Down Expand Up @@ -408,8 +409,8 @@ def _aot_executor_from_factory(
)
else:
raise ValueError(
f"Incorrect Target kind.\n"
f"Target kind should be from these options: [hexagon, llvm]."
"Incorrect Target kind.\n"
"Target kind should be from these options: [hexagon, llvm]."
)

remote_file_path = self.upload(binary_path, binary_name)
Expand Down
2 changes: 1 addition & 1 deletion python/tvm/contrib/hexagon/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# pylint: disable=invalid-name
# pylint: disable=invalid-name, f-string-without-interpolation, consider-using-from-import
"""Tools/compilers/linkers for Hexagon"""

import os
Expand Down
1 change: 1 addition & 0 deletions python/tvm/contrib/pipeline_executor_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# pylint: disable=f-string-without-interpolation
"""Pipeline executor that executes a series of modules in a pipeline fashion."""
import json
import os
Expand Down
2 changes: 1 addition & 1 deletion python/tvm/contrib/relay_viz/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ def _tuple_get_item(
node_id = node_to_id[node]

# Tuple -> TupleGetItemNode
viz_node = VizNode(node_id, f"TupleGetItem", f"idx: {node.index}")
viz_node = VizNode(node_id, "TupleGetItem", f"idx: {node.index}")
viz_edges = [VizEdge(node_to_id[node.tuple_value], node_id)]
return viz_node, viz_edges

Expand Down
2 changes: 1 addition & 1 deletion python/tvm/contrib/tedd.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# pylint: disable=import-outside-toplevel
# pylint: disable=import-outside-toplevel, nested-min-max
"""Tensor Expression Debug Display (TEDD), visualizing Tensor Expression"""
import html
import json
Expand Down
4 changes: 2 additions & 2 deletions python/tvm/driver/tvmc/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# pylint: disable=use-a-generator
"""
TVMC - TVM driver command-line interface
"""
Expand Down Expand Up @@ -85,8 +86,7 @@ def _main(argv):
parser.add_argument("-h", "--help", action="help", help="show this help message and exit.")

args = parser.parse_args(argv)
if args.verbose > 3:
args.verbose = 3
args.verbose = min(args.verbose, 3)

# See the meaning of the logging levels at
# https://docs.python.org/3/library/logging.html#logging-levels
Expand Down
1 change: 1 addition & 0 deletions python/tvm/driver/tvmc/micro.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# pylint: disable=consider-using-from-import
"""
Provides support for micro targets (microTVM).
"""
Expand Down
1 change: 1 addition & 0 deletions python/tvm/driver/tvmc/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# pylint: disable=consider-using-with,broad-exception-raised,consider-using-from-import
"""
This file contains the definition of a set of classes that wrap the outputs
of TVMC functions to create a simpler and more intuitive API.
Expand Down
3 changes: 2 additions & 1 deletion python/tvm/driver/tvmc/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# pylint: disable=consider-using-from-import
"""
Provides support to run compiled networks both locally and remotely.
"""
Expand Down Expand Up @@ -178,7 +179,7 @@ def add_run_parser(subparsers, main_parser, json_params):
sys.exit(f"Error: Project API server not found in {project_dir}!")
except TemplateProjectError:
sys.exit(
f"Error: Project directory error. That usually happens when model.tar is not found."
"Error: Project directory error. That usually happens when model.tar is not found."
)

project_info = project_.info()
Expand Down
1 change: 1 addition & 0 deletions python/tvm/ir/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# pylint: disable=invalid-name
"""Function defintiions."""
from enum import IntEnum
import tvm.runtime
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# pylint: disable=invalid-name
"""We extract one feature vector per BufferStoreNode statement in a TIR Stmt,
so we call this feature as "per-store" feature.
"""
Expand Down
1 change: 1 addition & 0 deletions python/tvm/meta_schedule/profiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# pylint: disable=used-before-assignment
"""A context manager that profiles tuning time cost for different parts."""
from contextlib import contextmanager
from typing import Dict, Optional
Expand Down
2 changes: 1 addition & 1 deletion python/tvm/meta_schedule/testing/dataset_extract_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
import glob
import json
import os
from tqdm import tqdm # type: ignore

import tvm
from tqdm import tqdm # type: ignore
from tvm import meta_schedule as ms
from tvm.ir import save_json
from tvm.meta_schedule.testing.relay_workload import _load_cache
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
import os
from typing import List

import tvm
from tqdm import tqdm # type: ignore
import tvm
from tvm import meta_schedule as ms
from tvm.ir import load_json
from tvm.target import Target
Expand Down
1 change: 1 addition & 0 deletions python/tvm/meta_schedule/testing/torchbench/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# pylint: disable=unused-variable
"""
This script is for benchmarking TVM performance on models from TorchBench.
It uses the TorchDynamo as the frontend to ingest models into TVM, and it also
Expand Down
1 change: 1 addition & 0 deletions python/tvm/meta_schedule/testing/torchbench/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# pylint: disable=invalid-name, pointless-exception-statement
"""
Helper functions for running TorchBench through the benchmark functions
from TorchDynamo.
Expand Down
1 change: 1 addition & 0 deletions python/tvm/micro/debugger.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# pylint: disable=consider-using-with

"""Defines functions for controlling debuggers for micro TVM binaries."""

Expand Down
1 change: 1 addition & 0 deletions python/tvm/micro/model_library_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# pylint: disable=cell-var-from-loop, use-list-literal

"""Defines functions for exporting to Model Library Format."""

Expand Down
1 change: 1 addition & 0 deletions python/tvm/micro/project_api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# pylint: disable=consider-using-with
"""
Project API client.
"""
Expand Down
3 changes: 2 additions & 1 deletion python/tvm/micro/project_api/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# pylint: disable=invalid-name

"""Defines a basic Project API server template.
Expand Down Expand Up @@ -475,7 +476,7 @@ def serve_one_request(self):
_LOG.error("EOF")
return False

except Exception as exc: # pylint: disable=broad-except
except Exception: # pylint: disable=broad-except
_LOG.error("Caught error reading request", exc_info=1)
return False

Expand Down
3 changes: 2 additions & 1 deletion python/tvm/relay/backend/contrib/ethosu/legalize.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# pylint: disable=invalid-name, unused-argument, import-outside-toplevel, no-value-for-parameter
# pylint: disable=invalid-name, unused-argument, import-outside-toplevel
# pylint: disable=no-value-for-parameter, use-list-literal
"""A set of passes to legalize some of operations for the NPU"""
from typing import List, Type, Callable
import math
Expand Down
2 changes: 1 addition & 1 deletion python/tvm/relay/backend/contrib/ethosu/te/depthwise.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def depthwise_conv2d_compute(
The OFM tensor.
"""
assert ifm.shape[0] == 1, f"Only batch size 1 is supported"
assert ifm.shape[0] == 1, "Only batch size 1 is supported"
assert ifm_layout in {"NHWC", "NHCWB16"}
assert ofm_layout in {"NHWC", "NHCWB16"}

Expand Down
2 changes: 1 addition & 1 deletion python/tvm/relay/backend/contrib/ethosu/tir/convolution.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
# pylint: disable=invalid-name, unused-argument
"""Extract parameters from the convolution operators in TIR."""
import math
import tvm
from ethosu.vela import api as vapi
import tvm
from ..vela_api import SCALE_BIAS_LENGTH, get_accelerator_config
from .utils import get_outer_loops, get_op_attrs, get_base_address, get_loads, get_stores
from .dma import get_ifm_params, get_ofm_params
Expand Down
Loading

0 comments on commit dc9c02d

Please sign in to comment.