ONE - On-device Neural Engine
Loading...
Searching...
No Matches
onert::ir::Model Class Reference

#include <Model.h>

Public Member Functions

 Model ()=default
 
 Model (const Model &obj)=default
 
 Model (Model &&)=default
 
Modeloperator= (const Model &)=default
 
Modeloperator= (Model &&)=default
 
 ~Model ()=default
 
void push (SubgraphIndex index, const std::shared_ptr< IGraph > &subg)
 Put subgraph in the container with a new Index for that.
 
void remove (const SubgraphIndex &index)
 Remove the subgraph that is associated with the given index.
 
const std::shared_ptr< IGraph > & at (const SubgraphIndex &index) const
 Get the subgraph that is associated with the given index.
 
std::shared_ptr< IGraph > & at (const SubgraphIndex &index)
 Get the subgraph that is associated with the given index.
 
bool exist (const SubgraphIndex &index) const
 Get the subgraph that is associated with the given index.
 
void iterate (const std::function< void(const SubgraphIndex &, const IGraph &)> &fn) const
 Iterate over the container with given function.
 
void iterate (const std::function< void(const SubgraphIndex &, IGraph &)> &fn)
 Iterate over the container with given function.
 
size_t subgraphs_count () const
 Get count of Subgraphs.
 
std::shared_ptr< IGraphprimary_subgraph () const
 Return the primary subgraph.
 
template<typename Graph , std::enable_if_t< std::is_base_of< IGraph, Graph >::value, bool > = true>
bool hasOnly ()
 Return whether the model has only typename Graph.
 
void bindKernelBuilder (const std::shared_ptr< onert::backend::custom::IKernelBuilder > &kernel_builder)
 
const std::shared_ptr< backend::custom::IKernelBuilder > & getKernelBuilder () const
 
void add_metadata (const std::string &name, std::unique_ptr< const ir::Data > data)
 
bool exists_metadata (const std::string &name) const
 
std::unique_ptr< const ir::Dataextract_metadata (const std::string name)
 

Detailed Description

Definition at line 43 of file Model.h.

Constructor & Destructor Documentation

◆ Model() [1/3]

onert::ir::Model::Model ( )
default

◆ Model() [2/3]

onert::ir::Model::Model ( const Model obj)
default

◆ Model() [3/3]

onert::ir::Model::Model ( Model &&  )
default

◆ ~Model()

onert::ir::Model::~Model ( )
default

Member Function Documentation

◆ add_metadata()

void onert::ir::Model::add_metadata ( const std::string &  name,
std::unique_ptr< const ir::Data data 
)
inline

Definition at line 180 of file Model.h.

181 {
182 _metadatas.emplace(name, std::move(data));
183 }

◆ at() [1/2]

std::shared_ptr< IGraph > & onert::ir::Model::at ( const SubgraphIndex index)
inline

Get the subgraph that is associated with the given index.

Parameters
[in]indexIndex of the subgraph to be returned
Returns
IGraph

Definition at line 86 of file Model.h.

86{ return _subgraphs.at(index); }

◆ at() [2/2]

const std::shared_ptr< IGraph > & onert::ir::Model::at ( const SubgraphIndex index) const
inline

Get the subgraph that is associated with the given index.

Parameters
[in]indexIndex of the subgraph to be returned
Returns
IGraph

Definition at line 76 of file Model.h.

77 {
78 return _subgraphs.at(index);
79 }

◆ bindKernelBuilder()

void onert::ir::Model::bindKernelBuilder ( const std::shared_ptr< onert::backend::custom::IKernelBuilder > &  kernel_builder)
inline

Definition at line 166 of file Model.h.

167 {
168 _kernel_builder = kernel_builder;
169 }

◆ exist()

bool onert::ir::Model::exist ( const SubgraphIndex index) const
inline

Get the subgraph that is associated with the given index.

Parameters
[in]indexIndex of the subgraph to be returned
Returns
true if such entry exists otherwise false

Definition at line 94 of file Model.h.

95 {
96 auto it = _subgraphs.find(index);
97 return it != _subgraphs.end();
98 }

◆ exists_metadata()

bool onert::ir::Model::exists_metadata ( const std::string &  name) const
inline

Definition at line 185 of file Model.h.

186 {
187 return _metadatas.find(name) != _metadatas.end();
188 }

◆ extract_metadata()

std::unique_ptr< const ir::Data > onert::ir::Model::extract_metadata ( const std::string  name)
inline

Definition at line 191 of file Model.h.

192 {
193 auto m = _metadatas.find(name);
194
195 if (m == _metadatas.end())
196 throw std::out_of_range{"no meatdata named " + name};
197
198 auto data = std::move(m->second);
199 _metadatas.erase(m);
200 return data;
201 }

References m.

◆ getKernelBuilder()

const std::shared_ptr< backend::custom::IKernelBuilder > & onert::ir::Model::getKernelBuilder ( ) const
inline

Definition at line 171 of file Model.h.

172 {
173 return _kernel_builder;
174 }

◆ hasOnly()

template<typename Graph , std::enable_if_t< std::is_base_of< IGraph, Graph >::value, bool > = true>
bool onert::ir::Model::hasOnly ( )
inline

Return whether the model has only typename Graph.

Template Parameters
GraphType that inherits from IGraph
Returns
true if the model has only typename Graph, otherwise false

Definition at line 150 of file Model.h.

151 {
152 for (const auto &e : _subgraphs)
153 {
154 if (std::dynamic_pointer_cast<Graph>(e.second) == nullptr)
155 return false;
156 }
157 return true;
158 }

◆ iterate() [1/2]

void onert::ir::Model::iterate ( const std::function< void(const SubgraphIndex &, const IGraph &)> &  fn) const
inline

Iterate over the container with given function.

Parameters
[in]fnFunction to be run for every container entry
Returns
N/A

Definition at line 106 of file Model.h.

107 {
108 for (const auto &[subg_idx, subg] : _subgraphs)
109 {
110 fn(subg_idx, *subg);
111 }
112 }

◆ iterate() [2/2]

void onert::ir::Model::iterate ( const std::function< void(const SubgraphIndex &, IGraph &)> &  fn)
inline

Iterate over the container with given function.

Parameters
[in]fnFunction to be run for every container entry
Returns
N/A

Definition at line 120 of file Model.h.

121 {
122 for (const auto &[subg_idx, subg] : _subgraphs)
123 {
124 fn(subg_idx, *subg);
125 }
126 }

◆ operator=() [1/2]

Model & onert::ir::Model::operator= ( const Model )
default

◆ operator=() [2/2]

Model & onert::ir::Model::operator= ( Model &&  )
default

◆ primary_subgraph()

std::shared_ptr< IGraph > onert::ir::Model::primary_subgraph ( ) const
inline

Return the primary subgraph.

Returns
std::shared_ptr<IGraph> Primary subgraph

Definition at line 140 of file Model.h.

140{ return _subgraphs.at(SubgraphIndex{0}); }
::onert::util::Index< uint16_t, SubgraphIndexTag > SubgraphIndex
Definition Index.h:41

◆ push()

void onert::ir::Model::push ( SubgraphIndex  index,
const std::shared_ptr< IGraph > &  subg 
)
inline

Put subgraph in the container with a new Index for that.

Parameters
[in]subgSubgraph to be pushed
[in]indexIndex of subgraph to be pushed
Returns
Created

Definition at line 60 of file Model.h.

60{ _subgraphs[index] = subg; }
loco::GraphInputIndex index(const TFPlaceholder *node)
Definition TFNode.cpp:54

◆ remove()

void onert::ir::Model::remove ( const SubgraphIndex index)
inline

Remove the subgraph that is associated with the given index.

Parameters
[in]indexIndex of the subgraph to be removed
Returns
N/A

Definition at line 68 of file Model.h.

68{ _subgraphs.erase(index); }

◆ subgraphs_count()

size_t onert::ir::Model::subgraphs_count ( ) const
inline

Get count of Subgraphs.

Returns
count of Subgraphs

Definition at line 133 of file Model.h.

133{ return _subgraphs.size(); }

The documentation for this class was generated from the following file: