From 5b310591d7ff0c12c51efb00032298e38432a414 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EA=B9=80=EC=9A=A9=EC=84=AD/On-Device=20Lab=28SR=29/Enginee?= =?utf8?q?r/=EC=82=BC=EC=84=B1=EC=A0=84=EC=9E=90?= Date: Thu, 25 Jul 2019 14:30:28 +0900 Subject: [PATCH] [neurun] Make visitor for Subgraph override in KernelGenerator (#5876) Make visitor for Subgraph override in KernelGenerator for preVisit and postVisit in the future Signed-off-by: Yongseop Kim --- runtimes/neurun/backend/acl_cl/KernelGenerator.cc | 11 +++++++++++ runtimes/neurun/backend/acl_cl/KernelGenerator.h | 1 + runtimes/neurun/backend/acl_neon/KernelGenerator.cc | 11 +++++++++++ runtimes/neurun/backend/acl_neon/KernelGenerator.h | 1 + runtimes/neurun/core/include/backend/IKernelGenerator.h | 2 +- 5 files changed, 25 insertions(+), 1 deletion(-) diff --git a/runtimes/neurun/backend/acl_cl/KernelGenerator.cc b/runtimes/neurun/backend/acl_cl/KernelGenerator.cc index b2489a1..cef1f01 100644 --- a/runtimes/neurun/backend/acl_cl/KernelGenerator.cc +++ b/runtimes/neurun/backend/acl_cl/KernelGenerator.cc @@ -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)}; diff --git a/runtimes/neurun/backend/acl_cl/KernelGenerator.h b/runtimes/neurun/backend/acl_cl/KernelGenerator.h index 6c70e1d..80b65c3 100644 --- a/runtimes/neurun/backend/acl_cl/KernelGenerator.h +++ b/runtimes/neurun/backend/acl_cl/KernelGenerator.h @@ -37,6 +37,7 @@ public: std::shared_ptr 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; diff --git a/runtimes/neurun/backend/acl_neon/KernelGenerator.cc b/runtimes/neurun/backend/acl_neon/KernelGenerator.cc index 1f57e75..2d1a477 100644 --- a/runtimes/neurun/backend/acl_neon/KernelGenerator.cc +++ b/runtimes/neurun/backend/acl_neon/KernelGenerator.cc @@ -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; diff --git a/runtimes/neurun/backend/acl_neon/KernelGenerator.h b/runtimes/neurun/backend/acl_neon/KernelGenerator.h index ecb05c3..ff4c911 100644 --- a/runtimes/neurun/backend/acl_neon/KernelGenerator.h +++ b/runtimes/neurun/backend/acl_neon/KernelGenerator.h @@ -37,6 +37,7 @@ public: std::shared_ptr 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; diff --git a/runtimes/neurun/core/include/backend/IKernelGenerator.h b/runtimes/neurun/core/include/backend/IKernelGenerator.h index 98ebd55..07d29ca 100644 --- a/runtimes/neurun/core/include/backend/IKernelGenerator.h +++ b/runtimes/neurun/core/include/backend/IKernelGenerator.h @@ -31,7 +31,7 @@ namespace neurun namespace backend { -class IKernelGenerator : model::OperationVisitor +class IKernelGenerator : public model::OperationVisitor { public: virtual ~IKernelGenerator() = default; -- 2.7.4