tvm_ffi.Object#
- class tvm_ffi.Object#
Bases:
objectBase 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
Objectinstances uses underlying handle identity unless an overridden implementation is provided on the concrete type. Usesame_as()to check whether two references point to the same underlying object.Most users interact with subclasses (e.g.
Tensor,Function) rather thanObjectdirectly.
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
Trueif both references point to the same object.- __ffi_init__(*args)#
Initialize the instance using the
__ffi_init__method registered on C++ side.
- same_as(other)#
Return
Trueif both references point to the same object.This checks identity of the underlying FFI handle rather than performing a structural, value-based comparison.
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)