ONE - On-device Neural Engine
|
Class that owns objects and maps them with indices as a handle for them. More...
#include <ObjectManager.h>
Public Member Functions | |
ObjectManager () | |
template<class... Args> | |
Index | emplace (Args &&...args) |
Create an object with args and put it in the container with a newly assigned Index . | |
Index | push (std::unique_ptr< Object > &&object, Index index) |
Put the object in the container with given index. | |
Index | push (std::unique_ptr< Object > &&object) |
Put the object in the container with a newly assigned index. | |
Index | set (Index index, std::unique_ptr< Object > &&object) |
Set the object in the container with given index. | |
void | remove (const Index &index) |
Remove the object that is associated with the given index. | |
const Object & | at (const Index &index) const |
Get the object that is associated with the given index. | |
Object & | at (const Index &index) |
Get the object that is associated with the given index. | |
const Object * | getRawPtr (const Index &index) const |
Get the object that is associated with the given index. | |
Object * | getRawPtr (const Index &index) |
Get the object that is associated with the given index. | |
bool | exist (const Index &index) const |
Get the object that is associated with the given index. | |
size_t | size () const |
Return the number of objects that the manager contains. | |
void | iterate (const std::function< void(const Index &, const Object &)> &fn) const |
Iterate over the container with given function. | |
void | iterate (const std::function< void(const Index &, Object &)> &fn) |
Iterate over the container with given function. | |
Protected Attributes | |
std::unordered_map< Index, std::unique_ptr< Object > > | _objects |
uint32_t | _next_index |
Class that owns objects and maps them with indices as a handle for them.
Definition at line 37 of file ObjectManager.h.
|
inline |
Definition at line 40 of file ObjectManager.h.
|
inline |
Get the object that is associated with the given index.
If such object does not exist, it will throw std::out_of_range
[in] | index | Index of the object to be returned |
Definition at line 130 of file ObjectManager.h.
References onert::util::ObjectManager< Index, Object >::_objects.
|
inline |
Get the object that is associated with the given index.
If such object does not exist, it will throw std::out_of_range
[in] | index | Index of the object to be returned |
Definition at line 121 of file ObjectManager.h.
References onert::util::ObjectManager< Index, Object >::_objects.
Referenced by onert::ir::train::TrainableGraph::btopolSortOperations(), onert::exec::DataflowExecutor::calculateRank(), onert::compiler::pass::ConstantOutputPass::callback(), onert::compiler::pass::PermutationInsertionPass::callback(), onert::compiler::pass::ConstantInsertionPass::callback(), onert::compiler::pass::ConstantLoweringPass::callback(), onert::compiler::train::pass::TrainableConstantInsertionPass::callback(), onert::ir::train::TrainableGraph::changeBackwardShape(), onert::ir::Graph::changeShape(), onert::backend::acl_common::AclConstantInitializer::copyInputInitialize(), onert::ir::train::TrainableGraph::disableBackward(), onert::ir::train::TrainableGraph::enableBackward(), onert::backend::acl_cl::KernelGenerator::generate(), onert::backend::acl_neon::KernelGenerator::generate(), onert::backend::ruy::KernelGenerator::generate(), onert::backend::builtin::KernelGenerator::generate(), onert::backend::trix::KernelGenerator::generate(), onert::exec::TracingObserver::handleJobBegin(), onert::exec::ProfileObserver::handleJobEnd(), onert::exec::TracingObserver::handleJobEnd(), onert::exec::MinMaxRecorder::handleJobEnd(), onert::compiler::StaticShapeInferer::infer(), onert::backend::cl_common::BackendContext< T_TensorBuilder, T_ConstantInitializer, T_KernelGenerator >::initConsts(), onert::backend::basic::initConsts(), onert::backend::basic::initSharedMemoryConsts(), onert::backend::acl_common::kernelGenFullyConnected(), onert::backend::acl_common::kernelGenLSTM(), onert::backend::acl_common::kernelGenPool2D(), onert::loader::BaseLoader< LoaderDomain >::loadOperand(), onert::ir::train::TrainableGraph::operation(), onert::backend::train::TensorPlanner::planBackPropTensors(), onert::backend::train::TensorPlanner::planGradientTensors(), onert::backend::train::TensorPlanner::planNonConstTensors(), onert::backend::cl_common::BackendContext< T_TensorBuilder, T_ConstantInitializer, T_KernelGenerator >::planTensors(), onert::ir::Graph::replaceOperation(), onert::backend::acl_common::AclConstantInitializer::run(), onert::compiler::train::pass::LossInsertionPass::run(), onert::compiler::pass::OddOutputPass::run(), onert::ir::Graph::setOperandValue(), onert::ir::Graph::topolSortOperations(), onert::ir::train::TrainableGraph::truncateBackwardOrder(), onert::backend::acl_common::AclConstantInitializer::visit(), onert::backend::acl_common::AclSubTensorAnalyzer::visit(), onert::backend::acl_cl::ConstantInitializer::visit(), onert::backend::acl_cl::ConstantInitializer::visit(), onert::backend::acl_neon::ConstantInitializer::visit(), onert::backend::train::KernelGenerator::visit(), onert::backend::train::KernelGenerator::visit(), onert::backend::train::KernelGenerator::visit(), onert::ir::OperationValidator::visit(), onert::ir::OperationValidator::visit(), and onert::ir::train::UseDefGenerator::visit().
|
inline |
Create an object with args and put it in the container with a newly assigned Index
.
[in] | args | Arguments for creating Operand object |
Definition at line 49 of file ObjectManager.h.
References onert::util::ObjectManager< Index, Object >::_objects.
Referenced by onert::ir::Graph::addOperand(), and onert::compiler::pass::ConstantInsertionPass::callback().
|
inline |
Get the object that is associated with the given index.
[in] | index | Index of the object to be returned |
Definition at line 169 of file ObjectManager.h.
References onert::util::ObjectManager< Index, Object >::_objects.
Referenced by onert::ir::train::TrainableGraph::changeBackwardShape(), onert::ir::Graph::changeShape(), onert::ir::Graph::replaceOperation(), and onert::ir::Graph::setOperandValue().
|
inline |
Get the object that is associated with the given index.
If such object does not exist, it will return nullptr
[in] | index | Index of the object to be returned |
Definition at line 158 of file ObjectManager.h.
References onert::util::ObjectManager< Index, Object >::getRawPtr().
|
inline |
Get the object that is associated with the given index.
If such object does not exist, it will return nullptr
[in] | index | Index of the object to be returned |
Definition at line 139 of file ObjectManager.h.
References onert::util::ObjectManager< Index, Object >::_objects.
Referenced by onert::util::ObjectManager< Index, Object >::getRawPtr().
|
inline |
Iterate over the container with given function.
[in] | fn | Function to be run for every container entry |
Definition at line 186 of file ObjectManager.h.
References onert::util::ObjectManager< Index, Object >::_objects.
Referenced by onert::ir::train::TrainableGraph::btopolSortOperations(), onert::compiler::StaticShapeInferer::dump(), onert::backend::train::BackendContext::gen(), onert::backend::builtin::train::BackendContext::gen(), onert::backend::acl_common::AclBackendContext< T_TensorBuilder, T_ConstantInitializer, T_KernelGenerator, T_Optimizer >::genTensors(), onert::backend::basic::train::genTensors(), onert::backend::basic::initConsts(), onert::backend::basic::initSharedMemoryConsts(), onert::backend::train::KernelGenerator::KernelGenerator(), onert::compiler::ShapeValidator::operator()(), onert::ir::OperationValidator::operator()(), onert::backend::acl_cl::Optimizer::optimize(), onert::backend::acl_neon::Optimizer::optimize(), onert::backend::train::TensorPlanner::planBackPropTensors(), onert::compiler::pass::OperationPass::run(), onert::compiler::pass::UnusedOperandEliminationPass::run(), onert::compiler::pass::OperandPass::run(), onert::compiler::HEScheduler::schedule(), onert::ir::Graph::topolSortOperations(), onert::ir::train::TrainableGraph::TrainableGraph(), and onert::ir::train::TrainableGraph::verify().
|
inline |
Iterate over the container with given function.
[in] | fn | Function to be run for every container entry |
Definition at line 199 of file ObjectManager.h.
References onert::util::ObjectManager< Index, Object >::_objects.
|
inline |
Put the object in the container with a newly assigned index.
It fails when it cannot generate a valid index.
[in] | object | Object to be pushed |
Definition at line 82 of file ObjectManager.h.
References onert::util::ObjectManager< Index, Object >::_objects.
|
inline |
Put the object in the container with given index.
It fails when the given index is already taken or index
is Undefined.
[in] | object | Object to be pushed |
[in] | index | Index associated with the object |
index
if successful, an Undefined index otherwise Definition at line 67 of file ObjectManager.h.
References onert::util::ObjectManager< Index, Object >::_objects.
Referenced by onert::ir::train::TrainableGraph::addBackwardOperand(), onert::ir::Graph::addOperand(), onert::ir::Graph::addOperation(), onert::ir::Graph::addOperation(), and onert::compiler::pass::ConstantOutputPass::callback().
|
inline |
Remove the object that is associated with the given index.
[in] | index | Index of the object to be removed |
Definition at line 111 of file ObjectManager.h.
References onert::util::ObjectManager< Index, Object >::_objects.
Referenced by onert::ir::Graph::removeOperand(), and onert::compiler::pass::UnusedOperandEliminationPass::run().
|
inline |
Set the object in the container with given index.
If the index is Undefined, it will fail. If the index is already taken, it will overwrite the content.
[in] | object | Object to be pushed |
[in] | index | Index associated with the object |
index
if successful, an Undefined index otherwise Definition at line 99 of file ObjectManager.h.
References onert::util::ObjectManager< Index, Object >::_objects.
Referenced by onert::ir::Graph::replaceOperation().
|
inline |
Return the number of objects that the manager contains.
Definition at line 179 of file ObjectManager.h.
References onert::util::ObjectManager< Index, Object >::_objects.
Referenced by nnfw_session::train_get_traininfo().
|
protected |
Definition at line 249 of file ObjectManager.h.
|
protected |
Definition at line 248 of file ObjectManager.h.
Referenced by onert::util::ObjectManager< Index, Object >::at(), onert::util::ObjectManager< Index, Object >::at(), onert::util::ObjectManager< Index, Object >::emplace(), onert::util::ObjectManager< Index, Object >::exist(), onert::util::ObjectManager< Index, Object >::getRawPtr(), onert::util::ObjectManager< Index, Object >::iterate(), onert::util::ObjectManager< Index, Object >::iterate(), onert::util::ObjectManager< Index, Object >::push(), onert::util::ObjectManager< Index, Object >::push(), onert::util::ObjectManager< Index, Object >::remove(), onert::util::ObjectManager< Index, Object >::set(), and onert::util::ObjectManager< Index, Object >::size().