24 #ifndef TVM_RUNTIME_METADATA_BASE_H_
25 #define TVM_RUNTIME_METADATA_BASE_H_
52 static constexpr
const char*
_type_key =
"metadata.MetadataBaseNode";
62 template <
typename C,
class Ref>
66 template <
typename C,
class Ref>
70 : index_{index}, parent_{parent} {}
72 inline Ref
operator*() {
return (*parent_)[index_]; }
75 if (index_ < parent_->size()) {
83 return parent_ == other.parent_ && index_ == other.index_;
97 template <
typename C,
class Ref>
104 template <typename T = typename std::enable_if<std::is_base_of<ObjectRef, Ref>::value>::type>
105 ArrayAccessor(
const C* data,
size_t num_data) : data_{data}, num_data_{num_data} {}
107 inline size_t size()
const {
return num_data_; }
110 if (index >= num_data_) {
111 throw std::runtime_error(
"Index out of range");
114 return Ref(&data_[index]);
137 ArrayAccessor(
const char** data,
size_t num_data) : data_{data}, num_data_{num_data} {}
139 inline size_t size()
const {
return num_data_; }
141 inline ::tvm::runtime::String
operator[](
size_t index)
const {
142 if (index >= num_data_) {
143 throw std::runtime_error(
"Index out of range");
145 return ::tvm::runtime::String(data_[index]);
188 <<
"cannot get struct name for MetadataArray with kind=" <<
kind;
189 constexpr
int prefix_size =
sizeof(
"metadata.") - 1;
190 constexpr
int suffix_size =
sizeof(
"Node") - 1;
192 return std::string(
"TVM") +
193 type_key_str.substr(prefix_size, type_key_str.size() - prefix_size - suffix_size);
204 static constexpr
const char*
_type_key =
"metadata.MetadataArrayNode";
Runtime Array container types.
Array, container representing a contiguous sequence of ObjectRefs.
Definition: array.h:289
Base class of all object reference.
Definition: object.h:519
base class of all object containers.
Definition: object.h:171
Reference to string objects.
Definition: string.h:98
runtime implementation for LibTorch/TorchScript.
Definition: analyzer.h:36
A device-independent managed NDArray abstraction.
A managed object in the TVM runtime.
Runtime String container types.