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_FFI_DEFINE_OBJECT_REF_METHODS_NULLABLE_WITHOUT_DEFAULT_CONSTRUCTOR( TypeName, ParentType, ObjectName)
 
#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::kRuntimeTensor = TVMFFITypeIndex::kTVMFFITensor , 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_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_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_FFI_DECLARE_OBJECT_INFO_FINAL macro."); \
ObjectName* CopyOnWrite() { \
ICHECK(data_ != nullptr); \
if (!data_.unique()) { \
auto n = ::tvm::ffi::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_FFI_DEFINE_OBJECT_REF_METHODS_NULLABLE_WITHOUT_DEFAULT_CONSTRUCTOR

#define TVM_FFI_DEFINE_OBJECT_REF_METHODS_NULLABLE_WITHOUT_DEFAULT_CONSTRUCTOR (   TypeName,
  ParentType,
  ObjectName 
)
Value:
explicit TypeName(::tvm::ffi::ObjectPtr<ObjectName> 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