From 57063e2ab925656ffff83fe0688e0d3bb3816696 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EC=98=A4=ED=98=95=EC=84=9D/On-Device=20Lab=28SR=29/Staff?= =?utf8?q?=20Engineer/=EC=82=BC=EC=84=B1=EC=A0=84=EC=9E=90?= Date: Thu, 21 Feb 2019 17:37:21 +0900 Subject: [PATCH] Introduce IExecutor interface (#4454) * Introduce IExecutor interface Introduce IExecutor interface Access executor using interface on frontend Signed-off-by: Hyeongseok Oh * Executor class as final --- runtimes/neurun/src/exec/Executor.h | 4 +- runtimes/neurun/src/exec/IExecutor.h | 82 ++++++++++++++++++++++++ runtimes/neurun/src/frontend/wrapper/execution.h | 2 +- 3 files changed, 85 insertions(+), 3 deletions(-) create mode 100644 runtimes/neurun/src/exec/IExecutor.h diff --git a/runtimes/neurun/src/exec/Executor.h b/runtimes/neurun/src/exec/Executor.h index 32febd3..f688cb1 100644 --- a/runtimes/neurun/src/exec/Executor.h +++ b/runtimes/neurun/src/exec/Executor.h @@ -22,7 +22,7 @@ #ifndef __NEURUN_EXEC_EXECUTOR_H_ #define __NEURUN_EXEC_EXECUTOR_H_ -#include "compiler/Plan.h" +#include "IExecutor.h" #include "Source.h" #include "Sink.h" @@ -34,7 +34,7 @@ namespace exec /** * @brief Class to handle execution phase */ -class Executor +class Executor final : public IExecutor { public: /** diff --git a/runtimes/neurun/src/exec/IExecutor.h b/runtimes/neurun/src/exec/IExecutor.h new file mode 100644 index 0000000..48c167c --- /dev/null +++ b/runtimes/neurun/src/exec/IExecutor.h @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2019 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file IExecutor.h + * @brief This file defines interface of Executor + */ +#ifndef __NEURUN_EXEC_I_EXECUTOR_H_ +#define __NEURUN_EXEC_I_EXECUTOR_H_ + +#include "compiler/Plan.h" + +namespace neurun +{ +namespace exec +{ + +/** + * @brief Struct to define interface of Executor + */ +struct IExecutor +{ + /** + * @brief Construct a new IExecutor object + */ + IExecutor() = default; + /** + * @brief Destroy the IExecutor object + */ + virtual ~IExecutor() = default; + + /** + * @brief Return plan + * @return Plan + */ + virtual const neurun::compiler::Plan &plan(void) const = 0; + /** + * @brief Set input data's information + * @param[in] index Input index + * @param[in] type Input data's type info + * @param[in] shape Input data's shape + * @param[in] buffer Input data's buffer pointer + * @param[in] length Input data's length + */ + virtual void setInput(const model::operand::IO::Index &index, + const model::operand::TypeInfo &type, const model::operand::Shape &shape, + const void *buffer, size_t length) = 0; + /** + * @brief Set output data's information + * @param[in] index Output index + * @param[in] type Output data's type info + * @param[in] shape Output data's shape + * @param[in] buffer Output data's buffer pointer + * @param[in] length Output data's length + */ + virtual void setOutput(const model::operand::IO::Index &index, + const model::operand::TypeInfo &type, const model::operand::Shape &shape, + void *buffer, size_t length) = 0; + /** + * @brief Start execution + * @note It should be called after setting input and output buffer + */ + virtual void execute(void) = 0; +}; + +} // namespace exec +} // namespace neurun + +#endif // __NEURUN_EXEC_I_EXECUTOR_H_ diff --git a/runtimes/neurun/src/frontend/wrapper/execution.h b/runtimes/neurun/src/frontend/wrapper/execution.h index 8479ec5..aca23cc 100644 --- a/runtimes/neurun/src/frontend/wrapper/execution.h +++ b/runtimes/neurun/src/frontend/wrapper/execution.h @@ -46,7 +46,7 @@ public: bool haveUnspecifiedDims(const neurun::model::operand::Index index) noexcept; private: - std::shared_ptr _executor; + std::shared_ptr _executor; }; #endif -- 2.7.4