template<typename ArrayType, typename ElemType>
class tvm::runtime::InplaceArrayBase< ArrayType, ElemType >
Base template for classes with array like memory layout.
It provides general methods to access the memory. The memory
layout is ArrayType + [ElemType]. The alignment of ArrayType
and ElemType is handled by the memory allocator.
- Template Parameters
-
ArrayType | The array header type, contains object specific metadata. |
ElemType | The type of objects stored in the array right after ArrayType. |
class ArrayObj : public InplaceArrayBase<ArrayObj, Elem> {
public:
template <typename Iterator>
void Init(Iterator begin, Iterator end) {
size_t num_elems = std::distance(begin, end);
auto it = begin;
this->size = 0;
for (size_t i = 0; i < num_elems; ++i) {
this->size++;
}
}
}
void test_function() {
vector<Elem> fields;
auto ptr = make_inplace_array_object<ArrayObj, Elem>(fields.size());
ptr->Init(fields.begin(), fields.end());
assert(ptr->operator[](0) == fields[0]);
}
void EmplaceInit(size_t idx, Args &&... args)
Construct a value in place with the arguments.
Definition: base.h:148
BlockInitFrame Init()
The block initialization statement.