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_FFI_DECLARE_OBJECT_INFO_FINAL macro."); \
114 ObjectName* CopyOnWrite() { \
115 ICHECK(data_ != nullptr); \
116 if (!data_.unique()) { \
117 auto n = ::tvm::ffi::make_object<ObjectName>(*(operator->())); \
118 ObjectPtr<Object>(std::move(n)).swap(data_); \
120 return static_cast<ObjectName*>(data_.get()); \
129 #define TVM_FFI_DEFINE_OBJECT_REF_METHODS_NULLABLE_WITHOUT_DEFAULT_CONSTRUCTOR( \
130 TypeName, ParentType, ObjectName) \
131 explicit TypeName(::tvm::ffi::ObjectPtr<ObjectName> 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_STR_CONCAT_(__x, __y) __x##__y
138 #define TVM_STR_CONCAT(__x, __y) TVM_STR_CONCAT_(__x, __y)
142 using tvm::ffi::ObjectPtr;
143 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
@ kStaticIndexEnd
Definition: object.h:73
@ kRuntimePackedFunc
ffi::Function.
Definition: object.h:63
@ kRuntimeTensor
runtime::Tensor.
Definition: object.h:56
@ 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