C++ API#

This page contains the API reference for the C++ API. The full API index below can be a bit dense, so we recommend the following tips first:

  • Please read the C++ Guide for a high-level overview of the C++ API.

    • The C++ Guide and examples will likely be sufficient to get started with most use cases.

  • The Key Classes lists the key classes that are most commonly used.

  • You can go to the Full API Index at the bottom of this page to access the full list of APIs.

    • We usually group the APIs by files. You can look at the file hierarchy in the full API index and navigate to the specific file to find the APIs in that file.

Header Organization#

The C++ APIs are organized into the following folders:

Folder

Description

tvm/ffi/

Core functionalities that support Function, Any, Object, etc.

tvm/ffi/container/

Additional container types such as Array, Map, Shape, Tensor, Variant …

tvm/ffi/reflection/

Reflection support for function and type information registration.

tvm/ffi/extra/

Extra APIs that are built on top.

Key Classes#

Class

Description

tvm::ffi::Function

Type-erased function that implements the ABI.

tvm::ffi::Any

Type-erased container for any supported value.

tvm::ffi::AnyView

Lightweight view of Any without ownership.

tvm::ffi::Object

Base class for all heap-allocated FFI objects.

tvm::ffi::ObjectRef

Reference class for objects.

tvm::ffi::Tensor

Multi-dimensional tensor with DLPack support.

tvm::ffi::Shape

Tensor shape container.

tvm::ffi::Module

Dynamic library module that can load exported functions.

tvm::ffi::String

String type for FFI.

tvm::ffi::Bytes

Byte array type.

tvm::ffi::Array

Dynamic array container.

tvm::ffi::Tuple

Heterogeneous tuple container.

tvm::ffi::Map

Key-value map container.

tvm::ffi::Optional

Optional value wrapper.

tvm::ffi::Variant

Type-safe union container.

Full API Index#