`graph::Graph::Phase` is an enum class that represents which phase the
Graph is at. Since we are going to use `Graph` class for multiple
phases we need this with verification infra.
- Introduce an enum class `graph::Graph::Phase`
- Phase transition when `ANeuralNetworksModel_finish()` is called
- Call verifier from the appropriate place
Signed-off-by: Hanjoung Lee <hanjoung.lee@samsung.com>
#include <bitset>
#include "logging.h"
+#include "verifier/IVerifier.h"
namespace neurun
{
void Graph::addOutput(const operand::Index &ind) { _outputs.append(ind); }
+void Graph::finishBuilding(void)
+{
+ assert(_phase == Phase::BUILDING);
+ _phase = Phase::MODEL;
+
+ // Call graph verifications for the MODEL phase
+ {
+ verifier::DAGChecker dag_checker;
+ dag_checker.verify(*this);
+ }
+}
+
void Graph::iteratePostDfs(const std::function<void(const operation::Node &)> &fn) const
{
std::vector<bool> visited(_operations.size(), false);
class Graph
{
+private:
+ enum class Phase
+ {
+ BUILDING,
+ MODEL,
+ LOWERED
+ };
+
public:
Graph(void) = default;
std::unique_ptr<::internal::tflite::operand::Data> &&data);
void addInput(const operand::Index &ind);
void addOutput(const operand::Index &ind);
+ void finishBuilding(void);
// Accessors
public:
void iteratePostDfs(const std::function<void(const operation::Node &)> &fn) const;
private:
+ Phase _phase{Phase::BUILDING};
operation::Set _operations;
operand::Set _operands;
operand::IndexSet _inputs;
#include "model.h"
+#include "graph/Graph.h"
+
//
// ANeuralNetworksModel
//
}
_finished = true;
+ _model->finishBuilding();
return ANEURALNETWORKS_NO_ERROR;
}