2 * Copyright (c) 2019 Samsung Electronics Co., Ltd. All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 * @brief This file defines interface of Executor
21 #ifndef __ONERT_EXEC_I_EXECUTOR_H__
22 #define __ONERT_EXEC_I_EXECUTOR_H__
25 #include "IFunction.h"
26 #include "IODescription.h"
28 #include "ir/OperationIndexMap.h"
32 #include <unordered_map>
38 class IPortableTensor;
49 class IExecutionObserver;
51 * @brief Struct to define interface of Executor
56 * @brief Construct a new IExecutor object
58 IExecutor() = default;
60 * @brief Destroy the IExecutor object
62 virtual ~IExecutor() = default;
65 * @brief Returns graph object
67 * @return Graph object
69 virtual const ir::Graph &graph() = 0;
72 * @brief Set an ordering on operations
73 * @param[in] ranks The table encoding the ordering
75 virtual void setIndexedRanks(std::shared_ptr<ir::OperationIndexMap<int64_t>>) = 0;
78 * @brief Execute with user-given input/output description (for primary subgraph)
79 * @param[in] desc Input and output description
80 * @note This method should be thread-safe
82 virtual void execute(const IODescription &desc) = 0;
85 * @brief Execute with given input/output tensors
87 * For non-primary subgraphs, input and output tensors must be given.
89 * @param[in] inputs tensors that are passed as inputs
90 * @param[in] outputs tensors that are passed as outputs
92 virtual void execute(const std::vector<backend::IPortableTensor *> &inputs,
93 const std::vector<backend::IPortableTensor *> &outputs) = 0;
96 * @brief Get output tensor objects
98 * @return Vector of @c IOTensor
100 virtual const std::vector<backend::controlflow::IOTensor *> &getOutputTensors() const = 0;
103 using ExecutorMap = std::unordered_map<ir::SubgraphIndex, std::unique_ptr<IExecutor>>;
108 #endif // __ONERT_EXEC_I_EXECUTOR_H__