This is an automated email from the ASF dual-hosted git repository.
tqchen pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm-ffi.git
The following commit(s) were added to refs/heads/main by this push:
new a5241e5 [ADDON] Fix import issue (#227)
a5241e5 is described below
commit a5241e5e5edf5f8e7b1250a945c816cc1b3169c4
Author: Tianqi Chen <[email protected]>
AuthorDate: Tue Nov 4 21:36:29 2025 -0500
[ADDON] Fix import issue (#227)
This PR fixes an import issue of the torch_c_dlpack_ext so prebuild can
be properly used here.
---
addons/torch_c_dlpack_ext/build_backend.py | 2 ++
addons/torch_c_dlpack_ext/pyproject.toml | 2 +-
addons/torch_c_dlpack_ext/torch_c_dlpack_ext/__init__.py | 2 +-
python/tvm_ffi/_optional_torch_c_dlpack.py | 6 ++----
4 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/addons/torch_c_dlpack_ext/build_backend.py
b/addons/torch_c_dlpack_ext/build_backend.py
index 8a14388..4301e43 100644
--- a/addons/torch_c_dlpack_ext/build_backend.py
+++ b/addons/torch_c_dlpack_ext/build_backend.py
@@ -18,6 +18,7 @@
from __future__ import annotations
+import os
import subprocess
import sys
from pathlib import Path
@@ -83,5 +84,6 @@ def build_wheel(
"--build-with-cuda" if torch.cuda.is_available() else "",
],
check=True,
+ env={**os.environ, "TVM_FFI_DISABLE_TORCH_C_DLPACK": "1"},
)
return orig.build_wheel(wheel_directory, config_settings,
metadata_directory)
diff --git a/addons/torch_c_dlpack_ext/pyproject.toml
b/addons/torch_c_dlpack_ext/pyproject.toml
index 549dc85..3cf0138 100644
--- a/addons/torch_c_dlpack_ext/pyproject.toml
+++ b/addons/torch_c_dlpack_ext/pyproject.toml
@@ -17,7 +17,7 @@
[project]
name = "torch_c_dlpack_ext"
-version = "0.1.0"
+version = "0.1.1"
requires-python = ">=3.9"
description = "torch c dlpack ext"
dependencies = ["torch"]
diff --git a/addons/torch_c_dlpack_ext/torch_c_dlpack_ext/__init__.py
b/addons/torch_c_dlpack_ext/torch_c_dlpack_ext/__init__.py
index cbde1de..9cb6f9f 100644
--- a/addons/torch_c_dlpack_ext/torch_c_dlpack_ext/__init__.py
+++ b/addons/torch_c_dlpack_ext/torch_c_dlpack_ext/__init__.py
@@ -16,4 +16,4 @@
# under the License.
"""torch c dlpack ext pakcage."""
-import core
+from . import core
diff --git a/python/tvm_ffi/_optional_torch_c_dlpack.py
b/python/tvm_ffi/_optional_torch_c_dlpack.py
index 4c5e024..302a29c 100644
--- a/python/tvm_ffi/_optional_torch_c_dlpack.py
+++ b/python/tvm_ffi/_optional_torch_c_dlpack.py
@@ -57,14 +57,12 @@ def load_torch_c_dlpack_extension() -> Any:
try:
import torch_c_dlpack_ext # type: ignore # noqa: PLC0415, F401
- return None
+ if hasattr(torch.Tensor, "__c_dlpack_exchange_api__"):
+ return None
except ImportError:
pass
try:
- # todo: check whether a prebuilt package is installed, if so, use it.
- ...
-
# check whether a JIT shared library is built in cache
cache_dir = Path(os.environ.get("TVM_FFI_CACHE_DIR",
"~/.cache/tvm-ffi")).expanduser()
addon_output_dir = cache_dir