This is an automated email from the ASF dual-hosted git repository.
spectrometerHBH pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm.git
The following commit(s) were added to refs/heads/main by this push:
new ffea531107 [REFACTOR][PYTHON] Lift compiler/CLI/process modules from
tvm.contrib to tvm.support (#19624)
ffea531107 is described below
commit ffea531107a40ac5264f343906cc6605ac3cd365
Author: Tianqi Chen <[email protected]>
AuthorDate: Wed May 27 15:31:12 2026 -0400
[REFACTOR][PYTHON] Lift compiler/CLI/process modules from tvm.contrib to
tvm.support (#19624)
## Summary
Lifts 10 host-toolchain / CLI / process / utility modules from
`python/tvm/contrib/` to a new `python/tvm/support/` package, and
deletes two dead contrib shims.
`tvm.support` is the home for Python helpers that integrate TVM with
external CLIs and host-side tools — compilers, archivers, subprocess
pools, and build-info queries. These are load-bearing internal pieces
that TVM's compile/link/run paths depend on. `tvm.contrib` is reserved
for optional vendor SDK integrations and experimental features. The
distinction is documented in the `tvm.support` package docstring.
Moved (one commit each):
- `tvm.contrib.cc` → `tvm.support.cc`
- `tvm.contrib.nvcc` → `tvm.support.nvcc`
- `tvm.contrib.rocm` → `tvm.support.rocm`
- `tvm.contrib.ndk` → `tvm.support.ndk`
- `tvm.contrib.xcode` → `tvm.support.xcode`
- `tvm.contrib.clang` → `tvm.support.clang`
- `tvm.contrib.emcc` → `tvm.support.emcc`
- `tvm.contrib.popen_pool` → `tvm.support.popen_pool`
- `tvm.contrib.utils` → `tvm.support.utils`
- `tvm.contrib.tar` → `tvm.support.tar`
Deleted:
- `tvm.contrib.spirv` — single `optimize()` wrapping `spirv-opt`; zero
importers.
- `tvm.contrib.rpc` — self-deprecation shim with "removed in 0.5"
banner; honoring it.
Package conversion:
- `python/tvm/support.py` → `python/tvm/support/__init__.py` with
inclusion-rule docstring.
- `libinfo()` extracted into `python/tvm/support/libinfo.py`.
- `FrontendTestModule` dropped (audit confirmed zero callers outside its
own definition).
## Compatibility
Hard break — no `tvm.contrib.<mod>` re-export shims. All callers updated
in this PR.
C++-side FFI registry keys (`tvm.contrib.nvcc.*`, etc.) are unchanged —
only the Python module path moves. Renaming the FFI keys is a separate
follow-up.
---
apps/android_rpc/tests/android_rpc_test.py | 2 +-
apps/ios_rpc/tests/ios_rpc_test.py | 2 +-
docs/how_to/tutorials/cross_compilation_and_rpc.py | 2 +-
docs/reference/api/python/contrib.rst | 66 -------------
docs/reference/api/python/support.rst | 50 ++++++++++
python/tvm/__init__.py | 4 +-
python/tvm/contrib/cutlass/build.py | 2 +-
python/tvm/contrib/hexagon/hexagon_profiler.py | 2 +-
python/tvm/contrib/hexagon/meta_schedule.py | 2 +-
python/tvm/contrib/hexagon/session.py | 2 +-
python/tvm/contrib/hexagon/tools.py | 2 +-
python/tvm/contrib/rpc.py | 28 ------
python/tvm/contrib/spirv.py | 59 ------------
python/tvm/contrib/tvmjs.py | 3 +-
python/tvm/exec/popen_worker.py | 2 +-
python/tvm/relax/backend/cuda/flashinfer.py | 2 +-
python/tvm/relax/backend/metal/coreml.py | 2 +-
python/tvm/relax/frontend/nn/extern.py | 2 +-
python/tvm/rpc/client.py | 2 +-
python/tvm/rpc/minrpc.py | 2 +-
python/tvm/rpc/proxy.py | 2 +-
python/tvm/rpc/server.py | 10 +-
python/tvm/rpc/tracker.py | 2 +-
python/tvm/runtime/executable.py | 2 +-
python/tvm/runtime/module.py | 14 +--
.../s_tir/meta_schedule/builder/local_builder.py | 4 +-
.../s_tir/meta_schedule/cost_model/mlp_model.py | 2 +-
.../s_tir/meta_schedule/cost_model/xgb_model.py | 3 +-
.../tvm/s_tir/meta_schedule/runner/local_runner.py | 2 +-
.../tvm/s_tir/meta_schedule/runner/rpc_runner.py | 2 +-
.../meta_schedule/testing/custom_builder_runner.py | 2 +-
python/tvm/support.py | 102 ---------------------
python/tvm/support/__init__.py | 54 +++++++++++
python/tvm/{contrib => support}/cc.py | 2 +-
python/tvm/{contrib => support}/clang.py | 0
python/tvm/{contrib => support}/emcc.py | 0
python/tvm/support/libinfo.py | 45 +++++++++
python/tvm/{contrib => support}/ndk.py | 0
python/tvm/{contrib => support}/nvcc.py | 0
python/tvm/{contrib => support}/popen_pool.py | 0
python/tvm/{contrib => support}/rocm.py | 0
python/tvm/{contrib => support}/tar.py | 2 +-
python/tvm/{contrib => support}/utils.py | 0
python/tvm/{contrib => support}/xcode.py | 0
python/tvm/testing/runner.py | 2 +-
python/tvm/testing/utils.py | 13 +--
python/tvm/tirx/bench.py | 2 +-
python/tvm/tirx/operator/intrinsics/cuda/header.py | 2 +-
python/tvm/tirx/script/builder/external_kernel.py | 2 +-
.../test_minimal_target_codegen_llvm.py | 2 +-
tests/python/codegen/test_gpu_codegen_allreduce.py | 2 +-
tests/python/codegen/test_inject_ptx_ldg32.py | 4 +-
tests/python/codegen/test_target_codegen_blob.py | 2 +-
tests/python/codegen/test_target_codegen_c_host.py | 2 +-
.../codegen/test_target_codegen_cross_llvm.py | 2 +-
tests/python/codegen/test_target_codegen_cuda.py | 10 +-
.../codegen/test_target_codegen_cuda_fastmath.py | 2 +-
tests/python/codegen/test_target_codegen_llvm.py | 2 +-
tests/python/codegen/test_target_codegen_metal.py | 2 +-
tests/python/contrib/test_ccache.py | 2 +-
tests/python/contrib/test_coreml_runtime.py | 3 +-
tests/python/contrib/test_popen_pool.py | 2 +-
tests/python/contrib/test_util.py | 2 +-
tests/python/nightly/test_nnapi/infrastructure.py | 2 +-
tests/python/relax/backend/adreno/utils.py | 2 +-
tests/python/relax/test_codegen_coreml.py | 4 +-
tests/python/relax/test_runtime_builtin.py | 3 +-
.../relax/test_runtime_sampling_flashinfer.py | 2 +-
tests/python/relax/test_transform_codegen_pass.py | 2 +-
tests/python/relax/test_vm_build.py | 2 +-
tests/python/relax/test_vm_codegen_only.py | 2 +-
tests/python/relax/texture/test_texture_nd.py | 2 +-
tests/python/runtime/test_runtime_measure.py | 2 +-
tests/python/runtime/test_runtime_module_export.py | 2 +-
tests/python/runtime/test_runtime_module_load.py | 2 +-
tests/python/runtime/test_runtime_rpc.py | 2 +-
.../test_s_tir_transform_inject_ptx_async_copy.py | 4 +-
tests/python/target/test_arm_target.py | 2 +-
tests/python/tirx-base/test_tir_intrin.py | 2 +-
tests/python/tirx/codegen/test_codegen_nvshmem.py | 2 +-
web/tests/python/relax_rpc_test.py | 3 +-
web/tests/python/webgpu_rpc_test.py | 3 +-
82 files changed, 246 insertions(+), 347 deletions(-)
diff --git a/apps/android_rpc/tests/android_rpc_test.py
b/apps/android_rpc/tests/android_rpc_test.py
index d1c27e23c8..79a69a2780 100644
--- a/apps/android_rpc/tests/android_rpc_test.py
+++ b/apps/android_rpc/tests/android_rpc_test.py
@@ -28,7 +28,7 @@ import numpy as np
import tvm
from tvm import rpc, te
-from tvm.contrib import ndk, utils
+from tvm.support import ndk, utils
# Set to be address of tvm proxy.
tracker_host = os.environ["TVM_TRACKER_HOST"]
diff --git a/apps/ios_rpc/tests/ios_rpc_test.py
b/apps/ios_rpc/tests/ios_rpc_test.py
index b29694bbd0..43a5b2db2c 100644
--- a/apps/ios_rpc/tests/ios_rpc_test.py
+++ b/apps/ios_rpc/tests/ios_rpc_test.py
@@ -26,7 +26,7 @@ import numpy as np
import tvm
from tvm import rpc, te
-from tvm.contrib import utils, xcode
+from tvm.support import utils, xcode
# Change target configuration, this is setting for iphone6s
arch = "arm64"
diff --git a/docs/how_to/tutorials/cross_compilation_and_rpc.py
b/docs/how_to/tutorials/cross_compilation_and_rpc.py
index 1adc8be99c..3a725791a2 100644
--- a/docs/how_to/tutorials/cross_compilation_and_rpc.py
+++ b/docs/how_to/tutorials/cross_compilation_and_rpc.py
@@ -100,7 +100,7 @@ import tvm_ffi
import tvm
from tvm import rpc, te
-from tvm.contrib import utils
+from tvm.support import utils
n = tvm.runtime.convert(1024)
A = te.placeholder((n,), name="A")
diff --git a/docs/reference/api/python/contrib.rst
b/docs/reference/api/python/contrib.rst
index 7182e73865..c2bcc939a8 100644
--- a/docs/reference/api/python/contrib.rst
+++ b/docs/reference/api/python/contrib.rst
@@ -25,18 +25,6 @@ tvm.contrib.cblas
:members:
-tvm.contrib.clang
-~~~~~~~~~~~~~~~~~
-.. automodule:: tvm.contrib.clang
- :members:
-
-
-tvm.contrib.cc
-~~~~~~~~~~~~~~
-.. automodule:: tvm.contrib.cc
- :members:
-
-
tvm.contrib.coreml_runtime
~~~~~~~~~~~~~~~~~~~~~~~~~~
.. automodule:: tvm.contrib.coreml_runtime
@@ -79,12 +67,6 @@ tvm.contrib.download
:members:
-tvm.contrib.emcc
-~~~~~~~~~~~~~~~~
-.. automodule:: tvm.contrib.emcc
- :members:
-
-
tvm.contrib.hipblas
~~~~~~~~~~~~~~~~~~~
.. automodule:: tvm.contrib.hipblas
@@ -97,60 +79,24 @@ tvm.contrib.mkl
:members:
-tvm.contrib.ndk
-~~~~~~~~~~~~~~~
-.. automodule:: tvm.contrib.ndk
- :members:
-
-
tvm.contrib.nnpack
~~~~~~~~~~~~~~~~~~
.. automodule:: tvm.contrib.nnpack
:members:
-tvm.contrib.nvcc
-~~~~~~~~~~~~~~~~
-.. automodule:: tvm.contrib.nvcc
- :members:
-
-
tvm.contrib.pickle_memoize
~~~~~~~~~~~~~~~~~~~~~~~~~~
.. automodule:: tvm.contrib.pickle_memoize
:members:
-tvm.contrib.popen_pool
-~~~~~~~~~~~~~~~~~~~~~~
-.. automodule:: tvm.contrib.popen_pool
- :members:
-
-
tvm.contrib.random
~~~~~~~~~~~~~~~~~~
.. automodule:: tvm.contrib.random
:members:
-tvm.contrib.rocm
-~~~~~~~~~~~~~~~~
-.. automodule:: tvm.contrib.rocm
- :members:
-
-
-tvm.contrib.spirv
-~~~~~~~~~~~~~~~~~
-.. automodule:: tvm.contrib.spirv
- :members:
-
-
-tvm.contrib.tar
-~~~~~~~~~~~~~~~~
-.. automodule:: tvm.contrib.tar
- :members:
-
-
tvm.contrib.thrust
~~~~~~~~~~~~~~~~~~
.. automodule:: tvm.contrib.thrust
@@ -163,18 +109,6 @@ tvm.contrib.tvmjs
:members:
-tvm.contrib.utils
-~~~~~~~~~~~~~~~~~
-.. automodule:: tvm.contrib.utils
- :members:
-
-
-tvm.contrib.xcode
-~~~~~~~~~~~~~~~~~
-.. automodule:: tvm.contrib.xcode
- :members:
-
-
tvm.contrib.cutlass
~~~~~~~~~~~~~~~~~~~
.. automodule:: tvm.contrib.cutlass
diff --git a/docs/reference/api/python/support.rst
b/docs/reference/api/python/support.rst
index 12511284e7..4663acd2aa 100644
--- a/docs/reference/api/python/support.rst
+++ b/docs/reference/api/python/support.rst
@@ -21,3 +21,53 @@ tvm.support
:members:
:imported-members:
:autosummary:
+
+tvm.support.cc
+~~~~~~~~~~~~~~
+.. automodule:: tvm.support.cc
+ :members:
+
+tvm.support.nvcc
+~~~~~~~~~~~~~~~~
+.. automodule:: tvm.support.nvcc
+ :members:
+
+tvm.support.rocm
+~~~~~~~~~~~~~~~~
+.. automodule:: tvm.support.rocm
+ :members:
+
+tvm.support.ndk
+~~~~~~~~~~~~~~~
+.. automodule:: tvm.support.ndk
+ :members:
+
+tvm.support.xcode
+~~~~~~~~~~~~~~~~~
+.. automodule:: tvm.support.xcode
+ :members:
+
+tvm.support.clang
+~~~~~~~~~~~~~~~~~
+.. automodule:: tvm.support.clang
+ :members:
+
+tvm.support.emcc
+~~~~~~~~~~~~~~~~
+.. automodule:: tvm.support.emcc
+ :members:
+
+tvm.support.popen_pool
+~~~~~~~~~~~~~~~~~~~~~~
+.. automodule:: tvm.support.popen_pool
+ :members:
+
+tvm.support.utils
+~~~~~~~~~~~~~~~~~
+.. automodule:: tvm.support.utils
+ :members:
+
+tvm.support.tar
+~~~~~~~~~~~~~~~
+.. automodule:: tvm.support.tar
+ :members:
diff --git a/python/tvm/__init__.py b/python/tvm/__init__.py
index ef59f3c2aa..e49e9fa0a4 100644
--- a/python/tvm/__init__.py
+++ b/python/tvm/__init__.py
@@ -66,8 +66,8 @@ from . import arith
# support infra
from . import support
-# Contrib initializers
-from .contrib import rocm as _rocm, nvcc as _nvcc
+# Side-effect imports: register CUDA/ROCm FFI callbacks at TVM startup
+from .support import rocm as _rocm, nvcc as _nvcc
# Relax contain modules that are only available in compiler package
# Do not import them if TVM is built with runtime only
diff --git a/python/tvm/contrib/cutlass/build.py
b/python/tvm/contrib/cutlass/build.py
index ce9a46ba70..4ff3f0812a 100644
--- a/python/tvm/contrib/cutlass/build.py
+++ b/python/tvm/contrib/cutlass/build.py
@@ -30,7 +30,7 @@ from tvm_ffi import register_global_func
import tvm
from tvm import relax, runtime
-from tvm.contrib.nvcc import get_cuda_version
+from tvm.support.nvcc import get_cuda_version
from tvm.topi.utils import get_const_tuple
from .gen_conv2d import CutlassConv2DProfiler
diff --git a/python/tvm/contrib/hexagon/hexagon_profiler.py
b/python/tvm/contrib/hexagon/hexagon_profiler.py
index aaec36688e..44a66ef7be 100644
--- a/python/tvm/contrib/hexagon/hexagon_profiler.py
+++ b/python/tvm/contrib/hexagon/hexagon_profiler.py
@@ -22,9 +22,9 @@
import os
import subprocess
-from tvm.contrib import utils
from tvm.contrib.hexagon.profiling.process_lwp_data import process_lwp_output
from tvm.ir.transform import PassContext
+from tvm.support import utils
class HexagonProfiler:
diff --git a/python/tvm/contrib/hexagon/meta_schedule.py
b/python/tvm/contrib/hexagon/meta_schedule.py
index 2a52fc5460..5582f69746 100644
--- a/python/tvm/contrib/hexagon/meta_schedule.py
+++ b/python/tvm/contrib/hexagon/meta_schedule.py
@@ -21,7 +21,6 @@ import tempfile
from collections.abc import Callable
import tvm
-from tvm.contrib.popen_pool import PopenPoolExecutor
from tvm.driver import build as tvm_build
from tvm.ir.module import IRModule
from tvm.runtime import Module, Tensor
@@ -39,6 +38,7 @@ from tvm.s_tir.meta_schedule.runner.rpc_runner import (
)
from tvm.s_tir.meta_schedule.utils import cpu_count, derived_object
from tvm.s_tir.transform import RemoveWeightLayoutRewriteBlock
+from tvm.support.popen_pool import PopenPoolExecutor
from tvm.target import Target
from .build import HexagonLauncherRPC
diff --git a/python/tvm/contrib/hexagon/session.py
b/python/tvm/contrib/hexagon/session.py
index 4769d3aba1..9f9d7d746c 100644
--- a/python/tvm/contrib/hexagon/session.py
+++ b/python/tvm/contrib/hexagon/session.py
@@ -26,7 +26,7 @@ import tvm
import tvm.contrib.hexagon as hexagon
from tvm import rpc as _rpc
from tvm import runtime
-from tvm.contrib import utils
+from tvm.support import utils
from .tools import HEXAGON_SIMULATOR_NAME, export_module
diff --git a/python/tvm/contrib/hexagon/tools.py
b/python/tvm/contrib/hexagon/tools.py
index 632149391f..85c456014b 100644
--- a/python/tvm/contrib/hexagon/tools.py
+++ b/python/tvm/contrib/hexagon/tools.py
@@ -31,7 +31,7 @@ import numpy
from tvm_ffi import register_global_func
import tvm
-import tvm.contrib.cc as cc
+import tvm.support.cc as cc
# Linking Hexagon shared libraries.
#
diff --git a/python/tvm/contrib/rpc.py b/python/tvm/contrib/rpc.py
deleted file mode 100644
index 882a76b568..0000000000
--- a/python/tvm/contrib/rpc.py
+++ /dev/null
@@ -1,28 +0,0 @@
-# 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.
-# ruff: noqa: F401
-"""Deprecation RPC module"""
-
-# pylint: disable=unused-import
-import warnings
-
-from ..rpc import LocalSession, RPCSession, Server, TrackerSession, connect,
connect_tracker
-
-warnings.warn(
- "Please use tvm.rpc instead of tvm.conrtib.rpc. tvm.contrib.rpc is going
to be removed in 0.5",
- DeprecationWarning,
-)
diff --git a/python/tvm/contrib/spirv.py b/python/tvm/contrib/spirv.py
deleted file mode 100644
index bbcf0ea39e..0000000000
--- a/python/tvm/contrib/spirv.py
+++ /dev/null
@@ -1,59 +0,0 @@
-# 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.
-"""Utility for Interacting with SPIRV Tools"""
-
-import os
-import subprocess
-
-from ..base import py_str
-from . import utils
-
-
-def optimize(spv_bin):
- """Optimize SPIRV using spirv-opt via CLI
-
- Note that the spirv-opt is still experimental.
-
- Parameters
- ----------
- spv_bin : bytearray
- The spirv file
-
- Return
- ------
- cobj_bin : bytearray
- The HSA Code Object
- """
-
- tmp_dir = utils.tempdir()
- tmp_in = tmp_dir.relpath("input.spv")
- tmp_out = tmp_dir.relpath("output.spv")
- with open(tmp_in, "wb") as out_file:
- out_file.write(bytes(spv_bin))
-
- sdk = os.environ.get("VULKAN_SDK", None)
- cmd = os.path.join(sdk, "bin/spirv-opt") if sdk else "spirv-opt"
- args = [cmd, "-O", tmp_in, "-o", tmp_out]
- proc = subprocess.Popen(args, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
- (out, _) = proc.communicate()
-
- if proc.returncode != 0:
- msg = "Opitmizationerror using spirv-opt:\n"
- msg += py_str(out)
- raise RuntimeError(msg)
-
- return bytearray(open(tmp_out, "rb").read())
diff --git a/python/tvm/contrib/tvmjs.py b/python/tvm/contrib/tvmjs.py
index 084af45d2d..46cda68106 100644
--- a/python/tvm/contrib/tvmjs.py
+++ b/python/tvm/contrib/tvmjs.py
@@ -39,8 +39,7 @@ except ImportError:
import tvm
from tvm.libinfo import find_lib_path
from tvm.runtime import DataType
-
-from .emcc import create_tvmjs_wasm
+from tvm.support.emcc import create_tvmjs_wasm
def _convert_f32_to_bf16(value):
diff --git a/python/tvm/exec/popen_worker.py b/python/tvm/exec/popen_worker.py
index 5d63abd466..ddaa16b76d 100644
--- a/python/tvm/exec/popen_worker.py
+++ b/python/tvm/exec/popen_worker.py
@@ -44,7 +44,7 @@ import traceback
import cloudpickle
-from tvm.contrib.popen_pool import StatusKind
+from tvm.support.popen_pool import StatusKind
class TimeoutStatus:
diff --git a/python/tvm/relax/backend/cuda/flashinfer.py
b/python/tvm/relax/backend/cuda/flashinfer.py
index a6e1fd9954..b3ff3bfc21 100644
--- a/python/tvm/relax/backend/cuda/flashinfer.py
+++ b/python/tvm/relax/backend/cuda/flashinfer.py
@@ -334,7 +334,7 @@ def gen_grouped_gemm_module(
"in https://docs.flashinfer.ai to install FlashInfer."
)
- compute_version =
"".join(tvm.contrib.nvcc.get_target_compute_version(target).split("."))
+ compute_version =
"".join(tvm.support.nvcc.get_target_compute_version(target).split("."))
if compute_version == "100":
jit_spec = gen_gemm_sm100_module()
else:
diff --git a/python/tvm/relax/backend/metal/coreml.py
b/python/tvm/relax/backend/metal/coreml.py
index 598ffa5308..7dd8ea3958 100644
--- a/python/tvm/relax/backend/metal/coreml.py
+++ b/python/tvm/relax/backend/metal/coreml.py
@@ -24,7 +24,6 @@ import tvm_ffi
import tvm
from tvm.contrib import coreml_runtime
-from tvm.contrib.xcode import compile_coreml
from tvm.relax import transform
from tvm.relax.dpl.pattern import is_op, wildcard
from tvm.relax.expr import (
@@ -39,6 +38,7 @@ from tvm.relax.expr import (
)
from tvm.relax.struct_info import PrimStructInfo, TensorStructInfo
from tvm.relax.transform import PatternCheckContext
+from tvm.support.xcode import compile_coreml
from ...expr_functor import PyExprVisitor, visitor
from ..pattern_registry import get_patterns_with_prefix, register_patterns
diff --git a/python/tvm/relax/frontend/nn/extern.py
b/python/tvm/relax/frontend/nn/extern.py
index f442d491dc..e424554367 100644
--- a/python/tvm/relax/frontend/nn/extern.py
+++ b/python/tvm/relax/frontend/nn/extern.py
@@ -25,8 +25,8 @@ from collections.abc import Callable
from pathlib import Path
from tvm import tirx
-from tvm.contrib import cc as _cc
from tvm.runtime import Module, load_static_library
+from tvm.support import cc as _cc
from ...op import call_dps_packed
from . import core
diff --git a/python/tvm/rpc/client.py b/python/tvm/rpc/client.py
index dce5861959..57ef8f1842 100644
--- a/python/tvm/rpc/client.py
+++ b/python/tvm/rpc/client.py
@@ -29,7 +29,7 @@ from tvm_ffi import DLDeviceType
import tvm.runtime
from tvm.base import TVMError
-from tvm.contrib import utils
+from tvm.support import utils
from . import _ffi_api, base, server
diff --git a/python/tvm/rpc/minrpc.py b/python/tvm/rpc/minrpc.py
index 58d2954937..73a804d592 100644
--- a/python/tvm/rpc/minrpc.py
+++ b/python/tvm/rpc/minrpc.py
@@ -21,7 +21,7 @@ import os
import tvm_ffi
from tvm import libinfo
-from tvm.contrib import cc
+from tvm.support import cc
def find_minrpc_server_libpath(server="posix_popen_server"):
diff --git a/python/tvm/rpc/proxy.py b/python/tvm/rpc/proxy.py
index 12a1542b77..bfaea7c69c 100644
--- a/python/tvm/rpc/proxy.py
+++ b/python/tvm/rpc/proxy.py
@@ -43,7 +43,7 @@ except ImportError as error_msg:
f"RPCProxy module requires tornado package {error_msg}. Try 'pip
install tornado'."
)
-from tvm.contrib.popen_pool import PopenWorker
+from tvm.support.popen_pool import PopenWorker
from ..base import py_str
from . import _ffi_api, base
diff --git a/python/tvm/rpc/server.py b/python/tvm/rpc/server.py
index 64381acf22..099cb8f1f1 100644
--- a/python/tvm/rpc/server.py
+++ b/python/tvm/rpc/server.py
@@ -42,10 +42,10 @@ import time
import tvm_ffi
from tvm.base import py_str
-from tvm.contrib import utils
-from tvm.contrib.popen_pool import PopenWorker
from tvm.libinfo import find_lib_path
from tvm.runtime.module import load_module as _load_module
+from tvm.support import utils
+from tvm.support.popen_pool import PopenWorker
# pylint: disable=unused-import
from . import _ffi_api, base, testing
@@ -91,14 +91,14 @@ def _server_env(load_library, work_path=None):
if path.endswith(".o"):
# Extra dependencies during runtime.
- from tvm.contrib import cc as _cc
+ from tvm.support import cc as _cc
_cc.create_shared(path + ".so", path)
path += ".so"
elif path.endswith(".tar"):
# Extra dependencies during runtime.
- from tvm.contrib import cc as _cc
- from tvm.contrib import tar as _tar
+ from tvm.support import cc as _cc
+ from tvm.support import tar as _tar
tar_temp = utils.tempdir(custom_path=path.replace(".tar", ""))
_tar.untar(path, tar_temp.temp_dir)
diff --git a/python/tvm/rpc/tracker.py b/python/tvm/rpc/tracker.py
index 1af2a26985..07e0a4302b 100644
--- a/python/tvm/rpc/tracker.py
+++ b/python/tvm/rpc/tracker.py
@@ -51,7 +51,7 @@ import struct
import sys
import threading
-from tvm.contrib.popen_pool import PopenWorker
+from tvm.support.popen_pool import PopenWorker
try:
from tornado import ioloop
diff --git a/python/tvm/runtime/executable.py b/python/tvm/runtime/executable.py
index 660756fa2b..39120a89fe 100644
--- a/python/tvm/runtime/executable.py
+++ b/python/tvm/runtime/executable.py
@@ -24,7 +24,7 @@ from typing import Any
from tvm_ffi import Function
import tvm
-from tvm.contrib import utils as _utils
+from tvm.support import utils as _utils
from . import Module
diff --git a/python/tvm/runtime/module.py b/python/tvm/runtime/module.py
index df78faa596..8ecda773b9 100644
--- a/python/tvm/runtime/module.py
+++ b/python/tvm/runtime/module.py
@@ -212,10 +212,10 @@ class Module(_Module):
# Extra dependencies during runtime.
from pathlib import Path
- from tvm.contrib import cc as _cc
- from tvm.contrib import tar as _tar
from tvm.contrib import tvmjs as _tvmjs
- from tvm.contrib import utils as _utils
+ from tvm.support import cc as _cc
+ from tvm.support import tar as _tar
+ from tvm.support import utils as _utils
if isinstance(file_name, Path):
file_name = str(file_name)
@@ -442,15 +442,15 @@ def load_module(path):
# We support this to be consistent with RPC module load.
if path.endswith(".o"):
# Extra dependencies during runtime.
- from tvm.contrib import cc as _cc
+ from tvm.support import cc as _cc
_cc.create_shared(path + ".so", path)
path += ".so"
elif path.endswith(".tar"):
# Extra dependencies during runtime.
- from tvm.contrib import cc as _cc
- from tvm.contrib import tar as _tar
- from tvm.contrib import utils as _utils
+ from tvm.support import cc as _cc
+ from tvm.support import tar as _tar
+ from tvm.support import utils as _utils
tar_temp = _utils.tempdir(custom_path=path.replace(".tar", ""))
_tar.untar(path, tar_temp.temp_dir)
diff --git a/python/tvm/s_tir/meta_schedule/builder/local_builder.py
b/python/tvm/s_tir/meta_schedule/builder/local_builder.py
index 8197f4a01a..2a88c0167b 100644
--- a/python/tvm/s_tir/meta_schedule/builder/local_builder.py
+++ b/python/tvm/s_tir/meta_schedule/builder/local_builder.py
@@ -26,9 +26,9 @@ from tvm_ffi import register_global_func
from tvm.ir import IRModule
from tvm.runtime import Module, Tensor, load_param_dict, save_param_dict
+from tvm.support.popen_pool import MapResult, PopenPoolExecutor, StatusKind
from tvm.target import Target
-from ....contrib.popen_pool import MapResult, PopenPoolExecutor, StatusKind
from ..logging import get_logger
from ..utils import cpu_count, derived_object,
get_global_func_with_default_on_worker
from .builder import BuilderInput, BuilderResult, PyBuilder
@@ -280,7 +280,7 @@ def default_export(mod: Module) -> str:
artifact_path : str
The path to the exported Module.
"""
- from tvm.contrib.tar import tar # pylint: disable=import-outside-toplevel
+ from tvm.support.tar import tar # pylint: disable=import-outside-toplevel
artifact_path = os.path.join(tempfile.mkdtemp(), "tvm_tmp_mod." +
tar.output_format)
mod.export_library(artifact_path, fcompile=tar)
diff --git a/python/tvm/s_tir/meta_schedule/cost_model/mlp_model.py
b/python/tvm/s_tir/meta_schedule/cost_model/mlp_model.py
index 0feb5af5eb..162110371f 100644
--- a/python/tvm/s_tir/meta_schedule/cost_model/mlp_model.py
+++ b/python/tvm/s_tir/meta_schedule/cost_model/mlp_model.py
@@ -32,8 +32,8 @@ import numpy as np # type: ignore
import torch # type: ignore
import tvm
+from tvm.support.tar import tar, untar
-from ....contrib.tar import tar, untar
from ....runtime import Tensor
from ....target import Target
from ..cost_model import PyCostModel
diff --git a/python/tvm/s_tir/meta_schedule/cost_model/xgb_model.py
b/python/tvm/s_tir/meta_schedule/cost_model/xgb_model.py
index 2bb29eb8cd..3bc0b4d769 100644
--- a/python/tvm/s_tir/meta_schedule/cost_model/xgb_model.py
+++ b/python/tvm/s_tir/meta_schedule/cost_model/xgb_model.py
@@ -25,7 +25,8 @@ from typing import TYPE_CHECKING, Any, Literal, NamedTuple,
Optional
import numpy as np # type: ignore
-from ....contrib.tar import tar, untar
+from tvm.support.tar import tar, untar
+
from ....runtime import Tensor
from ..cost_model import PyCostModel
from ..feature_extractor import FeatureExtractor
diff --git a/python/tvm/s_tir/meta_schedule/runner/local_runner.py
b/python/tvm/s_tir/meta_schedule/runner/local_runner.py
index 2e73f6b695..c55925fd0b 100644
--- a/python/tvm/s_tir/meta_schedule/runner/local_runner.py
+++ b/python/tvm/s_tir/meta_schedule/runner/local_runner.py
@@ -22,8 +22,8 @@ from collections.abc import Callable
from contextlib import contextmanager
import tvm
+from tvm.support.popen_pool import PopenPoolExecutor
-from ....contrib.popen_pool import PopenPoolExecutor
from ....runtime import Device, Module
from ..logging import get_logger
from ..profiler import Profiler
diff --git a/python/tvm/s_tir/meta_schedule/runner/rpc_runner.py
b/python/tvm/s_tir/meta_schedule/runner/rpc_runner.py
index ebfdd57715..435cfd8b4d 100644
--- a/python/tvm/s_tir/meta_schedule/runner/rpc_runner.py
+++ b/python/tvm/s_tir/meta_schedule/runner/rpc_runner.py
@@ -21,9 +21,9 @@ import os.path as osp
from collections.abc import Callable
from contextlib import contextmanager
-from tvm.contrib.popen_pool import PopenPoolExecutor
from tvm.rpc import RPCSession
from tvm.runtime import Device, Module
+from tvm.support.popen_pool import PopenPoolExecutor
from ..logging import get_logger
from ..profiler import Profiler
diff --git a/python/tvm/s_tir/meta_schedule/testing/custom_builder_runner.py
b/python/tvm/s_tir/meta_schedule/testing/custom_builder_runner.py
index ef193b338b..74c7a6c307 100644
--- a/python/tvm/s_tir/meta_schedule/testing/custom_builder_runner.py
+++ b/python/tvm/s_tir/meta_schedule/testing/custom_builder_runner.py
@@ -37,8 +37,8 @@ def run_module_via_rpc(
import os
import tempfile
- from tvm.contrib.tar import tar
from tvm.runtime import ndarray
+ from tvm.support.tar import tar
# pylint: enable=import-outside-toplevel
diff --git a/python/tvm/support.py b/python/tvm/support.py
deleted file mode 100644
index 021c32b075..0000000000
--- a/python/tvm/support.py
+++ /dev/null
@@ -1,102 +0,0 @@
-# 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.
-"""Support infra of TVM."""
-
-import ctypes
-import json
-import os
-import sys
-import textwrap
-
-import tvm_ffi
-
-import tvm
-
-from . import get_global_func
-from .runtime.module import Module
-
-tvm_ffi.init_ffi_api("support", __name__)
-
-
-def libinfo():
- """Returns a dictionary of compile-time info — minimal Python fallback.
-
- The native ``support.GetLibInfo`` global function is no longer registered
- after the upstream sync, so we synthesize the values from build-time hints
- instead.
- """
- import os
-
- return {
- "USE_CUDA": os.environ.get("TVM_USE_CUDA", "ON"),
- "USE_LLVM": os.environ.get("TVM_USE_LLVM", "ON"),
- "USE_NCCL": os.environ.get("TVM_USE_NCCL", "ON"),
- "USE_NVTX": os.environ.get("TVM_USE_NVTX", "ON"),
- "USE_NVSHMEM": os.environ.get("TVM_USE_NVSHMEM", "OFF"),
- "USE_HEXAGON": "OFF",
- "USE_CUDNN": "OFF",
- "USE_CUTLASS": "OFF",
- "USE_VULKAN": "OFF",
- "USE_OPENCL": "OFF",
- "USE_METAL": "OFF",
- "USE_ROCM": "OFF",
- "USE_CLML": "OFF",
- "USE_NNAPI_RUNTIME": "OFF",
- "USE_NNAPI_CODEGEN": "OFF",
- }
-
-
-def describe():
- """
- Print out information about TVM and the current Python environment
- """
- info = list((k, v) for k, v in libinfo().items())
- info = dict(sorted(info, key=lambda x: x[0]))
- print("Python Environment")
- sys_version = sys.version.replace("\n", " ")
- uname = os.uname()
- uname = f"{uname.sysname} {uname.release} {uname.version} {uname.machine}"
- lines = [
- f"TVM version = {tvm.__version__}",
- f"Python version = {sys_version} ({sys.maxsize.bit_length() + 1} bit)",
- f"os.uname() = {uname}",
- ]
- print(textwrap.indent("\n".join(lines), prefix=" "))
- print("CMake Options:")
- print(textwrap.indent(json.dumps(info, indent=2), prefix=" "))
-
-
-class FrontendTestModule(Module):
- """A tvm.runtime.Module whose member functions are PackedFunc."""
-
- def __init__(self, entry_name=None):
- underlying_mod = get_global_func("testing.FrontendTestModule")()
- handle = underlying_mod.handle
-
- # Set handle to NULL to avoid cleanup in c++ runtime, transferring
ownership.
- # Both cython and ctypes FFI use c_void_p, so this is safe to assign
here.
- underlying_mod.handle = ctypes.c_void_p(0)
-
- super().__init__(handle)
- if entry_name is not None:
- self.entry_name = entry_name
-
- def add_function(self, name, func):
- self.get_function("__add_function")(name, func)
-
- def __setitem__(self, key, value):
- self.add_function(key, value)
diff --git a/python/tvm/support/__init__.py b/python/tvm/support/__init__.py
new file mode 100644
index 0000000000..136309b940
--- /dev/null
+++ b/python/tvm/support/__init__.py
@@ -0,0 +1,54 @@
+# 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.
+"""tvm.support — Python helpers that integrate TVM with external CLIs
+and host-side tools (compilers, archivers, subprocess pools, build-info
+queries). Distinct from `tvm.contrib`, which is reserved for optional
+vendor SDK integrations and experimental features."""
+
+import json
+import os
+import platform
+import sys
+import textwrap
+
+import tvm_ffi
+
+import tvm
+
+tvm_ffi.init_ffi_api("support", __name__)
+
+from .libinfo import libinfo
+
+
+def describe():
+ """
+ Print out information about TVM and the current Python environment
+ """
+ info = list((k, v) for k, v in libinfo().items())
+ info = dict(sorted(info, key=lambda x: x[0]))
+ print("Python Environment")
+ sys_version = sys.version.replace("\n", " ")
+ uname = platform.uname()
+ uname = f"{uname.system} {uname.release} {uname.version} {uname.machine}"
+ lines = [
+ f"TVM version = {tvm.__version__}",
+ f"Python version = {sys_version} ({sys.maxsize.bit_length() + 1} bit)",
+ f"uname = {uname}",
+ ]
+ print(textwrap.indent("\n".join(lines), prefix=" "))
+ print("CMake Options:")
+ print(textwrap.indent(json.dumps(info, indent=2), prefix=" "))
diff --git a/python/tvm/contrib/cc.py b/python/tvm/support/cc.py
similarity index 99%
rename from python/tvm/contrib/cc.py
rename to python/tvm/support/cc.py
index d63f67a1ce..85efd46fb1 100644
--- a/python/tvm/contrib/cc.py
+++ b/python/tvm/support/cc.py
@@ -295,7 +295,7 @@ def cross_compiler(
--------
.. code-block:: python
- from tvm.contrib import cc, ndk
+ from tvm.support import cc, ndk
# export using arm gcc
mod = build_runtime_module()
mod.export_library(path_dso,
diff --git a/python/tvm/contrib/clang.py b/python/tvm/support/clang.py
similarity index 100%
rename from python/tvm/contrib/clang.py
rename to python/tvm/support/clang.py
diff --git a/python/tvm/contrib/emcc.py b/python/tvm/support/emcc.py
similarity index 100%
rename from python/tvm/contrib/emcc.py
rename to python/tvm/support/emcc.py
diff --git a/python/tvm/support/libinfo.py b/python/tvm/support/libinfo.py
new file mode 100644
index 0000000000..5d461236b3
--- /dev/null
+++ b/python/tvm/support/libinfo.py
@@ -0,0 +1,45 @@
+# 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.
+"""Build-info query helpers for tvm.support."""
+
+import os
+
+
+def libinfo():
+ """Returns a dictionary of compile-time info — minimal Python fallback.
+
+ The native ``support.GetLibInfo`` global function is no longer registered
+ after the upstream sync, so we synthesize the values from build-time hints
+ instead.
+ """
+ return {
+ "USE_CUDA": os.environ.get("TVM_USE_CUDA", "ON"),
+ "USE_LLVM": os.environ.get("TVM_USE_LLVM", "ON"),
+ "USE_NCCL": os.environ.get("TVM_USE_NCCL", "ON"),
+ "USE_NVTX": os.environ.get("TVM_USE_NVTX", "ON"),
+ "USE_NVSHMEM": os.environ.get("TVM_USE_NVSHMEM", "OFF"),
+ "USE_HEXAGON": "OFF",
+ "USE_CUDNN": "OFF",
+ "USE_CUTLASS": "OFF",
+ "USE_VULKAN": "OFF",
+ "USE_OPENCL": "OFF",
+ "USE_METAL": "OFF",
+ "USE_ROCM": "OFF",
+ "USE_CLML": "OFF",
+ "USE_NNAPI_RUNTIME": "OFF",
+ "USE_NNAPI_CODEGEN": "OFF",
+ }
diff --git a/python/tvm/contrib/ndk.py b/python/tvm/support/ndk.py
similarity index 100%
rename from python/tvm/contrib/ndk.py
rename to python/tvm/support/ndk.py
diff --git a/python/tvm/contrib/nvcc.py b/python/tvm/support/nvcc.py
similarity index 100%
rename from python/tvm/contrib/nvcc.py
rename to python/tvm/support/nvcc.py
diff --git a/python/tvm/contrib/popen_pool.py b/python/tvm/support/popen_pool.py
similarity index 100%
rename from python/tvm/contrib/popen_pool.py
rename to python/tvm/support/popen_pool.py
diff --git a/python/tvm/contrib/rocm.py b/python/tvm/support/rocm.py
similarity index 100%
rename from python/tvm/contrib/rocm.py
rename to python/tvm/support/rocm.py
diff --git a/python/tvm/contrib/tar.py b/python/tvm/support/tar.py
similarity index 98%
rename from python/tvm/contrib/tar.py
rename to python/tvm/support/tar.py
index a43b4f3392..d0dc3f01eb 100644
--- a/python/tvm/contrib/tar.py
+++ b/python/tvm/support/tar.py
@@ -99,7 +99,7 @@ def normalize_file_list_by_unpacking_tars(temp, file_list):
Parameters
----------
- temp: tvm.contrib.utils.TempDirectory
+ temp: tvm.support.utils.TempDirectory
A temp dir to hold the untared files.
file_list: List[str]
diff --git a/python/tvm/contrib/utils.py b/python/tvm/support/utils.py
similarity index 100%
rename from python/tvm/contrib/utils.py
rename to python/tvm/support/utils.py
diff --git a/python/tvm/contrib/xcode.py b/python/tvm/support/xcode.py
similarity index 100%
rename from python/tvm/contrib/xcode.py
rename to python/tvm/support/xcode.py
diff --git a/python/tvm/testing/runner.py b/python/tvm/testing/runner.py
index 366a4b5155..c9353a96d9 100644
--- a/python/tvm/testing/runner.py
+++ b/python/tvm/testing/runner.py
@@ -58,7 +58,7 @@ def _args_to_numpy(args):
def _normalize_export_func(export_func, output_format) -> tuple[Callable, str]:
- from tvm.contrib import ndk, tar
+ from tvm.support import ndk, tar
def export_with(func):
return lambda mod, path: mod.export_library(path, fcompile=func)
diff --git a/python/tvm/testing/utils.py b/python/tvm/testing/utils.py
index bdbf69396a..5cf96a7e07 100644
--- a/python/tvm/testing/utils.py
+++ b/python/tvm/testing/utils.py
@@ -89,11 +89,12 @@ import pytest
import tvm
import tvm.arith
import tvm.contrib.hexagon._ci_env_check as hexagon
-import tvm.contrib.utils
+import tvm.support.utils
import tvm.te
import tvm.tirx
-from tvm.contrib import cudnn, nvcc, rocm
+from tvm.contrib import cudnn
from tvm.error import TVMError
+from tvm.support import nvcc, rocm
from tvm.target import codegen
SKIP_SLOW_TESTS = os.getenv("SKIP_SLOW_TESTS", "").lower() in {"true", "1",
"yes"}
@@ -1246,8 +1247,8 @@ def requires_cuda_compute_version(major_version,
minor_version=0, exact=False):
"""
min_version = (major_version, minor_version)
try:
- arch = tvm.contrib.nvcc.get_target_compute_version()
- compute_version = tvm.contrib.nvcc.parse_compute_version(arch)
+ arch = tvm.support.nvcc.get_target_compute_version()
+ compute_version = tvm.support.nvcc.parse_compute_version(arch)
except ValueError:
# No GPU present. This test will be skipped from the
# requires_cuda() marks as well.
@@ -1857,8 +1858,8 @@ def terminate_self():
def is_ampere_or_newer():
"""Check if the target environment has an NVIDIA Ampere GPU or newer."""
- arch = tvm.contrib.nvcc.get_target_compute_version()
- major, minor = tvm.contrib.nvcc.parse_compute_version(arch)
+ arch = tvm.support.nvcc.get_target_compute_version()
+ major, minor = tvm.support.nvcc.parse_compute_version(arch)
return major >= 8 and minor != 9
diff --git a/python/tvm/tirx/bench.py b/python/tvm/tirx/bench.py
index 63de8e706f..69f39ffbd1 100644
--- a/python/tvm/tirx/bench.py
+++ b/python/tvm/tirx/bench.py
@@ -30,8 +30,8 @@ import triton.profiler as proton
import tvm_ffi
import tvm
-from tvm.contrib import nvcc
from tvm.script import tirx as Tx
+from tvm.support import nvcc
def is_running_under_pytest():
diff --git a/python/tvm/tirx/operator/intrinsics/cuda/header.py
b/python/tvm/tirx/operator/intrinsics/cuda/header.py
index c986ced2e9..848c3bd0ec 100644
--- a/python/tvm/tirx/operator/intrinsics/cuda/header.py
+++ b/python/tvm/tirx/operator/intrinsics/cuda/header.py
@@ -74,7 +74,7 @@ def header_generator(tags):
# NVRTC has no host C++ stdlib and no <cuda.h>. Branch on __CUDACC_RTC__ so
# the same emitted source compiles under both nvcc (offline) and NVRTC
- # (runtime) without any post-processing in tvm.contrib.nvcc.
+ # (runtime) without any post-processing in tvm.support.nvcc.
header += """
#ifdef __CUDACC_RTC__
#include <cuda/std/cstdint>
diff --git a/python/tvm/tirx/script/builder/external_kernel.py
b/python/tvm/tirx/script/builder/external_kernel.py
index e76854b936..c1f5d58716 100644
--- a/python/tvm/tirx/script/builder/external_kernel.py
+++ b/python/tvm/tirx/script/builder/external_kernel.py
@@ -28,8 +28,8 @@ import tvm_ffi
from tvm import __version__ as tvm_version
from tvm import tirx
-from tvm.contrib import nvcc
from tvm.runtime import Module, const
+from tvm.support import nvcc
class BaseKernel: # pylint: disable=too-few-public-methods
diff --git
a/tests/python/all-platform-minimal-test/test_minimal_target_codegen_llvm.py
b/tests/python/all-platform-minimal-test/test_minimal_target_codegen_llvm.py
index 19a11e4582..117be6e78d 100644
--- a/tests/python/all-platform-minimal-test/test_minimal_target_codegen_llvm.py
+++ b/tests/python/all-platform-minimal-test/test_minimal_target_codegen_llvm.py
@@ -26,7 +26,7 @@ import numpy as np
import tvm
import tvm.testing
from tvm import te, topi
-from tvm.contrib import utils
+from tvm.support import utils
@tvm.testing.requires_llvm
diff --git a/tests/python/codegen/test_gpu_codegen_allreduce.py
b/tests/python/codegen/test_gpu_codegen_allreduce.py
index dcf0c56648..31fb71706d 100644
--- a/tests/python/codegen/test_gpu_codegen_allreduce.py
+++ b/tests/python/codegen/test_gpu_codegen_allreduce.py
@@ -105,7 +105,7 @@ def
optional_metal_compile_callback(define_metal_compile_callback):
@tvm.register_global_func(name, override=True)
def compile_metal(src, target):
- from tvm.contrib.xcode import compile_metal # pylint:
disable=import-outside-toplevel
+ from tvm.support.xcode import compile_metal # pylint:
disable=import-outside-toplevel
return compile_metal(src, sdk="macosx")
diff --git a/tests/python/codegen/test_inject_ptx_ldg32.py
b/tests/python/codegen/test_inject_ptx_ldg32.py
index 4ea92421a7..fa61b6a503 100644
--- a/tests/python/codegen/test_inject_ptx_ldg32.py
+++ b/tests/python/codegen/test_inject_ptx_ldg32.py
@@ -41,8 +41,8 @@ def vector_add(A: T.Buffer((16), "float32"), B:
T.Buffer((32), "float32")) -> No
@tvm.testing.requires_cuda
def test_inject_ptx_intrin():
f = vector_add
- arch = tvm.contrib.nvcc.get_target_compute_version()
- major, _ = tvm.contrib.nvcc.parse_compute_version(arch)
+ arch = tvm.support.nvcc.get_target_compute_version()
+ major, _ = tvm.support.nvcc.parse_compute_version(arch)
if major < 8:
# Require at least SM80
return
diff --git a/tests/python/codegen/test_target_codegen_blob.py
b/tests/python/codegen/test_target_codegen_blob.py
index 5f27968ca8..8b4104fa10 100644
--- a/tests/python/codegen/test_target_codegen_blob.py
+++ b/tests/python/codegen/test_target_codegen_blob.py
@@ -22,9 +22,9 @@ import numpy as np
import tvm
import tvm.testing
-from tvm.contrib import cc, popen_pool, tar, utils
from tvm.script import ir as I
from tvm.script import tirx as T
+from tvm.support import cc, popen_pool, tar, utils
@tvm.testing.uses_gpu
diff --git a/tests/python/codegen/test_target_codegen_c_host.py
b/tests/python/codegen/test_target_codegen_c_host.py
index 035e4f30ef..5dac50d48e 100644
--- a/tests/python/codegen/test_target_codegen_c_host.py
+++ b/tests/python/codegen/test_target_codegen_c_host.py
@@ -19,9 +19,9 @@ import numpy as np
import tvm
import tvm.testing
-from tvm.contrib import utils
from tvm.script import ir as I
from tvm.script import tirx as T
+from tvm.support import utils
def test_add():
diff --git a/tests/python/codegen/test_target_codegen_cross_llvm.py
b/tests/python/codegen/test_target_codegen_cross_llvm.py
index 54b3c3d889..11800f1e61 100644
--- a/tests/python/codegen/test_target_codegen_cross_llvm.py
+++ b/tests/python/codegen/test_target_codegen_cross_llvm.py
@@ -25,9 +25,9 @@ import numpy as np
import tvm
import tvm.testing
from tvm import rpc
-from tvm.contrib import cc, utils
from tvm.script import ir as I
from tvm.script import tirx as T
+from tvm.support import cc, utils
@I.ir_module(s_tir=True)
diff --git a/tests/python/codegen/test_target_codegen_cuda.py
b/tests/python/codegen/test_target_codegen_cuda.py
index 391544cef1..7ffa189b64 100644
--- a/tests/python/codegen/test_target_codegen_cuda.py
+++ b/tests/python/codegen/test_target_codegen_cuda.py
@@ -21,11 +21,11 @@ import numpy as np
import pytest
import tvm
-import tvm.contrib.nvcc
+import tvm.support.nvcc
import tvm.testing
-from tvm.contrib.nvcc import have_bf16, have_fp16, have_int8
from tvm.script import ir as I
from tvm.script import tirx as T
+from tvm.support.nvcc import have_bf16, have_fp16, have_int8
@pytest.fixture(autouse=True, params=["nvcc", "nvrtc"])
@@ -37,13 +37,13 @@ def setup_cuda_compile_mode(request):
except ImportError:
pytest.skip("cuda-python not available, skipping nvrtc tests")
- orig_func = tvm.contrib.nvcc.tvm_callback_cuda_compile
+ orig_func = tvm.support.nvcc.tvm_callback_cuda_compile
def compile_mode_wrapper(code):
if mode == "nvcc":
- return tvm.contrib.nvcc.compile_cuda(code, target_format="fatbin",
compiler="nvcc")
+ return tvm.support.nvcc.compile_cuda(code, target_format="fatbin",
compiler="nvcc")
elif mode == "nvrtc":
- return tvm.contrib.nvcc.compile_cuda(code, target_format="cubin",
compiler="nvrtc")
+ return tvm.support.nvcc.compile_cuda(code, target_format="cubin",
compiler="nvrtc")
else:
raise ValueError(f"Unknown mode: {mode}")
diff --git a/tests/python/codegen/test_target_codegen_cuda_fastmath.py
b/tests/python/codegen/test_target_codegen_cuda_fastmath.py
index a3a9d4a308..7686dc0dad 100644
--- a/tests/python/codegen/test_target_codegen_cuda_fastmath.py
+++ b/tests/python/codegen/test_target_codegen_cuda_fastmath.py
@@ -26,10 +26,10 @@ import pytest
import tvm
import tvm.testing
import tvm.tirx as tirx
-from tvm.contrib.nvcc import have_fp16
from tvm.ir.module import IRModule
from tvm.runtime.executable import Executable
from tvm.script import tirx as T
+from tvm.support.nvcc import have_fp16
VECTOR_N_INPUTS = 8
diff --git a/tests/python/codegen/test_target_codegen_llvm.py
b/tests/python/codegen/test_target_codegen_llvm.py
index 3c7e22d40a..033d5af32f 100644
--- a/tests/python/codegen/test_target_codegen_llvm.py
+++ b/tests/python/codegen/test_target_codegen_llvm.py
@@ -23,9 +23,9 @@ import pytest
import tvm
import tvm.testing
-from tvm.contrib import clang, utils
from tvm.script import ir as I
from tvm.script import tirx as T
+from tvm.support import clang, utils
from tvm.target.codegen import llvm_get_intrinsic_name,
llvm_lookup_intrinsic_id
diff --git a/tests/python/codegen/test_target_codegen_metal.py
b/tests/python/codegen/test_target_codegen_metal.py
index f9b85dc689..c1a8054b60 100644
--- a/tests/python/codegen/test_target_codegen_metal.py
+++ b/tests/python/codegen/test_target_codegen_metal.py
@@ -187,7 +187,7 @@ def test_vectorized_uint8():
@tvm.testing.requires_metal(support_required="compile-only")
def test_func_with_trailing_pod_params():
- from tvm.contrib import xcode # pylint: disable=import-outside-toplevel
+ from tvm.support import xcode # pylint: disable=import-outside-toplevel
@T.prim_func(s_tir=True)
def func(A: T.Buffer((16), "float32"), B: T.Buffer((16), "float32"), x:
T.float32):
diff --git a/tests/python/contrib/test_ccache.py
b/tests/python/contrib/test_ccache.py
index 8536622878..013b6896cb 100644
--- a/tests/python/contrib/test_ccache.py
+++ b/tests/python/contrib/test_ccache.py
@@ -23,7 +23,7 @@ import tempfile
import pytest
import tvm
-from tvm.contrib.cc import _is_linux_like, _is_windows_like,
create_executable, create_shared
+from tvm.support.cc import _is_linux_like, _is_windows_like,
create_executable, create_shared
def _src_gen(text):
diff --git a/tests/python/contrib/test_coreml_runtime.py
b/tests/python/contrib/test_coreml_runtime.py
index 4aa99f9f8f..514286100c 100644
--- a/tests/python/contrib/test_coreml_runtime.py
+++ b/tests/python/contrib/test_coreml_runtime.py
@@ -22,7 +22,8 @@ import pytest
import tvm
from tvm import rpc, te
-from tvm.contrib import coreml_runtime, utils, xcode
+from tvm.contrib import coreml_runtime
+from tvm.support import utils, xcode
proxy_host = os.environ.get("TVM_IOS_RPC_PROXY_HOST", "127.0.0.1")
proxy_port = os.environ.get("TVM_IOS_RPC_PROXY_PORT", 9090)
diff --git a/tests/python/contrib/test_popen_pool.py
b/tests/python/contrib/test_popen_pool.py
index 6ac5970f3b..479af49949 100644
--- a/tests/python/contrib/test_popen_pool.py
+++ b/tests/python/contrib/test_popen_pool.py
@@ -23,7 +23,7 @@ import time
import psutil
import pytest
-from tvm.contrib.popen_pool import PopenPoolExecutor, PopenWorker
+from tvm.support.popen_pool import PopenPoolExecutor, PopenWorker
from tvm.testing import (
identity_after,
terminate_self,
diff --git a/tests/python/contrib/test_util.py
b/tests/python/contrib/test_util.py
index fa7fe2c562..4d2ba8ed00 100644
--- a/tests/python/contrib/test_util.py
+++ b/tests/python/contrib/test_util.py
@@ -20,7 +20,7 @@ import datetime
import os
import shutil
-from tvm.contrib import utils
+from tvm.support import utils
def validate_debug_dir_path(temp_dir, expected_basename):
diff --git a/tests/python/nightly/test_nnapi/infrastructure.py
b/tests/python/nightly/test_nnapi/infrastructure.py
index 917af437b4..bf4f07431a 100644
--- a/tests/python/nightly/test_nnapi/infrastructure.py
+++ b/tests/python/nightly/test_nnapi/infrastructure.py
@@ -20,8 +20,8 @@ import numpy as np
import tvm
import tvm.script.relax as R
-from tvm.contrib import ndk, utils
from tvm.relax.backend.contrib.nnapi import partition_for_nnapi
+from tvm.support import ndk, utils
# pylint: disable=import-outside-toplevel,missing-function-docstring
diff --git a/tests/python/relax/backend/adreno/utils.py
b/tests/python/relax/backend/adreno/utils.py
index 360cf17cd3..d1153ff417 100644
--- a/tests/python/relax/backend/adreno/utils.py
+++ b/tests/python/relax/backend/adreno/utils.py
@@ -23,7 +23,7 @@ import numpy as np
import tvm
import tvm.testing
from tvm import relax
-from tvm.contrib import ndk
+from tvm.support import ndk
# Test Infra
diff --git a/tests/python/relax/test_codegen_coreml.py
b/tests/python/relax/test_codegen_coreml.py
index 63a704cc41..e9b9bcb09c 100644
--- a/tests/python/relax/test_codegen_coreml.py
+++ b/tests/python/relax/test_codegen_coreml.py
@@ -27,9 +27,9 @@ target, dev = "llvm", tvm.cpu()
def _has_xcode():
try:
- import tvm.contrib.xcode
+ import tvm.support.xcode
- tvm.contrib.xcode.xcrun([])
+ tvm.support.xcode.xcrun([])
return True
except FileNotFoundError:
pass
diff --git a/tests/python/relax/test_runtime_builtin.py
b/tests/python/relax/test_runtime_builtin.py
index 3eb06fc400..e842160f30 100644
--- a/tests/python/relax/test_runtime_builtin.py
+++ b/tests/python/relax/test_runtime_builtin.py
@@ -21,9 +21,10 @@ import tvm_ffi
import tvm
import tvm.testing
-from tvm.contrib import tvmjs, utils
+from tvm.contrib import tvmjs
from tvm.ir import assert_structural_equal
from tvm.relax.testing.runtime_builtin import MakeShapeCode, MatchShapeCode
+from tvm.support import utils
def test_make_shape():
diff --git a/tests/python/relax/test_runtime_sampling_flashinfer.py
b/tests/python/relax/test_runtime_sampling_flashinfer.py
index c5092a149a..6aaa418d07 100644
--- a/tests/python/relax/test_runtime_sampling_flashinfer.py
+++ b/tests/python/relax/test_runtime_sampling_flashinfer.py
@@ -25,7 +25,7 @@ import pytest
import tvm
import tvm.testing
from tvm import relax
-from tvm.contrib import utils
+from tvm.support import utils
@pytest.mark.skip(reason="Requires FlashInfer enabled and proper setup")
diff --git a/tests/python/relax/test_transform_codegen_pass.py
b/tests/python/relax/test_transform_codegen_pass.py
index 2e56a6721f..8b1c109035 100644
--- a/tests/python/relax/test_transform_codegen_pass.py
+++ b/tests/python/relax/test_transform_codegen_pass.py
@@ -25,12 +25,12 @@ import pytest
import tvm
import tvm.testing
from tvm import relax, s_tir, tirx
-from tvm.contrib import utils
from tvm.relax.dpl import is_op, wildcard
from tvm.relax.testing import transform
from tvm.script import ir as I
from tvm.script import relax as R
from tvm.script import tirx as T
+from tvm.support import utils
env_checker_codegen = tvm.get_global_func("relax.ext.tensorrt", True)
env_checker_runtime = tvm.get_global_func("relax.is_tensorrt_runtime_enabled",
True)
diff --git a/tests/python/relax/test_vm_build.py
b/tests/python/relax/test_vm_build.py
index aef7de8af5..7c445911ff 100644
--- a/tests/python/relax/test_vm_build.py
+++ b/tests/python/relax/test_vm_build.py
@@ -28,12 +28,12 @@ import tvm
import tvm.script
import tvm.testing
from tvm import relax, rpc, te, tirx, topi
-from tvm.contrib import cc, popen_pool, utils
from tvm.relax.testing import nn
from tvm.relax.testing.vm import check_saved_func
from tvm.script import ir as I
from tvm.script import relax as R
from tvm.script import tirx as T
+from tvm.support import cc, popen_pool, utils
EXEC_MODE = ["bytecode", "compiled"]
diff --git a/tests/python/relax/test_vm_codegen_only.py
b/tests/python/relax/test_vm_codegen_only.py
index 17c612e7ff..0585a2a844 100644
--- a/tests/python/relax/test_vm_codegen_only.py
+++ b/tests/python/relax/test_vm_codegen_only.py
@@ -122,7 +122,7 @@ def test_vm_exec_serialize_export_library(exec_mode):
mod = TestVMMove
target = tvm.target.Target("llvm", host="llvm")
ex = codegen(mod, target)
- from tvm.contrib import utils
+ from tvm.support import utils
temp_dir = utils.tempdir()
path_exec = temp_dir.relpath("exec.so")
diff --git a/tests/python/relax/texture/test_texture_nd.py
b/tests/python/relax/texture/test_texture_nd.py
index a63ec042b1..201faec112 100644
--- a/tests/python/relax/texture/test_texture_nd.py
+++ b/tests/python/relax/texture/test_texture_nd.py
@@ -30,11 +30,11 @@ from tvm import (
relax,
tirx,
)
-from tvm.contrib import ndk
from tvm.relax.transform.legalize_ops import adreno as legalize_adreno
from tvm.rpc import connect_tracker
from tvm.script import ir as I
from tvm.script import tirx as T
+from tvm.support import ndk
from tvm.target import Target
diff --git a/tests/python/runtime/test_runtime_measure.py
b/tests/python/runtime/test_runtime_measure.py
index 2559709072..626f7d6f96 100644
--- a/tests/python/runtime/test_runtime_measure.py
+++ b/tests/python/runtime/test_runtime_measure.py
@@ -20,8 +20,8 @@ import time
import tvm
from tvm import te
-from tvm.contrib.utils import tempdir
from tvm.runtime.module import BenchmarkResult
+from tvm.support.utils import tempdir
def test_min_repeat_ms():
diff --git a/tests/python/runtime/test_runtime_module_export.py
b/tests/python/runtime/test_runtime_module_export.py
index 47a1ffd41f..bb6727c0f7 100644
--- a/tests/python/runtime/test_runtime_module_export.py
+++ b/tests/python/runtime/test_runtime_module_export.py
@@ -17,7 +17,7 @@
import tvm
import tvm.testing
-from tvm.contrib import utils
+from tvm.support import utils
@tvm.testing.requires_llvm
diff --git a/tests/python/runtime/test_runtime_module_load.py
b/tests/python/runtime/test_runtime_module_load.py
index 38ac7e36e8..3983717e6e 100644
--- a/tests/python/runtime/test_runtime_module_load.py
+++ b/tests/python/runtime/test_runtime_module_load.py
@@ -23,7 +23,7 @@ import pytest
import tvm
import tvm.testing
from tvm import te
-from tvm.contrib import cc, popen_pool, utils
+from tvm.support import cc, popen_pool, utils
runtime_py = """
import os
diff --git a/tests/python/runtime/test_runtime_rpc.py
b/tests/python/runtime/test_runtime_rpc.py
index 05d8d8bf66..5dbcddea89 100644
--- a/tests/python/runtime/test_runtime_rpc.py
+++ b/tests/python/runtime/test_runtime_rpc.py
@@ -31,11 +31,11 @@ import tvm_ffi
import tvm
import tvm.testing
from tvm import rpc, te
-from tvm.contrib import cc, utils
from tvm.rpc.proxy import Proxy
from tvm.rpc.tracker import Tracker
from tvm.script import ir as I
from tvm.script import tirx as T
+from tvm.support import cc, utils
if __name__ == "__main__":
# NOTE: must live here to avoid registering PackedFunc with
libtvm_compiler.so twice.
diff --git
a/tests/python/s_tir/transform/test_s_tir_transform_inject_ptx_async_copy.py
b/tests/python/s_tir/transform/test_s_tir_transform_inject_ptx_async_copy.py
index 2d06b192e2..9875114f66 100644
--- a/tests/python/s_tir/transform/test_s_tir_transform_inject_ptx_async_copy.py
+++ b/tests/python/s_tir/transform/test_s_tir_transform_inject_ptx_async_copy.py
@@ -348,8 +348,8 @@ __asm__ __volatile__("cp.async.wait_group 0;");
@pytest.fixture
def postproc_if_missing_async_support():
- arch = tvm.contrib.nvcc.get_target_compute_version()
- major, _ = tvm.contrib.nvcc.parse_compute_version(arch)
+ arch = tvm.support.nvcc.get_target_compute_version()
+ major, _ = tvm.support.nvcc.parse_compute_version(arch)
support_async = major >= 8
func_name = "tvm_callback_cuda_postproc"
diff --git a/tests/python/target/test_arm_target.py
b/tests/python/target/test_arm_target.py
index c3d0c571a4..6b8e7c3a22 100644
--- a/tests/python/target/test_arm_target.py
+++ b/tests/python/target/test_arm_target.py
@@ -101,7 +101,7 @@ def sve_device_vector_length():
o_path = f"{tmp_dir}/out.o"
with open(c_path, "w") as f:
f.write(c_code)
- tvm.contrib.cc.create_executable(o_path, c_path, ["-march=native"])
+ tvm.support.cc.create_executable(o_path, c_path, ["-march=native"])
out = subprocess.check_output(o_path, shell=True).strip().decode()
return int(out)
diff --git a/tests/python/tirx-base/test_tir_intrin.py
b/tests/python/tirx-base/test_tir_intrin.py
index 48306dda64..4d185ac03f 100644
--- a/tests/python/tirx-base/test_tir_intrin.py
+++ b/tests/python/tirx-base/test_tir_intrin.py
@@ -24,8 +24,8 @@ import scipy
import tvm
import tvm.testing
from tvm import te, tirx, topi
-from tvm.contrib import clang, utils
from tvm.script import tirx as T
+from tvm.support import clang, utils
def test_nearbyint():
diff --git a/tests/python/tirx/codegen/test_codegen_nvshmem.py
b/tests/python/tirx/codegen/test_codegen_nvshmem.py
index 6e48246d53..0e6ba4c79e 100644
--- a/tests/python/tirx/codegen/test_codegen_nvshmem.py
+++ b/tests/python/tirx/codegen/test_codegen_nvshmem.py
@@ -24,10 +24,10 @@ import pytest
import tvm
import tvm.testing
-from tvm.contrib.popen_pool import PopenWorker
from tvm.runtime import ShapeTuple
from tvm.runtime import disco as di
from tvm.script import tirx as Tx
+from tvm.support.popen_pool import PopenWorker
NUM_WORKERS = 4
diff --git a/web/tests/python/relax_rpc_test.py
b/web/tests/python/relax_rpc_test.py
index afe5a72082..579ed014ce 100644
--- a/web/tests/python/relax_rpc_test.py
+++ b/web/tests/python/relax_rpc_test.py
@@ -20,8 +20,9 @@ import numpy as np
import tvm
from tvm import relax, rpc
-from tvm.contrib import tvmjs, utils
+from tvm.contrib import tvmjs
from tvm.script import relax as R
+from tvm.support import utils
proxy_host = "127.0.0.1"
proxy_port = 9090
diff --git a/web/tests/python/webgpu_rpc_test.py
b/web/tests/python/webgpu_rpc_test.py
index bf1c9ac780..22aa0e3a07 100644
--- a/web/tests/python/webgpu_rpc_test.py
+++ b/web/tests/python/webgpu_rpc_test.py
@@ -24,7 +24,8 @@ import numpy as np
import tvm
from tvm import rpc, te
-from tvm.contrib import tvmjs, utils
+from tvm.contrib import tvmjs
+from tvm.support import utils
proxy_host = "127.0.0.1"
proxy_port = 9090