Introduce `operation::LowerInfo` which contains backend id as string.
Signed-off-by: Hanjoung Lee <hanjoung.lee@samsung.com>
#include "verifier/IVerifier.h"
#include "nnfw/std/memory.h"
#include "linear/Linear.h"
+#include "operation/LowerInfo.h"
namespace neurun
{
void Graph::lower(void)
{
assert(_phase == Phase::MODEL);
- _phase = Phase::LOWERED;
- // Call graph verifications for the LOWERED phase
+ // Lower
+ {
+ _operations.iterate([&](const operation::Index &, operation::Node &node) {
+ // TODO Update backend id accordingly. Currently "acl_cl" by default
+ node.lower_info(nnfw::make_unique<operation::LowerInfo>(std::string("acl_cl")));
+ });
+ }
+
+ // Graph verifications for the LOWERED phase
{
verifier::DAGChecker dag_checker;
dag_checker.verify(*this);
}
+
+ _phase = Phase::LOWERED;
}
std::unique_ptr<linear::Linear> Graph::linearize(void)
--- /dev/null
+#include "LowerInfo.h"
+
+namespace neurun
+{
+namespace graph
+{
+namespace operation
+{
+
+LowerInfo::LowerInfo(const std::string &backend_id) : _backend_id(backend_id)
+{
+ // DO NOTHING
+}
+
+} // namespace operation
+} // namespace graph
+} // namespace neurun
--- /dev/null
+#ifndef __NEURUN_GRAPH_OPERATION_LOWER_INFO_H__
+#define __NEURUN_GRAPH_OPERATION_LOWER_INFO_H__
+
+#include <string>
+
+namespace neurun
+{
+namespace graph
+{
+namespace operation
+{
+
+class LowerInfo
+{
+public:
+ LowerInfo(const std::string &backend_id);
+ const std::string &backend_id() const { return _backend_id; }
+
+private:
+ const std::string _backend_id;
+};
+
+} // namespace operation
+} // namespace graph
+} // namespace neurun
+
+#endif // __NEURUN_GRAPH_OPERATION_LOWER_INFO_H__
#ifndef __NEURUN_GRAPH_OPERATION_NODE_H__
#define __NEURUN_GRAPH_OPERATION_NODE_H__
+#include <memory>
+
#include "graph/operand/IndexSet.h"
#include "internal/op/Node.h"
+#include "LowerInfo.h"
namespace neurun
{
namespace operation
{
-struct Node
+class LowerInfo;
+
+class Node
{
public:
virtual ~Node() = default;
virtual operand::IndexSet inputs() const = 0;
virtual operand::IndexSet outputs() const = 0;
virtual const ::internal::tflite::op::Node *op() const = 0;
+
+public:
+ void lower_info(std::unique_ptr<LowerInfo> &&lower_info) { _lower_info = std::move(lower_info); }
+ const LowerInfo *lower_info() const { return _lower_info.get(); }
+
+private:
+ std::unique_ptr<LowerInfo> _lower_info;
};
} // namespace operation