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();
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 <<
")";
101std::vector<int32_t>
Reader::outputs(const ::circle::Operator *op)
const
118 _subgraph_index = sgindex;
120 _operators =
nullptr;
125 if (_subgraphs->
size() <= 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();
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)
loco::GraphInputIndex index(const TFPlaceholder *node)