#define __NEURUN_EXEC_OBSREVERS_H__
#include "exec/IFunction.h"
-#include "model/Operation.h"
+#include "model/Subgraph.h"
#include "backend/ExecTime.h"
#include "util/ITimer.h"
#include "IExecutor.h"
/// @brief Invoked just before model (not individual operation) execution begins
virtual void handleBegin(IExecutor *) { return; }
- virtual void handleBegin(IExecutor *, const model::Operation *, const backend::Backend *) = 0;
- virtual void handleEnd(IExecutor *, const model::Operation *, const backend::Backend *) = 0;
+ virtual void handleBegin(IExecutor *, const model::Subgraph *, const backend::Backend *) = 0;
+ virtual void handleEnd(IExecutor *, const model::Subgraph *, const backend::Backend *) = 0;
/// @brief Invoked just after model (not individual operation) execution ends
virtual void handleEnd(IExecutor *) { return; }
{
public:
explicit ProfileObserver(std::shared_ptr<backend::ExecTime> et) : _et(std::move(et)) {}
- void handleBegin(IExecutor *, const model::Operation *, const backend::Backend *) override;
- void handleEnd(IExecutor *, const model::Operation *, const backend::Backend *) override;
+ void handleBegin(IExecutor *, const model::Subgraph *, const backend::Backend *) override;
+ void handleEnd(IExecutor *, const model::Subgraph *, const backend::Backend *) override;
void handleEnd(IExecutor *) override { _et->uploadOperationsExecTime(); }
ChromeTracingObserver(const std::string &filepath);
~ChromeTracingObserver();
void handleBegin(IExecutor *) override;
- void handleBegin(IExecutor *, const model::Operation *, const backend::Backend *) override;
- void handleEnd(IExecutor *, const model::Operation *, const backend::Backend *) override;
+ void handleBegin(IExecutor *, const model::Subgraph *, const backend::Backend *) override;
+ void handleEnd(IExecutor *, const model::Subgraph *, const backend::Backend *) override;
void handleEnd(IExecutor *) override;
private:
VERBOSE(DataflowExecutor) << "Run job #" << job_index << std::endl;
auto subgraph_index = _job_to_subgraph[job_index];
- // Workaround - assumes only one operation in a subgraph
- auto op = _subgraphs->at(subgraph_index).operations().at(0).node;
+ auto subgraph = &_subgraphs->at(subgraph_index);
const backend::Backend *backend = _lower_info->operation.at(subgraph_index)->backend();
- _subject.notifyJobBegin(this, op, backend);
+ _subject.notifyJobBegin(this, subgraph, backend);
if (is_profiling)
job->fn()->runSync();
else
job->run();
- _subject.notifyJobEnd(this, op, backend);
+ _subject.notifyJobEnd(this, subgraph, backend);
notify(job_index);
_finished_jobs[job_index] = std::move(job);
}
}
}
-void ExecutionObservee::notifyJobBegin(IExecutor *executor, const model::Operation *operation,
+void ExecutionObservee::notifyJobBegin(IExecutor *executor, const model::Subgraph *subgraph,
const backend::Backend *backend)
{
for (auto &o : _observers)
{
- o->handleBegin(executor, operation, backend);
+ o->handleBegin(executor, subgraph, backend);
}
}
-void ExecutionObservee::notifyJobEnd(IExecutor *executor, const model::Operation *operation,
+void ExecutionObservee::notifyJobEnd(IExecutor *executor, const model::Subgraph *subgraph,
const backend::Backend *backend)
{
for (auto &o : _observers)
{
- o->handleEnd(executor, operation, backend);
+ o->handleEnd(executor, subgraph, backend);
}
}
void add(std::unique_ptr<IExecutionObserver> observer);
void notifyModelBegin(IExecutor *executor);
void notifyModelEnd(IExecutor *executor);
- void notifyJobBegin(IExecutor *executor, const model::Operation *operation,
+ void notifyJobBegin(IExecutor *executor, const model::Subgraph *subgraph,
const backend::Backend *backend);
- void notifyJobEnd(IExecutor *executor, const model::Operation *operation,
+ void notifyJobEnd(IExecutor *executor, const model::Subgraph *subgraph,
const backend::Backend *backend);
private:
namespace exec
{
-void ProfileObserver::handleBegin(neurun::exec::IExecutor *, const neurun::model::Operation *,
+void ProfileObserver::handleBegin(neurun::exec::IExecutor *, const neurun::model::Subgraph *,
const neurun::backend::Backend *backend)
{
_timer = backend->config()->timer();
_timer->handleBegin();
}
-void ProfileObserver::handleEnd(IExecutor *exec, const model::Operation *node,
+void ProfileObserver::handleEnd(IExecutor *exec, const model::Subgraph *subgraph,
const backend::Backend *backend)
{
_timer->handleEnd();
const auto timer_res = _timer->getTime();
+ // NOTE This assumes there is just one operation in a subgraph
+ auto node = subgraph->operations().at(0).node;
auto node_name = node->name();
VERBOSE(ProfileInfo) << "Time for " << node_name << " : " << timer_res << std::endl;
// TODO Record the run of the entire graph begin
}
-void ChromeTracingObserver::handleBegin(IExecutor *, const model::Operation *op,
+void ChromeTracingObserver::handleBegin(IExecutor *, const model::Subgraph *subgraph,
const backend::Backend *)
{
- _collector.onEvent(EventCollector::Event{EventCollector::Edge::BEGIN, op->name()});
+ _collector.onEvent(EventCollector::Event{EventCollector::Edge::BEGIN, subgraph->name()});
}
-void ChromeTracingObserver::handleEnd(IExecutor *, const model::Operation *op,
+void ChromeTracingObserver::handleEnd(IExecutor *, const model::Subgraph *subgraph,
const backend::Backend *)
{
- _collector.onEvent(EventCollector::Event{EventCollector::Edge::END, op->name()});
+ _collector.onEvent(EventCollector::Event{EventCollector::Edge::END, subgraph->name()});
}
void ChromeTracingObserver::handleEnd(IExecutor *)
_subject.notifyModelBegin(this);
for (auto &&code : _code)
{
- // FIXME Assumes only one operation in a subgraph
- const auto op = code.elem.subgraph->operations().at(0).node;
+ const auto subgraph = code.elem.subgraph;
const auto backend = code.elem.lower_info->backend();
- _subject.notifyJobBegin(this, op, backend);
+ _subject.notifyJobBegin(this, subgraph, backend);
code.fn->run();
- _subject.notifyJobEnd(this, op, backend);
+ _subject.notifyJobEnd(this, subgraph, backend);
}
_subject.notifyModelEnd(this);
}