17#ifndef __ONERT_IR_MODEL_H__
18#define __ONERT_IR_MODEL_H__
21#include <unordered_map>
60 void push(
SubgraphIndex index,
const std::shared_ptr<IGraph> &subg) { _subgraphs[index] = subg; }
78 return _subgraphs.at(index);
86 std::shared_ptr<IGraph> &
at(
const SubgraphIndex &index) {
return _subgraphs.at(index); }
96 auto it = _subgraphs.find(index);
97 return it != _subgraphs.end();
108 for (
const auto &[subg_idx, subg] : _subgraphs)
122 for (
const auto &[subg_idx, subg] : _subgraphs)
149 template <typename Graph, std::enable_if_t<std::is_base_of<IGraph, Graph>::value,
bool> =
true>
152 for (
const auto &e : _subgraphs)
154 if (std::dynamic_pointer_cast<Graph>(e.second) ==
nullptr)
161 std::unordered_map<SubgraphIndex, std::shared_ptr<IGraph>> _subgraphs;
166 bindKernelBuilder(
const std::shared_ptr<onert::backend::custom::IKernelBuilder> &kernel_builder)
168 _kernel_builder = kernel_builder;
173 return _kernel_builder;
177 std::shared_ptr<backend::custom::IKernelBuilder> _kernel_builder;
180 void add_metadata(
const std::string &name, std::unique_ptr<const ir::Data> data)
182 _metadatas.emplace(name, std::move(data));
187 return _metadatas.find(name) != _metadatas.end();
193 auto m = _metadatas.find(name);
195 if (
m == _metadatas.end())
196 throw std::out_of_range{
"no meatdata named " + name};
198 auto data = std::move(
m->second);
204 std::unordered_map<std::string, std::unique_ptr<const ir::Data>> _metadatas;
Model(const Model &obj)=default
std::unique_ptr< const ir::Data > extract_metadata(const std::string name)
void iterate(const std::function< void(const SubgraphIndex &, IGraph &)> &fn)
Iterate over the container with given function.
std::shared_ptr< IGraph > & at(const SubgraphIndex &index)
Get the subgraph that is associated with the given index.
std::shared_ptr< IGraph > primary_subgraph() const
Return the primary subgraph.
bool exist(const SubgraphIndex &index) const
Get the subgraph that is associated with the given index.
Model & operator=(const Model &)=default
Model & operator=(Model &&)=default
void iterate(const std::function< void(const SubgraphIndex &, const IGraph &)> &fn) const
Iterate over the container with given function.
void remove(const SubgraphIndex &index)
Remove the subgraph that is associated with the given index.
size_t subgraphs_count() const
Get count of Subgraphs.
bool hasOnly()
Return whether the model has only typename Graph.
const std::shared_ptr< backend::custom::IKernelBuilder > & getKernelBuilder() const
bool exists_metadata(const std::string &name) const
void add_metadata(const std::string &name, std::unique_ptr< const ir::Data > data)
void bindKernelBuilder(const std::shared_ptr< onert::backend::custom::IKernelBuilder > &kernel_builder)
void push(SubgraphIndex index, const std::shared_ptr< IGraph > &subg)
Put subgraph in the container with a new Index for that.
const std::shared_ptr< IGraph > & at(const SubgraphIndex &index) const
Get the subgraph that is associated with the given index.