24 #ifndef TVM_RUNTIME_CONTAINER_SHAPE_TUPLE_H_
25 #define TVM_RUNTIME_CONTAINER_SHAPE_TUPLE_H_
46 static constexpr
const char*
_type_key =
"runtime.ShapeTuple";
69 explicit FromStd(std::vector<index_type> other) : data_container{other} {}
73 std::vector<index_type> data_container;
97 template <
typename IterType>
136 ICHECK(idx < this->
size()) <<
"IndexError: indexing " << idx <<
" on an array of size "
138 return this->
data()[idx];
167 auto ptr = make_object<ShapeTupleObj::FromStd>(std::move(
shape));
168 ptr->size = ptr->data_container.size();
169 ptr->data = ptr->data_container.data();
170 data_ = std::move(ptr);
Base class of all object reference.
Definition: object.h:517
const Object * get() const
Definition: object.h:552
ObjectPtr< Object > data_
Internal pointer that backs the reference.
Definition: object.h:603
base class of all object containers.
Definition: object.h:169
An object representing shape tuple moved from std::vector.
Definition: shape_tuple.h:57
FromStd(std::vector< index_type > other)
Construct a new FromStd object.
Definition: shape_tuple.h:69
ShapeTupleObj::index_type index_type
The type of shape index element.
Definition: shape_tuple.h:60
An object representing a shape tuple.
Definition: shape_tuple.h:36
index_type * data
The pointer to shape tuple data.
Definition: shape_tuple.h:41
int64_t index_type
The type of shape index element.
Definition: shape_tuple.h:39
TVM_DECLARE_FINAL_OBJECT_INFO(ShapeTupleObj, Object)
uint64_t size
The size of the shape tuple object.
Definition: shape_tuple.h:43
static constexpr const uint32_t _type_index
Definition: shape_tuple.h:45
static constexpr const char * _type_key
Definition: shape_tuple.h:46
Reference to shape tuple objects.
Definition: shape_tuple.h:81
index_type at(size_t idx) const
Immutably read i-th element from the shape tuple.
Definition: shape_tuple.h:146
const index_type * data() const
Return the data pointer.
Definition: shape_tuple.h:121
index_type back() const
Definition: shape_tuple.h:155
index_type operator[](size_t idx) const
Immutably read i-th element from the shape tuple.
Definition: shape_tuple.h:135
size_t size() const
Return the size of the shape tuple.
Definition: shape_tuple.h:128
ShapeTuple(IterType begin, IterType end)
Constructor from iterator.
Definition: shape_tuple.h:98
ShapeTuple(std::initializer_list< index_type > shape)
constructor from initializer list
Definition: shape_tuple.h:104
bool empty() const
Definition: shape_tuple.h:149
const index_type * begin() const
Definition: shape_tuple.h:158
ShapeTuple()
Construct an empty shape tuple.
Definition: shape_tuple.h:89
const index_type * end() const
Definition: shape_tuple.h:161
TVM_DEFINE_NOTNULLABLE_OBJECT_REF_METHODS(ShapeTuple, ObjectRef, ShapeTupleObj)
ShapeTupleObj::index_type index_type
The type of shape index element.
Definition: shape_tuple.h:84
index_type front() const
Definition: shape_tuple.h:152
Tensor shape(const Tensor &src, DataType dtype, const std::string name="T_shape", const std::string tag=kInjective)
Get the shape of input tensor.
Definition: transform.h:1766
runtime implementation for LibTorch/TorchScript.
Definition: analyzer.h:36
@ kRuntimeShapeTuple
runtime::ShapeTuple.
Definition: object.h:72