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"
27 #include "ir/OperationIndexMap.h"
28 #include "backend/IDynamicTensorManager.h"
34 class IExecutionObserver;
36 * @brief Struct to define interface of Executor
41 * @brief Construct a new IExecutor object
43 IExecutor() = default;
45 * @brief Destroy the IExecutor object
47 virtual ~IExecutor() = default;
50 * @brief Returns graph object
52 * @return Graph object
54 virtual const ir::Graph &graph() = 0;
57 * @brief Set an ordering on operations
58 * @param[in] ranks The table encoding the ordering
60 virtual void setIndexedRanks(std::shared_ptr<ir::OperationIndexMap<int64_t>>) = 0;
63 * @brief Start execution
64 * @param[in] desc Input and output description
65 * @note This method should be thread-safe
67 virtual void execute(const IODescription &desc) = 0;
70 using ExecutorMap = std::unordered_map<ir::SubgraphIndex, std::unique_ptr<IExecutor>>;
72 // TODO Move this structure to suitable place
74 * @brief Dynamic allocation info for input tensors
75 * When user sets shape of input having unknown dims after compilation, memory for the input
76 * should be allocated before executing kernels. This struct contains information to allocate
81 /// @brief index of input tensor whose memory needs to be allocated at execution time
83 /// @brief dynamic tensor manager that can allocate memory when input tensor is dynamic
84 backend::IDynamicTensorManager *dyn_tensor_manager;
87 using DynAllocInfoMap = std::unordered_map<std::shared_ptr<backend::ITensor>, DynAllocInfo>;
92 #endif // __ONERT_EXEC_I_EXECUTOR_H_