[neurun] Make visitor for Subgraph override in KernelGenerator (#5876)
author김용섭/On-Device Lab(SR)/Engineer/삼성전자 <yons.kim@samsung.com>
Thu, 25 Jul 2019 05:30:28 +0000 (14:30 +0900)
committer이한종/On-Device Lab(SR)/Engineer/삼성전자 <hanjoung.lee@samsung.com>
Thu, 25 Jul 2019 05:30:28 +0000 (14:30 +0900)
Make visitor for Subgraph override in KernelGenerator for preVisit and
postVisit in the future

Signed-off-by: Yongseop Kim <yons.kim@samsung.com>
runtimes/neurun/backend/acl_cl/KernelGenerator.cc
runtimes/neurun/backend/acl_cl/KernelGenerator.h
runtimes/neurun/backend/acl_neon/KernelGenerator.cc
runtimes/neurun/backend/acl_neon/KernelGenerator.h
runtimes/neurun/core/include/backend/IKernelGenerator.h

index b2489a1..cef1f01 100644 (file)
@@ -151,6 +151,17 @@ KernelGenerator::KernelGenerator(const neurun::model::Operands &ctx,
   // DO NOTHING
 }
 
+void KernelGenerator::visit(const model::Subgraph &subgraph)
+{
+  for (const auto &e : subgraph.operations())
+  {
+    const auto &node = *(e.node);
+    //_tensor_builder->preVisit(node);
+    node.accept(*this);
+    //_tensor_builder->postVisit(node);
+  }
+}
+
 void KernelGenerator::visit(const model::operation::CastNode &node)
 {
   const auto ofm_index{node.getOutputs().at(0)};
index 6c70e1d..80b65c3 100644 (file)
@@ -37,6 +37,7 @@ public:
 
   std::shared_ptr<ITensorBuilder> tensor_builder() override { return _tensor_builder; }
 
+  void visit(const model::Subgraph &) override;
   void visit(const model::operation::Conv2DNode &) override;
   void visit(const model::operation::DepthwiseConv2DNode &) override;
   void visit(const model::operation::MaxPool2DNode &) override;
index 1f57e75..2d1a477 100644 (file)
@@ -160,6 +160,17 @@ KernelGenerator::KernelGenerator(const neurun::model::Operands &ctx,
   // DO NOTHING
 }
 
+void KernelGenerator::visit(const model::Subgraph &subgraph)
+{
+  for (const auto &e : subgraph.operations())
+  {
+    const auto &node = *(e.node);
+    //_tensor_builder->preVisit(node);
+    node.accept(*this);
+    //_tensor_builder->postVisit(node);
+  }
+}
+
 void KernelGenerator::visit(const model::operation::Conv2DNode &node)
 {
   using model::operation::Conv2DNode;
index ecb05c3..ff4c911 100644 (file)
@@ -37,6 +37,7 @@ public:
 
   std::shared_ptr<ITensorBuilder> tensor_builder() override { return _tensor_builder; }
 
+  void visit(const model::Subgraph &) override;
   void visit(const model::operation::Conv2DNode &) override;
   void visit(const model::operation::DepthwiseConv2DNode &) override;
   void visit(const model::operation::MaxPool2DNode &) override;
index 98ebd55..07d29ca 100644 (file)
@@ -31,7 +31,7 @@ namespace neurun
 namespace backend
 {
 
-class IKernelGenerator : model::OperationVisitor
+class IKernelGenerator : public model::OperationVisitor
 {
 public:
   virtual ~IKernelGenerator() = default;