ONE - On-device Neural Engine
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
onert::exec::LinearExecutor Class Referencefinal

Class to handle execution phase. Simple run the sequence of operations that is sorted in topological order. More...

#include <LinearExecutor.h>

Collaboration diagram for onert::exec::LinearExecutor:

Public Member Functions

 LinearExecutor (std::unique_ptr< compiler::LoweredGraph > lowered_graph, backend::BackendContexts &&backend_contexts, const compiler::TensorRegistries &tensor_regs, compiler::CodeMap &&code_map, const std::vector< ir::OperationIndex > &order, const util::TracingCtx *tracing_ctx)
 Construct a new LinearExecutor object.
 
void executeImpl (const ExecutionObservee &subject) override
 
- Public Member Functions inherited from onert::exec::ExecutorBase
 ExecutorBase (std::unique_ptr< compiler::LoweredGraph > &&lowered_graph, backend::BackendContexts &&backend_contexts, const compiler::TensorRegistries &tensor_regs, const util::TracingCtx *tracing_ctx)
 Construct a new ExecutorBase object.
 
virtual ~ExecutorBase ()=default
 
const ir::Graphgraph () const final
 Returns graph object.
 
void execute (const std::vector< backend::IPortableTensor * > &inputs, const std::vector< backend::IPortableTensor * > &outputs, const ExecutionOptions &options) override
 Execute with given input/output tensors.
 
uint32_t inputSize () const override
 Get input size.
 
uint32_t outputSize () const override
 Get output size.
 
const ir::OperandInfoinputInfo (uint32_t index) const override
 Get input info at index.
 
const ir::OperandInfooutputInfo (uint32_t index) const override
 Get output info at index.
 
ir::Layout inputLayout (uint32_t index) const override
 Get input layout at index.
 
ir::Layout outputLayout (uint32_t index) const override
 Get output layout at index.
 
void setIndexedRanks (std::shared_ptr< ir::OperationIndexMap< int64_t > > ranks) final
 Set an ordering on operations.
 
void addObserver (std::unique_ptr< IExecutionObserver > ref)
 
backend::BackendContextsgetBackendContexts ()
 
const ExecutionOptionscurrentOptions () const override
 Return current execution configuration.
 
- Public Member Functions inherited from onert::exec::IExecutor
 IExecutor ()=default
 Construct a new IExecutor object.
 
virtual ~IExecutor ()=default
 Destroy the IExecutor object.
 

Additional Inherited Members

- Protected Member Functions inherited from onert::exec::ExecutorBase
bool hasDynamicInput ()
 Returns true if any input tensor is dynamic; false if all are static tensors.
 
- Protected Attributes inherited from onert::exec::ExecutorBase
ExecObservers _observers
 
std::shared_ptr< ir::OperationIndexMap< int64_t > > _indexed_ranks
 
std::unique_ptr< compiler::LoweredGraph_lowered_graph
 
backend::BackendContexts _backend_contexts
 
const ir::Graph_graph
 
std::vector< backend::builtin::IOTensor * > _input_tensors
 
std::vector< backend::builtin::IOTensor * > _output_tensors
 
std::mutex _mutex
 
const util::TracingCtx_tracing_ctx
 
ExecutionOptions _current_options
 

Detailed Description

Class to handle execution phase. Simple run the sequence of operations that is sorted in topological order.

Definition at line 38 of file LinearExecutor.h.

Constructor & Destructor Documentation

◆ LinearExecutor()

onert::exec::LinearExecutor::LinearExecutor ( std::unique_ptr< compiler::LoweredGraph lowered_graph,
backend::BackendContexts &&  backend_contexts,
const compiler::TensorRegistries tensor_regs,
compiler::CodeMap &&  code_map,
const std::vector< ir::OperationIndex > &  order,
const util::TracingCtx tracing_ctx 
)
inline

Construct a new LinearExecutor object.

Parameters
lowered_graphLoweredGraph object
tensor_buildersTensor builders that are currently used
code_mapir::Operation and its code map

Definition at line 47 of file LinearExecutor.h.

51 : ExecutorBase{std::move(lowered_graph), std::move(backend_contexts), tensor_regs, tracing_ctx}
52 {
53 for (auto &&index : order)
54 {
55 _code.emplace_back(std::move(code_map.at(index)));
56 }
57 }
ExecutorBase(std::unique_ptr< compiler::LoweredGraph > &&lowered_graph, backend::BackendContexts &&backend_contexts, const compiler::TensorRegistries &tensor_regs, const util::TracingCtx *tracing_ctx)
Construct a new ExecutorBase object.

Member Function Documentation

◆ executeImpl()

void onert::exec::LinearExecutor::executeImpl ( const ExecutionObservee subject)
overridevirtual

Implements onert::exec::ExecutorBase.

Definition at line 25 of file LinearExecutor.cc.

26{
27 if (!subject.isEmpty() && _tracing_ctx)
28 {
29 auto profiling_subg_index = _tracing_ctx->getSubgraphIndex(&_graph);
30
31 subject.notifySubgraphBegin(profiling_subg_index);
32 for (auto &&code : _code)
33 {
34 const auto backend = code.op_backend;
35// TODO : Move ruy profiler into ExecutionObserver
36#ifdef RUY_PROFILER
37 ruy::profiler::ScopeLabel label(code.op->name());
38#endif
39 subject.notifyJobBegin(this, profiling_subg_index, code.op_ind, backend);
40
41 auto &fn_seq = code.fn_seq;
42
43 fn_seq->initRunning();
44
45 bool handle_dynamic_tensor =
46 _lowered_graph->getHasDynamicTensor(code.op_ind) || hasDynamicInput();
47 fn_seq->enableDynamicShapeInferer(handle_dynamic_tensor);
48 fn_seq->run();
49
50 subject.notifyJobEnd(this, profiling_subg_index, code.op_ind, backend);
51 }
52 subject.notifySubgraphEnd(profiling_subg_index);
53 }
54 else
55 {
56 for (auto &&code : _code)
57 {
58// TODO : Move ruy profiler into ExecutionObserver
59#ifdef RUY_PROFILER
60 ruy::profiler::ScopeLabel label(code.op->name());
61#endif
62
63 auto &fn_seq = code.fn_seq;
64
65 fn_seq->initRunning();
66
67 bool handle_dynamic_tensor =
68 _lowered_graph->getHasDynamicTensor(code.op_ind) || hasDynamicInput();
69 fn_seq->enableDynamicShapeInferer(handle_dynamic_tensor);
70 fn_seq->run();
71 }
72 }
73}
std::unique_ptr< compiler::LoweredGraph > _lowered_graph
bool hasDynamicInput()
Returns true if any input tensor is dynamic; false if all are static tensors.
const util::TracingCtx * _tracing_ctx
const ir::Graph & _graph
ir::SubgraphIndex getSubgraphIndex(const ir::Graph *g) const
Get subgraph index of a graph.
Definition TracingCtx.h:59
Code * code(const SessionID &sess)
Definition Session.cpp:54

References onert::exec::ExecutorBase::_graph, onert::exec::ExecutorBase::_lowered_graph, onert::exec::ExecutorBase::_tracing_ctx, onert::util::TracingCtx::getSubgraphIndex(), onert::exec::ExecutorBase::hasDynamicInput(), onert::exec::ExecutionObservee::isEmpty(), onert::exec::ExecutionObservee::notifyJobBegin(), onert::exec::ExecutionObservee::notifyJobEnd(), onert::exec::ExecutionObservee::notifySubgraphBegin(), and onert::exec::ExecutionObservee::notifySubgraphEnd().


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