Registry / ai-ml / apache-tvm-ffi

apache-tvm-ffi

JSON →
library0.1.13.post3pypypi✓ verified 9d ago

apache-tvm-ffi provides the foundational Foreign Function Interface (FFI) layer for the Apache TVM deep learning compiler stack, enabling Python to bind to and interact with C++ types and functions. It is currently at version 0.1.10 and receives frequent, minor updates.

pip install apache-tvm-ffi
INSTALL
IMPORT
SIG · APACHE-TVM-FFI
A
apache-tvm-ffi
ai-mlpythonv0.1.13.post3
Install
1.9s avg
Import
206ms
Disk
27MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.1.13.post3 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
build_error
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.9s · import 0.206s · 29MB
27MB installed
● package 27MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

tvm_ffi
import tvm_ffi
device
from tvm_ffi import device
import tvm_ffi.device
The `device` function is a direct export from the top-level `tvm_ffi` module, not a submodule.
Object
from tvm_ffi.runtime_base import Object
Function
from tvm_ffi.runtime_base import Function

Demonstrates basic device context creation using `tvm_ffi.device` and shows the `tvm_ffi.runtime_base.Object` base class for extending FFI objects.

import tvm_ffi # tvm_ffi provides low-level FFI bindings, often used with TVM itself. # A simple interaction is with device context management. # Create a CPU device context cpu_ctx = tvm_ffi.device("cpu", 0) print(f"CPU context: {cpu_ctx}") assert str(cpu_ctx) == "cpu(0)" # Attempt to create a GPU device context (may fail if no GPU is present) try: gpu_ctx = tvm_ffi.device("cuda", 0) print(f"CUDA context: {gpu_ctx}") assert str(gpu_ctx) == "cuda(0)" except tvm_ffi.TVMError as e: print(f"Could not create CUDA context: {e}") # The tvm_ffi.Object is a base class for runtime objects from tvm_ffi.runtime_base import Object class MyTVMObject(Object): # Custom runtime objects inherit from tvm_ffi.runtime_base.Object # This is often extended in C++ and exposed via FFI. pass # Note: Direct instantiation of Object in Python is usually for type hinting # or for objects returned from FFI calls. # obj = MyTVMObject() # This would typically require C++ backend setup
Debug
Known issues
breakingThe Python-side field descriptor infrastructure for dataclasses was removed. If you were using `tvm-ffi` to define dataclasses with specific FFI-related field descriptors, this API has been removed.
fix
Re-evaluate your dataclass integration with `tvm-ffi`. You may need to remove or refactor custom Python-side field descriptor logic, as the underlying infrastructure is no longer available.
affects: >=0.1.10
breakingThe `tvm_ffi.Function.__init__` constructor, which was briefly introduced, was reverted. If you implemented code relying on a custom `__init__` for `tvm_ffi.Function` objects, it will break.
fix
Remove any direct calls to `tvm_ffi.Function.__init__` or rework code that assumed its presence. `tvm_ffi.Function` objects are typically obtained from FFI calls or registered C++ functions rather than being instantiated directly in Python.
affects: >=0.1.9
gotchaThe `apache-tvm-ffi` library is a low-level FFI binding for TVM's C++ runtime. It is not typically used as a standalone application library but rather as a foundational component for deeper integration with TVM or custom C++ extensions. Its API surface can be complex and requires understanding of TVM's C++ backend.
fix
Ensure you have a clear understanding of its role within the TVM ecosystem. For general TVM usage, you might interact with higher-level `tvm` library constructs, which internally use `apache-tvm-ffi`.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'tvm_ffi'
The 'tvm_ffi' module is not installed or not found in the Python environment.
fix
Install the 'tvm_ffi' module by running 'pip install apache-tvm-ffi'.
ImportError: cannot import name 'core' from partially initialized module 'tvm_ffi' (most likely due to a circular import)
A circular import occurred due to improper module initialization.
fix
Ensure that the 'tvm_ffi' module is correctly installed and that there are no circular dependencies in your imports.
ModuleNotFoundError: No module named 'tvm._ffi.function'
The 'tvm._ffi.function' module is missing, possibly due to an incomplete or incorrect installation of TVM.
fix
Reinstall TVM by following the official installation guide to ensure all modules are properly installed.
ModuleNotFoundError: No module named 'tvm'
The 'tvm' Python package, which relies on `apache-tvm-ffi`, is not installed or not accessible in the current Python environment or `PYTHONPATH` is incorrectly set. This often happens after building TVM from source without properly installing the Python bindings.
fix
Ensure TVM and its FFI bindings are correctly installed. If using pip, run: `pip install apache-tvm-ffi` (or `pip install apache-tvm --pre` for the full TVM package). If building from source, make sure you've built the Python package and added the `python` directory of your TVM installation to your `PYTHONPATH`.
RuntimeError: Cannot find the TVM runtime library
The Python `tvm` package can be imported, but it fails to load the underlying C++ shared library (`libtvm.so` on Linux/macOS or `tvm.dll` on Windows), which is essential for its FFI functionality. This typically means the compiled library is missing or its path is not in the system's dynamic library search paths (`LD_LIBRARY_PATH` on Linux, `DYLD_LIBRARY_PATH` on macOS, `PATH` on Windows).
fix
Verify that the TVM C++ shared library (`libtvm.so` or `tvm.dll`) has been built and is located in a directory included in your system's dynamic linker search path. You might need to set `export TVM_LIBRARY_PATH=/path/to/tvm/build` or add `/path/to/tvm/build` to `LD_LIBRARY_PATH` (or equivalent for your OS).
Upgrade
Version history
0.1.13.post3latest on PyPI · released Aug 10, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
50 hits · last 30 days
node
44
Amazon
1
Google (AI)
1
Resources
apache-tvm-ffi — pip install apache-tvm-ffi · libregistry