Python API#

TVM FFI Python package.

Object#

Object

Base class of all TVM FFI objects.

Tensor#

Tensor

Managed n-dimensional array compatible with DLPack.

from_dlpack(ext_tensor, *[, ...])

Import a foreign array that implements the DLPack producer protocol.

Shape(content)

Shape tuple that represents tvm::ffi::Shape returned by an FFI call.

dtype(content)

Lightweight data type in TVM FFI.

Device

A device descriptor used by TVM FFI and DLPack.

DLDeviceType(value[, names, module, ...])

Enumeration mirroring DLPack's DLDeviceType

device(device_type[, index])

Construct a TVM FFI device with given device type and index.

Function#

Function

Callable wrapper around a TVM FFI function.

Module#

Module(*args, **kwargs)

Module container for dynamically loaded Module.

system_lib([symbol_prefix])

Get system-wide library module singleton with functions prefixed by __tvm_ffi_{symbol_prefix}.

load_module(path)

Load module from file.

Containers#

Array(input_list)

Array container that represents a sequence of values in the FFI.

Map(input_dict)

Map container.

Global Registry#

register_error([name_or_cls, cls])

Register an error class so it can be recognized by the ffi error handler.

register_object([type_key])

Register object type.

register_global_func(func_name[, f, override])

Register global function.

get_global_func(name[, allow_missing])

Get a global function by name.

get_global_func_metadata(name)

Get metadata (including type schema) for a global function.

init_ffi_api(namespace[, target_module_name])

Initialize register ffi api functions into a given module.

remove_global_func(name)

Remove a global function by name.

Stream Context#

StreamContext(device, stream)

Represent a stream context in the FFI system.

use_torch_stream([context])

Create an FFI stream context with a Torch stream or graph.

use_raw_stream(device, stream)

Create an FFI stream context with the given device and stream handle.

get_raw_stream(device)

Get the current FFI stream of a given device.

C++ Extension#

C++ integration helpers for building and loading inline modules.

cpp.load_inline(name, *[, cpp_sources, ...])

Compile, build and load a C++/CUDA module from inline source code.

cpp.build_inline(name, *[, cpp_sources, ...])

Compile and build a C++/CUDA module from inline source code.

cpp.load(name, *[, cpp_files, cuda_files, ...])

Compile, build and load a C++/CUDA module from source files.

cpp.build(name, *[, cpp_files, cuda_files, ...])

Compile and build a C++/CUDA module from source files.

Misc#

serialization.from_json_graph_str(json_str)

Load an object from a JSON graph string.

serialization.to_json_graph_str(obj[, metadata])

Dump an object to a JSON graph string.

access_path.AccessKind(value[, names, ...])

Kinds of access steps in an access path.

access_path.AccessPath()

Access path container.

access_path.AccessStep(*args, **kwargs)

Access step container.

convert(value)

Convert a Python object into TVM FFI values.

ObjectConvertible()

Base class for Python classes convertible to Object.