ONE - On-device Neural Engine
Loading...
Searching...
No Matches
DynamicTensorManager.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved
3 *
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
16
17#ifndef __ONERT_BACKEND_BASIC_DYNAMICTENSOR_MANAGER_H__
18#define __ONERT_BACKEND_BASIC_DYNAMICTENSOR_MANAGER_H__
19
20#include "MemoryManager.h"
21#include "TensorRegistry.h"
22
23#include <ir/OperandInfo.h>
24#include <ir/IOperation.h>
25#include <ir/Index.h>
26
27#include <unordered_set>
28
29namespace onert
30{
31namespace backend
32{
33namespace basic
34{
35
36// TODO Find optimized algorithm to manage memory.
37
42{
43public:
44 DynamicTensorManager(const std::shared_ptr<TensorRegistry> &reg);
45
46 virtual ~DynamicTensorManager() = default;
47
48 void buildTensor(const ir::OperandIndex &ind, const ir::OperandInfo &tensor_info);
49
50 std::shared_ptr<DynamicMemoryManager> dynamic_mem_mgr() { return _dynamic_mem_mgr; }
51
52private:
53 const ITensor *getRawITensor(ir::OperandIndex ind);
54
55private:
60 std::shared_ptr<DynamicMemoryManager> _dynamic_mem_mgr;
61 const std::shared_ptr<TensorRegistry> _tensors;
62
63 // contains list of dynamic tensor index, which can be deallocated after running operation
64 // note: this map could contain static tensor index too. Careful use is required.
65 std::unordered_map<ir::OperationIndex, std::unordered_set<backend::ITensor *>>
66 _dealloc_tensor_map;
67};
68
69} // namespace basic
70} // namespace backend
71} // namespace onert
72
73#endif // __ONERT_BACKEND_BASIC_DYNAMICTENSOR_MANAGER_H__
This file contains OperandInfo class.
Class to manage dynamic tensor and its memory.
void buildTensor(const ir::OperandIndex &ind, const ir::OperandInfo &tensor_info)
std::shared_ptr< DynamicMemoryManager > dynamic_mem_mgr()
Class to save tensor's shape and type.
Definition OperandInfo.h:56