std::map<uint32_t, model::OperandIndex> _tensor_to_operand;
// Mapping from operator pointer to subgraph pointer
std::map<const Operator *, const SubGraph *> _op_to_subgraph;
- // Mapping from operator code to BuiltinOperator
- std::vector<BuiltinOperator> _op_code_to_builtin_op;
- std::unordered_map<uint32_t, std::string> _opcode_index_to_custom_opcode;
const Model *_model;
};
model::OperandIndexSequence inputs;
model::OperandIndexSequence outputs;
- for (auto in_idx : *op->inputs())
- {
- inputs.append(model::OperandIndex(in_idx));
- }
-
- for (auto out_idx : *op->outputs())
- {
- outputs.append(model::OperandIndex(out_idx));
- }
+ loadOperationIO(op, inputs, outputs);
- auto custom_op_id = _opcode_index_to_custom_opcode.at(op->opcode_index());
+ auto *op_code = _model->operator_codes()->Get(op->opcode_index());
+ auto custom_op_id = op_code->custom_code()->str();
auto constraint = model::operation::OperandConstraint::createExact(inputs.size());
template <typename LoaderDomain, typename SpecificLoader>
void BaseLoader<LoaderDomain, SpecificLoader>::loadOperation(const Operator *op)
{
- const auto builtin_op = _op_code_to_builtin_op[op->opcode_index()];
+ const auto builtin_op = _model->operator_codes()->Get(op->opcode_index())->builtin_code();
switch (builtin_op)
{
_model = LoaderDomain::GetModel(_buffer.data());
// Version unused
// const auto version = _model->version();
- const auto *op_codes = _model->operator_codes();
- const auto *subgraphs = _model->subgraphs();
// Description unused
// const auto *description = _model->description();
const auto *buffers = _model->buffers();
// Metabuffer unsued
// const auto *metadata_buffer = _model->metadata_buffer();
- // Use operator codes
- for (const auto *op_code : *op_codes)
- {
- _op_code_to_builtin_op.push_back(op_code->builtin_code());
-
- if (op_code->builtin_code() == BuiltinOperator::BuiltinOperator_CUSTOM)
- {
- auto id = op_code->custom_code()->str();
- _opcode_index_to_custom_opcode[_op_code_to_builtin_op.size() - 1] = id;
- }
- // Custom code unsued
- // Version unused
- }
// Load subgraphs and mapping from op to subgraph
- for (const auto *subgraph : *subgraphs)
+ for (const auto *subgraph : *_model->subgraphs())
{
// NOTE This loop have to be called before loadOperation
for (const auto *op : *subgraph->operators())