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

#include <ExecutionObservers.h>

Collaboration diagram for onert::exec::TracingObserver:

Public Member Functions

 TracingObserver (const std::string &workspace_dir, const ir::Graph &graph, const util::TracingCtx *tracing_ctx)
 
 ~TracingObserver ()
 
void handleSubgraphBegin (std::pair< ir::ModelIndex, ir::SubgraphIndex >) override
 Invoked just before model (not individual operation) execution begins.
 
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 ~IExecutionObserver ()=default
 

Detailed Description

Definition at line 104 of file ExecutionObservers.h.

Constructor & Destructor Documentation

◆ TracingObserver()

onert::exec::TracingObserver::TracingObserver ( const std::string &  workspace_dir,
const ir::Graph graph,
const util::TracingCtx tracing_ctx 
)

Definition at line 117 of file ExecutionObservers.cc.

119 : _recorder{std::make_unique<EventRecorder>()}, _collector{_recorder.get()}, _graph{graph},
120 _workspace_dir{workspace_dir}, _tracing_ctx{tracing_ctx}, _triggered{false}
121{
122 // DO NOTHING
123}

◆ ~TracingObserver()

onert::exec::TracingObserver::~TracingObserver ( )

Definition at line 125 of file ExecutionObservers.cc.

126{
127 try
128 {
129 // Write file if this observer is triggered at least once
130 if (_triggered)
131 {
132 auto event_writer = EventWriter::get(_workspace_dir);
133 event_writer->startToUse();
134 event_writer->readyToFlush(std::move(_recorder));
135 }
136 }
137 catch (const std::exception &e)
138 {
139 std::cerr << "E: Fail to record event in TracingObserver: " << e.what() << std::endl;
140 }
141}
static EventWriter * get(const std::string &workspace_dir)
Retuens a singleton object.
Definition EventWriter.h:91

References EventWriter::get().

Member Function Documentation

◆ handleJobBegin()

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

Implements onert::exec::IExecutionObserver.

Definition at line 151 of file ExecutionObservers.cc.

153{
154 std::string backend_id = backend->config()->id();
155 const auto &op = _graph.operations().at(op_ind);
157 ind.first.value(), ind.second.value(),
158 backend_id, op_ind.value(),
159 op.name()};
160 // add shape of inputs
161 setUserData(_graph, &op, ev.userData);
162 _collector.onEvent(ev);
163}
void onEvent(const EventT &event)
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.

References onert::util::ObjectManager< Index, Object >::at(), EventCollector::BEGIN, onert::backend::Backend::config(), onert::ir::IOperation::name(), EventCollector::onEvent(), onert::ir::Graph::operations(), and onert::util::Index< T, DummyTag >::value().

◆ handleJobEnd()

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

Implements onert::exec::IExecutionObserver.

Definition at line 165 of file ExecutionObservers.cc.

167{
168 std::string backend_id = backend->config()->id();
170 _tracing_ctx, EventCollector::Edge::END, ind.first.value(), ind.second.value(), backend_id,
171 op_ind.value(), _graph.operations().at(op_ind).name()});
172}

References onert::util::ObjectManager< Index, Object >::at(), onert::backend::Backend::config(), EventCollector::END, EventCollector::onEvent(), onert::ir::Graph::operations(), and onert::util::Index< T, DummyTag >::value().

◆ handleSubgraphBegin()

void onert::exec::TracingObserver::handleSubgraphBegin ( std::pair< ir::ModelIndex, ir::SubgraphIndex )
overridevirtual

Invoked just before model (not individual operation) execution begins.

Reimplemented from onert::exec::IExecutionObserver.

Definition at line 143 of file ExecutionObservers.cc.

144{
145 _triggered = true;
146
148 ind.first.value(), ind.second.value()});
149}

References EventCollector::BEGIN, and EventCollector::onEvent().

◆ handleSubgraphEnd()

void onert::exec::TracingObserver::handleSubgraphEnd ( std::pair< ir::ModelIndex, ir::SubgraphIndex )
overridevirtual

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

Reimplemented from onert::exec::IExecutionObserver.

Definition at line 174 of file ExecutionObservers.cc.

175{
177 ind.first.value(), ind.second.value()});
178}

References EventCollector::END, and EventCollector::onEvent().

◆ type()

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

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