tvm_ffi.Object#

class tvm_ffi.Object#

Bases: object

Base class of all TVM FFI objects.

This is the root Python type for objects backed by the TVM FFI runtime. Each instance references a handle to a C++ runtime object. Python subclasses typically correspond to C++ runtime types and are registered via tvm_ffi.register_object.

Notes

  • Equality of two Object instances uses underlying handle identity unless an overridden implementation is provided on the concrete type. Use same_as() to check whether two references point to the same underlying object.

  • Most users interact with subclasses (e.g. Tensor, Function) rather than Object directly.

Examples

Constructing objects is typically performed by Python wrappers that call into registered constructors on the FFI side.

# Acquire a testing object constructed through FFI
obj = tvm_ffi.testing.create_object("testing.TestObjectBase", v_i64=12)
assert isinstance(obj, tvm_ffi.Object)
assert obj.same_as(obj)
__init__()#

Methods

__ffi_init__(*args)

Initialize the instance using the __ffi_init__ method registered on C++ side.

same_as(other)

Return True if both references point to the same object.

__ffi_init__(*args)#

Initialize the instance using the __ffi_init__ method registered on C++ side.

Parameters:

args (list of objects) – The arguments to the constructor

Return type:

None

same_as(other)#

Return True if both references point to the same object.

This checks identity of the underlying FFI handle rather than performing a structural, value-based comparison.

Parameters:

other (object) – The object to compare against.

Return type:

bool

Returns:

bool

Examples

x = tvm_ffi.testing.create_object("testing.TestObjectBase")
y = x
z = tvm_ffi.testing.create_object("testing.TestObjectBase")
assert x.same_as(y)
assert not x.same_as(z)