tvm_ffi.register_object#
- tvm_ffi.register_object(type_key=None)[source]#
Register object type.
- Parameters:
type_key (
str|None, default:None) – The type key of the node. It requirestype_keyto be registered already on the C++ side. If not specified, the class name will be used.- Return type:
Callable[[TypeVar(_T, bound=type)],TypeVar(_T, bound=type)]
Notes
All
Objectsubclasses get__slots__ = ()by default via the metaclass, preventing per-instance__dict__. To opt out and allow arbitrary instance attributes, declare__slots__ = ("__dict__",)explicitly in the class body:@tvm_ffi.register_object("test.MyObject") class MyObject(Object): __slots__ = ("__dict__",)
Examples
The following code registers MyObject using type key “test.MyObject”, if the type key is already registered on the C++ side.
@tvm_ffi.register_object("test.MyObject") class MyObject(Object): pass