From cf468c94610b4ea9020ceb1444566635d44a0e8d Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EC=9E=A5=EC=A7=80=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: Fri, 9 Aug 2019 15:51:24 +0900 Subject: [PATCH] Add layout as a member of SubGraph into KernelGenerators (#6283) This commit adds layout as a member of SubGraph into KernelGenerators. Signed-off-by: jiseob.jang --- runtimes/neurun/backend/acl_cl/KernelGenerator.cc | 1 + runtimes/neurun/backend/acl_cl/KernelGenerator.h | 1 + runtimes/neurun/backend/acl_neon/KernelGenerator.cc | 1 + runtimes/neurun/backend/acl_neon/KernelGenerator.h | 1 + runtimes/neurun/backend/cpu/KernelGenerator.cc | 12 ++++++++++++ runtimes/neurun/backend/cpu/KernelGenerator.h | 2 ++ 6 files changed, 18 insertions(+) diff --git a/runtimes/neurun/backend/acl_cl/KernelGenerator.cc b/runtimes/neurun/backend/acl_cl/KernelGenerator.cc index 41d0ef8..cd17302 100644 --- a/runtimes/neurun/backend/acl_cl/KernelGenerator.cc +++ b/runtimes/neurun/backend/acl_cl/KernelGenerator.cc @@ -154,6 +154,7 @@ KernelGenerator::KernelGenerator(const neurun::model::Operands &ctx, void KernelGenerator::visit(const model::Subgraph &subgraph) { + _current_subg_layout = subgraph.getLayout(); for (const auto &e : subgraph.operations()) { const auto &node = *(e.node); diff --git a/runtimes/neurun/backend/acl_cl/KernelGenerator.h b/runtimes/neurun/backend/acl_cl/KernelGenerator.h index 3a27c5f..db9bf41 100644 --- a/runtimes/neurun/backend/acl_cl/KernelGenerator.h +++ b/runtimes/neurun/backend/acl_cl/KernelGenerator.h @@ -95,6 +95,7 @@ public: private: const neurun::model::Operands &_ctx; std::shared_ptr _tensor_builder; + model::Layout _current_subg_layout; }; } // namespace acl_cl diff --git a/runtimes/neurun/backend/acl_neon/KernelGenerator.cc b/runtimes/neurun/backend/acl_neon/KernelGenerator.cc index 0b14e41..044366c 100644 --- a/runtimes/neurun/backend/acl_neon/KernelGenerator.cc +++ b/runtimes/neurun/backend/acl_neon/KernelGenerator.cc @@ -165,6 +165,7 @@ KernelGenerator::KernelGenerator(const neurun::model::Operands &ctx, void KernelGenerator::visit(const model::Subgraph &subgraph) { + _current_subg_layout = subgraph.getLayout(); for (const auto &e : subgraph.operations()) { const auto &node = *(e.node); diff --git a/runtimes/neurun/backend/acl_neon/KernelGenerator.h b/runtimes/neurun/backend/acl_neon/KernelGenerator.h index 6c49b38..32d32a1 100644 --- a/runtimes/neurun/backend/acl_neon/KernelGenerator.h +++ b/runtimes/neurun/backend/acl_neon/KernelGenerator.h @@ -68,6 +68,7 @@ public: private: const neurun::model::Operands &_ctx; std::shared_ptr _tensor_builder; + model::Layout _current_subg_layout; }; } // namespace acl_neon diff --git a/runtimes/neurun/backend/cpu/KernelGenerator.cc b/runtimes/neurun/backend/cpu/KernelGenerator.cc index 1b0c0fd..2708783 100644 --- a/runtimes/neurun/backend/cpu/KernelGenerator.cc +++ b/runtimes/neurun/backend/cpu/KernelGenerator.cc @@ -53,6 +53,18 @@ KernelGenerator::KernelGenerator(const neurun::model::Operands &operand_ctx, // DO NOTHING } +void KernelGenerator::visit(const model::Subgraph &subgraph) +{ + _current_subg_layout = subgraph.getLayout(); + 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/cpu/KernelGenerator.h b/runtimes/neurun/backend/cpu/KernelGenerator.h index 1d08573..eb29773 100644 --- a/runtimes/neurun/backend/cpu/KernelGenerator.h +++ b/runtimes/neurun/backend/cpu/KernelGenerator.h @@ -35,6 +35,7 @@ public: KernelGenerator(const neurun::model::Operands &ctx, const std::shared_ptr &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; @@ -50,6 +51,7 @@ public: private: const neurun::model::Operands &_ctx; std::shared_ptr _tensor_builder; + model::Layout _current_subg_layout; }; } // namespace cpu -- 2.7.4