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 (ir::SubgraphIndex) override
 Invoked just before model (not individual operation) execution begins.
 
void handleJobBegin (IExecutor *, ir::SubgraphIndex, ir::OperationIndex, const backend::Backend *) override
 
void handleJobEnd (IExecutor *, ir::SubgraphIndex, ir::OperationIndex, const backend::Backend *) override
 
void handleSubgraphEnd (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 103 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 116 of file ExecutionObservers.cc.

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

◆ ~TracingObserver()

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

Definition at line 124 of file ExecutionObservers.cc.

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

References EventWriter::get().

Member Function Documentation

◆ handleJobBegin()

void onert::exec::TracingObserver::handleJobBegin ( IExecutor ,
ir::SubgraphIndex  subg_ind,
ir::OperationIndex  op_ind,
const backend::Backend backend 
)
overridevirtual

Implements onert::exec::IExecutionObserver.

Definition at line 150 of file ExecutionObservers.cc.

152{
153 std::string backend_id = backend->config()->id();
154 const auto &op = _graph.operations().at(op_ind);
156 subg_ind.value(), backend_id,
157 op_ind.value(), op.name()};
158 // add shape of inputs
159 setUserData(_graph, &op, ev.userData);
160 _collector.onEvent(ev);
161}
void onEvent(const EventT &event)
const Operations & operations() const override
Definition Graph.h:114
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 ,
ir::SubgraphIndex  subg_ind,
ir::OperationIndex  op_ind,
const backend::Backend backend 
)
overridevirtual

Implements onert::exec::IExecutionObserver.

Definition at line 163 of file ExecutionObservers.cc.

165{
166 std::string backend_id = backend->config()->id();
168 subg_ind.value(), backend_id, op_ind.value(),
169 _graph.operations().at(op_ind).name()});
170}

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 ( ir::SubgraphIndex  )
overridevirtual

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

Reimplemented from onert::exec::IExecutionObserver.

Definition at line 142 of file ExecutionObservers.cc.

143{
144 _triggered = true;
145
146 _collector.onEvent(
147 EventCollector::SubgEvent{_tracing_ctx, EventCollector::Edge::BEGIN, subg_ind.value()});
148}

References EventCollector::BEGIN, EventCollector::onEvent(), and onert::util::Index< T, DummyTag >::value().

◆ handleSubgraphEnd()

void onert::exec::TracingObserver::handleSubgraphEnd ( ir::SubgraphIndex  )
overridevirtual

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

Reimplemented from onert::exec::IExecutionObserver.

Definition at line 172 of file ExecutionObservers.cc.

173{
174 _collector.onEvent(
175 EventCollector::SubgEvent{_tracing_ctx, EventCollector::Edge::END, subg_ind.value()});
176}

References EventCollector::END, EventCollector::onEvent(), and onert::util::Index< T, DummyTag >::value().

◆ type()

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

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