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.
17 #ifndef __ONERT_BACKEND_CPU_COMMON_STATICTENSOR_MANAGER_H__
18 #define __ONERT_BACKEND_CPU_COMMON_STATICTENSOR_MANAGER_H__
20 #include "MemoryManager.h"
22 #include "backend/ITensorManager.h"
23 #include "ir/OperandIndexMap.h"
24 #include "ir/OperandInfo.h"
25 #include "TensorRegistry.h"
34 class StaticTensorManager : public backend::ITensorManager
37 StaticTensorManager(const std::shared_ptr<TensorRegistry> ®);
38 virtual ~StaticTensorManager() = default;
40 void allocateConsts(void);
41 void allocateNonconsts(void);
42 void deallocateConsts(void);
43 void deallocateNonconsts(void);
45 void buildTensor(const ir::OperandIndex &ind, const ir::OperandInfo &tensor_info,
46 ir::Layout backend_layout, bool as_const);
48 void claimPlan(const ir::OperandIndex &ind, uint32_t size);
49 void releasePlan(const ir::OperandIndex &ind);
51 void iterate(const std::function<void(const ir::OperandIndex &)> &fn);
54 std::unique_ptr<DynamicMemoryManager> _const_mgr;
55 std::unique_ptr<MemoryManager> _nonconst_mgr;
56 const std::shared_ptr<TensorRegistry> _tensors;
57 ir::OperandIndexMap<bool> _as_constants;
60 } // namespace cpu_common
61 } // namespace backend
64 #endif // __ONERT_BACKEND_CPU_COMMON_STATICTENSOR_MANAGER_H__