24 #ifndef TVM_RUNTIME_METADATA_BASE_H_ 25 #define TVM_RUNTIME_METADATA_BASE_H_ 49 static constexpr
const char*
_type_key =
"metadata.MetadataBaseNode";
59 template <
typename C,
class Ref>
63 template <
typename C,
class Ref>
67 : index_{index}, parent_{parent} {}
69 inline Ref
operator*() {
return (*parent_)[index_]; }
72 if (index_ < parent_->size()) {
80 return parent_ == other.parent_ && index_ == other.index_;
94 template <
typename C,
class Ref>
101 template <typename T = typename std::enable_if<std::is_base_of<ObjectRef, Ref>::value>::type>
102 ArrayAccessor(
const C* data,
size_t num_data) : data_{data}, num_data_{num_data} {}
104 inline size_t size()
const {
return num_data_; }
107 if (index >= num_data_) {
108 throw std::runtime_error(
"Index out of range");
111 return Ref(&data_[index]);
134 ArrayAccessor(
const char** data,
size_t num_data) : data_{data}, num_data_{num_data} {}
136 inline size_t size()
const {
return num_data_; }
138 inline ::tvm::runtime::String
operator[](
size_t index)
const {
139 if (index >= num_data_) {
140 throw std::runtime_error(
"Index out of range");
142 return ::tvm::runtime::String(data_[index]);
179 : array(::
std::move(array)), kind{kind}, type_key{type_key} {}
185 <<
"cannot get struct name for MetadataArray with kind=" << kind;
186 constexpr
int prefix_size =
sizeof(
"metadata.") - 1;
187 constexpr
int suffix_size =
sizeof(
"Node") - 1;
188 std::string type_key_str(type_key);
189 return std::string(
"TVM") +
190 type_key_str.substr(prefix_size, type_key_str.size() - prefix_size - suffix_size);
201 static constexpr
const char*
_type_key =
"metadata.MetadataArrayNode";
217 #endif // TVM_RUNTIME_METADATA_BASE_H_
runtime implementation for LibTorch/TorchScript.
Definition: analyzer.h:36
Definition: loop_state.h:456
base class of all object containers.
Definition: object.h:167
#define TVM_DEFINE_MUTABLE_OBJECT_REF_METHODS(TypeName, ParentType, ObjectName)
Definition: object.h:744
Array, container representing a contiguous sequence of ObjectRefs.
Definition: array.h:289
Reference to string objects.
Definition: string.h:97
Base class of all object reference.
Definition: object.h:511
A managed object in the TVM runtime.
bool operator==(const String &lhs, const std::string &rhs)
Definition: string.h:407