2 * Copyright (c) 2020 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.
17 #ifndef __ONERT_BACKEND_CONTROLFLOW_TENSOR_BUILDER_H__
18 #define __ONERT_BACKEND_CONTROLFLOW_TENSOR_BUILDER_H__
20 #include <backend/cpu_common/StaticTensorManager.h>
21 #include <backend/cpu_common/TensorRegistry.h>
22 #include <backend/cpu_common/Tensor.h>
24 #include <ir/OperandIndexMap.h>
26 #include <unordered_map>
28 #include "DynamicTensorManager.h"
40 TensorBuilder(const std::shared_ptr<TensorRegistry> &tensor_reg);
43 * @brief Register tensor information to allocate on CPU backend
44 * @param[in] ind Operand index
45 * @param[in] info Operand information
46 * @param[in] layout Operand data layout
48 void registerTensorInfo(const ir::OperandIndex &ind, const ir::OperandInfo &info,
49 ir::Layout backend_layout);
51 void notifyFirstUse(const ir::OperandIndex &);
52 void notifyLastUse(const ir::OperandIndex &);
54 bool isRegistered(const ir::OperandIndex &) const;
58 void postFunctionPrepare() { /* DO NOTHING */}
60 DynamicTensorManager *dynamicTensorManager(void);
63 * @brief Get tensor with a specific OperandIndex.
64 * @param ind OperandIndex for the tensor. There must exist a tensor with this ind.
65 * If not, program will crash with assert or exception.
66 * @return operand::Tensor *
68 cpu_common::Tensor *nativeOwnTensorAt(const ir::OperandIndex &ind);
71 const std::shared_ptr<TensorRegistry> _tensor_reg;
72 std::unique_ptr<DynamicTensorManager> _dynamic_tensor_mgr;
73 std::unique_ptr<cpu_common::StaticTensorManager> _static_tensor_mgr;
74 ir::OperandIndexMap<ir::OperandInfo> _tensor_info_map;
75 ir::OperandIndexMap<ir::Layout> _tensor_layout_map;
78 } // namespace controlflow
79 } // namespace backend
82 #endif // __ONERT_BACKEND_CONTROLFLOW_TENSOR_BUILDER_H__