17#include "mio_circle/Reader.h"
18#include "mio_circle/Helper.h"
32 throw std::runtime_error(
"Invalid model");
35 _version = model->version();
36 _subgraphs = model->subgraphs();
37 _buffers = model->buffers();
38 _metadata = model->metadata();
39 _signature_defs = model->signature_defs();
41 auto opcodes = model->operator_codes();
42 for (const ::circle::OperatorCode *opcode : *
opcodes)
44 _op_codes.push_back(opcode);
50 if (buff_data !=
nullptr)
58 if (
auto *buffer = (*_buffers)[buf_idx])
60 if (
auto *array = buffer->data())
62 if (
size_t size = array->size())
64 if (buff_data !=
nullptr)
66 *buff_data =
reinterpret_cast<const uint8_t *
>(array->data());
78 uint32_t index = op->opcode_index();
79 assert(index < _op_codes.size());
80 const ::circle::OperatorCode *opcode = _op_codes.at(index);
87 uint32_t index = op->opcode_index();
88 assert(index < _op_codes.size());
89 const ::circle::OperatorCode *opcode = _op_codes.at(index);
93 std::ostringstream oss;
94 oss <<
"(invalid: " << index <<
")";
118 _subgraph_index = sgindex;
120 _operators =
nullptr;
125 if (_subgraphs->Length() <= sgindex)
131 const ::circle::SubGraph *subgraph = (*_subgraphs)[sgindex];
133 auto name = subgraph->name();
134 _subgraph_name = name ? name->c_str() :
"(noname)";
136 _tensors = subgraph->tensors();
137 _operators = subgraph->operators();
138 _data_format = subgraph->data_format();
const std::vector< const ::circle::OperatorCode * > & opcodes()
std::string opcode_name(const ::circle::Operator *op) const
const std::vector< int32_t > & outputs() const
std::string tensor_name(const ::circle::Tensor *tensor) const
size_t buffer_info(uint32_t buf_idx, const uint8_t **buff_data)
std::string tensor_dtype(const ::circle::Tensor *tensor) const
::circle::BuiltinOperator builtin_code(const ::circle::Operator *op) const
bool select_subgraph(uint32_t subgraph)
const char * tensor_name(const ::circle::Tensor *tensor)
std::string opcode_name(const ::circle::OperatorCode *opcode)
std::vector< T > as_index_vector(const flatbuffers::Vector< T > *flat_array)
const char * tensor_type(const ::circle::Tensor *tensor)
bool is_valid(const ::circle::OperatorCode *opcode)
::circle::BuiltinOperator builtin_code_neutral(const ::circle::OperatorCode *opcode)