tvm
Namespaces | Macros | Enumerations
object.h File Reference

A managed object in the TVM runtime. More...

#include <tvm/ffi/cast.h>
#include <tvm/ffi/object.h>
#include <tvm/ffi/optional.h>
#include <tvm/runtime/base.h>
#include <utility>
Include dependency graph for object.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

 tvm
 Performance counters for profiling via the PAPI library.
 
 tvm::runtime
 

Macros

#define TVM_DEFINE_DEFAULT_COPY_MOVE_AND_ASSIGN(TypeName)
 
#define TVM_DEFINE_OBJECT_REF_COW_METHOD(ObjectName)
 Define CopyOnWrite function in an ObjectRef. More...
 
#define TVM_DEFINE_OBJECT_REF_METHODS_WITHOUT_DEFAULT_CONSTRUCTOR(TypeName, ParentType, ObjectName)
 
#define TVM_DECLARE_BASE_OBJECT_INFO   TVM_FFI_DECLARE_BASE_OBJECT_INFO
 
#define TVM_DECLARE_FINAL_OBJECT_INFO   TVM_FFI_DECLARE_FINAL_OBJECT_INFO
 
#define TVM_DEFINE_NOTNULLABLE_OBJECT_REF_METHODS   TVM_FFI_DEFINE_NOTNULLABLE_OBJECT_REF_METHODS
 
#define TVM_DEFINE_MUTABLE_OBJECT_REF_METHODS   TVM_FFI_DEFINE_MUTABLE_OBJECT_REF_METHODS
 
#define TVM_DEFINE_OBJECT_REF_METHODS   TVM_FFI_DEFINE_OBJECT_REF_METHODS
 
#define TVM_DEFINE_MUTABLE_NOTNULLABLE_OBJECT_REF_METHODS    TVM_FFI_DEFINE_MUTABLE_NOTNULLABLE_OBJECT_REF_METHODS
 
#define TVM_STR_CONCAT_(__x, __y)   __x##__y
 
#define TVM_STR_CONCAT(__x, __y)   TVM_STR_CONCAT_(__x, __y)
 

Enumerations

enum  tvm::runtime::TypeIndex : int32_t {
  tvm::runtime::kRuntimeModule = TVMFFITypeIndex::kTVMFFIModule , tvm::runtime::kRuntimeNDArray = TVMFFITypeIndex::kTVMFFINDArray , tvm::runtime::kRuntimeShape = TVMFFITypeIndex::kTVMFFIShape , tvm::runtime::kCustomStaticIndex = TVMFFITypeIndex::kTVMFFIDynObjectBegin - 16 ,
  tvm::runtime::kRuntimePackedFunc = kCustomStaticIndex + 1 , tvm::runtime::kRuntimeDiscoDRef = kCustomStaticIndex + 2 , tvm::runtime::kRuntimeRPCObjectRef = kCustomStaticIndex + 3 , tvm::runtime::kRuntimeString ,
  tvm::runtime::kRuntimeMap , tvm::runtime::kRuntimeArray , tvm::runtime::kStaticIndexEnd
}
 Namespace for the list of type index. More...
 

Detailed Description

A managed object in the TVM runtime.

Macro Definition Documentation

◆ TVM_DECLARE_BASE_OBJECT_INFO

#define TVM_DECLARE_BASE_OBJECT_INFO   TVM_FFI_DECLARE_BASE_OBJECT_INFO

◆ TVM_DECLARE_FINAL_OBJECT_INFO

#define TVM_DECLARE_FINAL_OBJECT_INFO   TVM_FFI_DECLARE_FINAL_OBJECT_INFO

◆ TVM_DEFINE_DEFAULT_COPY_MOVE_AND_ASSIGN

#define TVM_DEFINE_DEFAULT_COPY_MOVE_AND_ASSIGN (   TypeName)
Value:
TypeName(const TypeName& other) = default; \
TypeName(TypeName&& other) = default; \
TypeName& operator=(const TypeName& other) = default; \
TypeName& operator=(TypeName&& other) = default;

◆ TVM_DEFINE_MUTABLE_NOTNULLABLE_OBJECT_REF_METHODS

#define TVM_DEFINE_MUTABLE_NOTNULLABLE_OBJECT_REF_METHODS    TVM_FFI_DEFINE_MUTABLE_NOTNULLABLE_OBJECT_REF_METHODS

◆ TVM_DEFINE_MUTABLE_OBJECT_REF_METHODS

#define TVM_DEFINE_MUTABLE_OBJECT_REF_METHODS   TVM_FFI_DEFINE_MUTABLE_OBJECT_REF_METHODS

◆ TVM_DEFINE_NOTNULLABLE_OBJECT_REF_METHODS

#define TVM_DEFINE_NOTNULLABLE_OBJECT_REF_METHODS   TVM_FFI_DEFINE_NOTNULLABLE_OBJECT_REF_METHODS

◆ TVM_DEFINE_OBJECT_REF_COW_METHOD

#define TVM_DEFINE_OBJECT_REF_COW_METHOD (   ObjectName)
Value:
static_assert(ObjectName::_type_final, \
"TVM's CopyOnWrite may only be used for " \
"Object types that are declared as final, " \
"using the TVM_DECLARE_FINAL_OBJECT_INFO macro."); \
ObjectName* CopyOnWrite() { \
ICHECK(data_ != nullptr); \
if (!data_.unique()) { \
auto n = make_object<ObjectName>(*(operator->())); \
ObjectPtr<Object>(std::move(n)).swap(data_); \
} \
return static_cast<ObjectName*>(data_.get()); \
}

Define CopyOnWrite function in an ObjectRef.

Parameters
ObjectNameThe Type of the Node.

CopyOnWrite will generate a unique copy of the internal node. The node will be copied if it is referenced by multiple places. The function returns the raw pointer to the node to allow modification of the content.

MyCOWObjectRef ref, ref2;
ref2 = ref;
ref.CopyOnWrite()->value = new_value;
assert(ref2->value == old_value);
assert(ref->value == new_value);

◆ TVM_DEFINE_OBJECT_REF_METHODS

#define TVM_DEFINE_OBJECT_REF_METHODS   TVM_FFI_DEFINE_OBJECT_REF_METHODS

◆ TVM_DEFINE_OBJECT_REF_METHODS_WITHOUT_DEFAULT_CONSTRUCTOR

#define TVM_DEFINE_OBJECT_REF_METHODS_WITHOUT_DEFAULT_CONSTRUCTOR (   TypeName,
  ParentType,
  ObjectName 
)
Value:
explicit TypeName(::tvm::ffi::ObjectPtr<::tvm::ffi::Object> n) : ParentType(n) {} \
TVM_DEFINE_DEFAULT_COPY_MOVE_AND_ASSIGN(TypeName); \
const ObjectName* operator->() const { return static_cast<const ObjectName*>(data_.get()); } \
const ObjectName* get() const { return operator->(); } \
using ContainerType = ObjectName;

◆ TVM_STR_CONCAT

#define TVM_STR_CONCAT (   __x,
  __y 
)    TVM_STR_CONCAT_(__x, __y)

◆ TVM_STR_CONCAT_

#define TVM_STR_CONCAT_ (   __x,
  __y 
)    __x##__y