ONE - On-device Neural Engine
Loading...
Searching...
No Matches
onert::exec::ProfileObserver Class Reference

#include <ExecutionObservers.h>

Collaboration diagram for onert::exec::ProfileObserver:

Public Member Functions

 ProfileObserver (std::shared_ptr< ExecTime > et, const ir::Graph &graph)
 
void handleJobBegin (IExecutor *, std::pair< ir::ModelIndex, ir::SubgraphIndex >, ir::OperationIndex, const backend::Backend *) override
 
void handleJobEnd (IExecutor *, std::pair< ir::ModelIndex, ir::SubgraphIndex >, ir::OperationIndex, const backend::Backend *) override
 
void handleSubgraphEnd (std::pair< ir::ModelIndex, ir::SubgraphIndex >) override
 Invoked just after model (not individual operation) execution ends.
 
ObserverType type () const override
 
- Public Member Functions inherited from onert::exec::IExecutionObserver
virtual void handleSubgraphBegin (std::pair< ir::ModelIndex, ir::SubgraphIndex >)
 Invoked just before model (not individual operation) execution begins.
 
virtual ~IExecutionObserver ()=default
 

Detailed Description

Definition at line 80 of file ExecutionObservers.h.

Constructor & Destructor Documentation

◆ ProfileObserver()

onert::exec::ProfileObserver::ProfileObserver ( std::shared_ptr< ExecTime et,
const ir::Graph graph 
)
inlineexplicit

Definition at line 83 of file ExecutionObservers.h.

84 : _et(std::move(et)), _graph(graph)
85 {
86 }

Member Function Documentation

◆ handleJobBegin()

void onert::exec::ProfileObserver::handleJobBegin ( IExecutor ,
std::pair< ir::ModelIndex, ir::SubgraphIndex ,
ir::OperationIndex  ,
const backend::Backend backend 
)
overridevirtual

Implements onert::exec::IExecutionObserver.

Definition at line 76 of file ExecutionObservers.cc.

79{
80 _timer = backend->config()->timer();
81 if (_timer == nullptr)
82 throw std::runtime_error("To profile backend timer() method must be implemented");
83 _timer->handleBegin();
84}

References onert::backend::Backend::config().

◆ handleJobEnd()

void onert::exec::ProfileObserver::handleJobEnd ( IExecutor exec,
std::pair< ir::ModelIndex, ir::SubgraphIndex ,
ir::OperationIndex  op_ind,
const backend::Backend backend 
)
overridevirtual

Implements onert::exec::IExecutionObserver.

Definition at line 86 of file ExecutionObservers.cc.

88{
89 _timer->handleEnd();
90 const auto timer_res = _timer->getTime();
91
92 // NOTE This assumes there is just one operation in a op
93 const auto &node = _graph.operations().at(op_ind);
94 auto node_name = node.name();
95 VERBOSE(ProfileInfo) << "Time for " << node_name << " : " << timer_res << std::endl;
96
97 // fill ExecTime:
98 bool is_quantized = exec->graph().operands().at(node.getInputs().at(0)).typeInfo().type() ==
99 ir::DataType::QUANT_UINT8_ASYMM;
100
101 uint32_t size = 0;
102 for (const auto &ind : (node.getInputs() + node.getOutputs()) | ir::Remove::UNDEFINED)
103 {
104 size += exec->graph().operands().at(ind).info().total_size();
105 }
106 if (node_name == "Permute")
107 {
108 // TODO Change it to updateOperationExecTime()
109 _et->updatePermuteTime(backend, backend, is_quantized, size, timer_res);
110 }
111 else
112 {
113 _et->updateOperationExecTime(backend, node_name, is_quantized, size, timer_res);
114 }
115};
const Operations & operations() const override
Definition Graph.h:105
const Object & at(const Index &index) const
Get the object that is associated with the given index.
#define VERBOSE(name, lv)
Definition Log.h:71
bool is_quantized(const CircleNode *node)
int32_t size[5]
Definition Slice.cpp:35

References onert::util::ObjectManager< Index, Object >::at(), onert::exec::IExecutor::graph(), onert::ir::Graph::operands(), onert::ir::Graph::operations(), size, Operand::type, onert::ir::UNDEFINED, and VERBOSE.

◆ handleSubgraphEnd()

void onert::exec::ProfileObserver::handleSubgraphEnd ( std::pair< ir::ModelIndex, ir::SubgraphIndex )
inlineoverridevirtual

Invoked just after model (not individual operation) execution ends.

Reimplemented from onert::exec::IExecutionObserver.

Definition at line 92 of file ExecutionObservers.h.

93 {
94 _et->storeOperationsExecTime();
95 }

◆ type()

ObserverType onert::exec::ProfileObserver::type ( ) const
inlineoverridevirtual

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