24 #ifndef TVM_RUNTIME_CONTAINER_ADT_H_
25 #define TVM_RUNTIME_CONTAINER_ADT_H_
45 static constexpr
const char*
_type_key =
"runtime.ADT";
52 size_t GetSize()
const {
return size; }
61 template <
typename Iterator>
62 void Init(Iterator begin, Iterator end) {
63 size_t num_elems = std::distance(begin, end);
66 for (
size_t i = 0; i < num_elems; ++i) {
85 ADT(int32_t
tag, std::vector<ObjectRef> fields) :
ADT(
tag, fields.begin(), fields.end()){};
93 template <
typename Iterator>
94 ADT(int32_t
tag, Iterator begin, Iterator end) {
95 size_t num_elems = std::distance(begin, end);
96 auto ptr = make_inplace_array_object<ADTObj, ObjectRef>(num_elems);
98 ptr->Init(begin, end);
99 data_ = std::move(ptr);
107 ADT(int32_t
tag, std::initializer_list<ObjectRef> init) :
ADT(
tag, init.begin(), init.end()){};
134 template <
typename... Args>
136 return ADT(0, std::forward<Args>(args)...);
An object representing a structure or enumeration.
Definition: adt.h:36
uint32_t size
Number of fields in the ADT object.
Definition: adt.h:41
int32_t tag
The tag representing the constructor used.
Definition: adt.h:39
static constexpr const char * _type_key
Definition: adt.h:45
TVM_DECLARE_FINAL_OBJECT_INFO(ADTObj, Object)
static constexpr const uint32_t _type_index
Definition: adt.h:44
reference to algebraic data type objects.
Definition: adt.h:78
ADT(int32_t tag, std::vector< ObjectRef > fields)
construct an ADT object reference.
Definition: adt.h:85
TVM_DEFINE_OBJECT_REF_METHODS(ADT, ObjectRef, ADTObj)
static ADT Tuple(Args &&... args)
Construct a tuple object.
Definition: adt.h:135
const ObjectRef & operator[](size_t idx) const
Access element at index.
Definition: adt.h:115
ADT(int32_t tag, std::initializer_list< ObjectRef > init)
construct an ADT object reference.
Definition: adt.h:107
int32_t tag() const
Return the ADT tag.
Definition: adt.h:120
ADT(int32_t tag, Iterator begin, Iterator end)
construct an ADT object reference.
Definition: adt.h:94
size_t size() const
Return the number of fields.
Definition: adt.h:125
Base template for classes with array like memory layout.
Definition: base.h:100
void EmplaceInit(size_t idx, Args &&... args)
Construct a value in place with the arguments.
Definition: base.h:149
Base class of all object reference.
Definition: object.h:519
const Object * operator->() const
Definition: object.h:556
ObjectPtr< Object > data_
Internal pointer that backs the reference.
Definition: object.h:605
base class of all object containers.
Definition: object.h:171
runtime implementation for LibTorch/TorchScript.
Definition: analyzer.h:36
@ kRuntimeADT
Definition: object.h:81