From 430709b794cff5f5dc528b474bae310aa33f7b2e Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EC=9D=B4=ED=95=9C=EC=A2=85/=EB=8F=99=EC=9E=91=EC=A0=9C?= =?utf8?q?=EC=96=B4Lab=28SR=29/Engineer/=EC=82=BC=EC=84=B1=EC=A0=84?= =?utf8?q?=EC=9E=90?= Date: Thu, 6 Sep 2018 10:32:26 +0900 Subject: [PATCH] [neurun] Move Source and Sink to `exec` dir (#2612) Move `Source` and `Sink` to exec directory and change namespace from `internal` to `exec`. Signed-off-by: Hanjoung Lee --- runtimes/neurun/src/{internal => exec}/Sink.h | 12 ++++++++++-- runtimes/neurun/src/{internal => exec}/Source.h | 14 +++++++++++--- runtimes/neurun/src/frontend/execution.cc | 14 ++++++++------ runtimes/neurun/src/frontend/wrapper/execution.h | 19 +++++++++++-------- 4 files changed, 40 insertions(+), 19 deletions(-) rename runtimes/neurun/src/{internal => exec}/Sink.h (94%) rename runtimes/neurun/src/{internal => exec}/Source.h (93%) diff --git a/runtimes/neurun/src/internal/Sink.h b/runtimes/neurun/src/exec/Sink.h similarity index 94% rename from runtimes/neurun/src/internal/Sink.h rename to runtimes/neurun/src/exec/Sink.h index cf0de1c..8a30d24 100644 --- a/runtimes/neurun/src/internal/Sink.h +++ b/runtimes/neurun/src/exec/Sink.h @@ -1,5 +1,5 @@ -#ifndef __INTERNAL_SINK_H__ -#define __INTERNAL_SINK_H__ +#ifndef __NEURUN_EXEC_SINK_H__ +#define __NEURUN_EXEC_SINK_H__ #include @@ -12,6 +12,11 @@ #include "internal/nnapi/feature/View.h" #include "internal/nnapi/feature/Reader.h" +namespace neurun +{ +namespace exec +{ + struct Sink { virtual ~Sink() = default; @@ -96,4 +101,7 @@ private: const size_t _size; }; +} // namespace exec +} // namespace neurun + #endif // __INTERNAL_SINK_H__ diff --git a/runtimes/neurun/src/internal/Source.h b/runtimes/neurun/src/exec/Source.h similarity index 93% rename from runtimes/neurun/src/internal/Source.h rename to runtimes/neurun/src/exec/Source.h index b3cad38..dc631fd 100644 --- a/runtimes/neurun/src/internal/Source.h +++ b/runtimes/neurun/src/exec/Source.h @@ -1,5 +1,5 @@ -#ifndef __INTERNAL_SOURCE_H__ -#define __INTERNAL_SOURCE_H__ +#ifndef __NEURUN_EXEC_SOURCE_H__ +#define __NEURUN_EXEC_SOURCE_H__ #include @@ -14,6 +14,11 @@ #include "backend/acl_cl/feature/View.h" +namespace neurun +{ +namespace exec +{ + struct Source { virtual ~Source() = default; @@ -99,4 +104,7 @@ private: const size_t _size; }; -#endif // __INTERNAL_SOURCE_H__ +} // namespace exec +} // namespace neurun + +#endif // __NEURUN_EXEC_SOURCE_H__ diff --git a/runtimes/neurun/src/frontend/execution.cc b/runtimes/neurun/src/frontend/execution.cc index 4114c2d..b12d823 100644 --- a/runtimes/neurun/src/frontend/execution.cc +++ b/runtimes/neurun/src/frontend/execution.cc @@ -6,7 +6,6 @@ #include "frontend/wrapper/execution.h" #include "frontend/wrapper/event.h" -#include "internal/Source.h" #include "graph/operand/Index.h" // @@ -62,14 +61,15 @@ int ANeuralNetworksExecution_setInput(ANeuralNetworksExecution *execution, int32 const auto len = operands.at(operand_index).shape().dim(1); - execution->source(index, len, reinterpret_cast(buffer), length); + execution->source( + index, len, reinterpret_cast(buffer), length); } else if (operands.at(operand_index).shape().rank() == 4) { const auto &operand_shape = operands.at(operand_index).shape().asFeature(); - execution->source(index, operand_shape, - reinterpret_cast(buffer), length); + execution->source( + index, operand_shape, reinterpret_cast(buffer), length); } else { @@ -108,13 +108,15 @@ int ANeuralNetworksExecution_setOutput(ANeuralNetworksExecution *execution, int3 const auto len = operands.at(operand_index).shape().dim(1); - execution->sink(index, len, reinterpret_cast(buffer), length); + execution->sink(index, len, reinterpret_cast(buffer), + length); } else if (operands.at(operand_index).shape().rank() == 4) { const auto &operand_shape = operands.at(operand_index).shape().asFeature(); - execution->sink(index, operand_shape, reinterpret_cast(buffer), length); + execution->sink(index, operand_shape, + reinterpret_cast(buffer), length); } else { diff --git a/runtimes/neurun/src/frontend/wrapper/execution.h b/runtimes/neurun/src/frontend/wrapper/execution.h index 4c4c5c2..f0a910b 100644 --- a/runtimes/neurun/src/frontend/wrapper/execution.h +++ b/runtimes/neurun/src/frontend/wrapper/execution.h @@ -2,8 +2,8 @@ #define __EXECUTION_H__ #include "codegen/Plan.h" -#include "internal/Source.h" -#include "internal/Sink.h" +#include "exec/Source.h" +#include "exec/Sink.h" struct ANeuralNetworksExecution { @@ -22,29 +22,32 @@ private: public: // TODO Use InputIndex instead of int - void source(int n, std::unique_ptr &&source) { _sources.at(n) = std::move(source); } + void source(int n, std::unique_ptr &&source) + { + _sources.at(n) = std::move(source); + } template void source(int n, Args &&... args) { source(n, std::unique_ptr{new T{std::forward(args)...}}); } public: - const Source &source(int n) const { return *(_sources.at(n)); } + const neurun::exec::Source &source(int n) const { return *(_sources.at(n)); } public: // TODO Use OutputIndex instead of int - void sink(int n, std::unique_ptr &&sink) { _sinks.at(n) = std::move(sink); } + void sink(int n, std::unique_ptr &&sink) { _sinks.at(n) = std::move(sink); } template void sink(int n, Args &&... args) { sink(n, std::unique_ptr{new T{std::forward(args)...}}); } public: - const Sink &sink(int n) const { return *(_sinks.at(n)); } + const neurun::exec::Sink &sink(int n) const { return *(_sinks.at(n)); } private: - std::vector> _sources; - std::vector> _sinks; + std::vector> _sources; + std::vector> _sinks; }; #endif -- 2.7.4