23 #ifndef TVM_RUNTIME_OBJECT_H_
24 #define TVM_RUNTIME_OBJECT_H_
26 #include <tvm/ffi/cast.h>
27 #include <tvm/ffi/object.h>
28 #include <tvm/ffi/optional.h>
36 using tvm::ffi::Object;
37 using tvm::ffi::ObjectPtr;
38 using tvm::ffi::ObjectPtrEqual;
39 using tvm::ffi::ObjectPtrHash;
40 using tvm::ffi::ObjectRef;
42 using tvm::ffi::GetObjectPtr;
43 using tvm::ffi::GetRef;
77 static_cast<int>(TVMFFITypeIndex::kTVMFFIStaticObjectEnd),
78 "Static slot overflows to custom indices");
84 #define TVM_DEFINE_DEFAULT_COPY_MOVE_AND_ASSIGN(TypeName) \
85 TypeName(const TypeName& other) = default; \
86 TypeName(TypeName&& other) = default; \
87 TypeName& operator=(const TypeName& other) = default; \
88 TypeName& operator=(TypeName&& other) = default;
109 #define TVM_DEFINE_OBJECT_REF_COW_METHOD(ObjectName) \
110 static_assert(ObjectName::_type_final, \
111 "TVM's CopyOnWrite may only be used for " \
112 "Object types that are declared as final, " \
113 "using the TVM_DECLARE_FINAL_OBJECT_INFO macro."); \
114 ObjectName* CopyOnWrite() { \
115 ICHECK(data_ != nullptr); \
116 if (!data_.unique()) { \
117 auto n = make_object<ObjectName>(*(operator->())); \
118 ObjectPtr<Object>(std::move(n)).swap(data_); \
120 return static_cast<ObjectName*>(data_.get()); \
129 #define TVM_DEFINE_OBJECT_REF_METHODS_WITHOUT_DEFAULT_CONSTRUCTOR(TypeName, ParentType, \
131 explicit TypeName(::tvm::ffi::ObjectPtr<::tvm::ffi::Object> n) : ParentType(n) {} \
132 TVM_DEFINE_DEFAULT_COPY_MOVE_AND_ASSIGN(TypeName); \
133 const ObjectName* operator->() const { return static_cast<const ObjectName*>(data_.get()); } \
134 const ObjectName* get() const { return operator->(); } \
135 using ContainerType = ObjectName;
137 #define TVM_DECLARE_BASE_OBJECT_INFO TVM_FFI_DECLARE_BASE_OBJECT_INFO
138 #define TVM_DECLARE_FINAL_OBJECT_INFO TVM_FFI_DECLARE_FINAL_OBJECT_INFO
139 #define TVM_DEFINE_NOTNULLABLE_OBJECT_REF_METHODS TVM_FFI_DEFINE_NOTNULLABLE_OBJECT_REF_METHODS
141 #define TVM_DEFINE_MUTABLE_OBJECT_REF_METHODS TVM_FFI_DEFINE_MUTABLE_OBJECT_REF_METHODS
142 #define TVM_DEFINE_OBJECT_REF_METHODS TVM_FFI_DEFINE_OBJECT_REF_METHODS
143 #define TVM_DEFINE_MUTABLE_NOTNULLABLE_OBJECT_REF_METHODS \
144 TVM_FFI_DEFINE_MUTABLE_NOTNULLABLE_OBJECT_REF_METHODS
146 #define TVM_STR_CONCAT_(__x, __y) __x##__y
147 #define TVM_STR_CONCAT(__x, __y) TVM_STR_CONCAT_(__x, __y)
151 using tvm::ffi::ObjectPtr;
152 using tvm::ffi::ObjectRef;
TypeIndex
Namespace for the list of type index.
Definition: object.h:50
@ kRuntimeDiscoDRef
runtime::DRef for disco distributed runtime
Definition: object.h:65
@ kRuntimeMap
Definition: object.h:70
@ kRuntimeNDArray
runtime::NDArray.
Definition: object.h:56
@ kStaticIndexEnd
Definition: object.h:73
@ kRuntimePackedFunc
ffi::Function.
Definition: object.h:63
@ kRuntimeShape
runtime::Shape.
Definition: object.h:58
@ kRuntimeArray
Definition: object.h:71
@ kRuntimeRPCObjectRef
runtime::RPCObjectRef
Definition: object.h:67
@ kRuntimeString
Definition: object.h:69
@ kCustomStaticIndex
Definition: object.h:61
@ kRuntimeModule
runtime::Module.
Definition: object.h:54
Performance counters for profiling via the PAPI library.
Definition: analyzer.h:37