ONE - On-device Neural Engine
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
MemoryManager.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2023 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_TRAIN_MEMORY_MANAGER_H__
18#define __ONERT_BACKEND_TRAIN_MEMORY_MANAGER_H__
19
21
24
26{
27
29
31{
32public:
33 TrainableMemoryManager(uint32_t optimizer_vars_count);
34 virtual ~TrainableMemoryManager() = default;
35
36 void allocate(void);
37 uint8_t *getOptVarBuffer(const ir::OperandIndex &ind, uint32_t pos_var) const;
38
39private:
40 std::shared_ptr<basic::Allocator> _var_mem_alloc;
41 uint32_t _optim_vars_count;
42};
43
45{
46public:
48
49 void allocate(void);
50 uint8_t *getBuffer(const DisposableTensorIndex &ind) const;
51 void deallocate(void) { _mem_alloc->release(); }
52
53 void claimPlan(const DisposableTensorIndex &ind, uint32_t size);
54 void releasePlan(const DisposableTensorIndex &ind);
55
56 std::shared_ptr<basic::Allocator> getMemAlloc() { return _mem_alloc; }
57
58private:
60 basic::IMemoryPlanner<DisposableTensorIndex> *createMemoryPlanner(const std::string planner_id);
61
62private:
63 std::shared_ptr<basic::IMemoryPlanner<DisposableTensorIndex>> _mem_planner;
64 std::shared_ptr<basic::Allocator> _mem_alloc;
65};
66
68{
69public:
71
72 void allocate(void);
73 uint8_t *getBuffer(const LayerScopeTensorIndex &ind) const;
74 void deallocate(void);
75
76 void claimPlan(const LayerScopeTensorIndex &ind, uint32_t size);
77 void releasePlan(const LayerScopeTensorIndex &ind);
78
79private:
81
82private:
83 std::shared_ptr<basic::IMemoryPlanner<LayerScopeTensorIndex>> _mem_planner;
84 std::shared_ptr<basic::Allocator> _mem_alloc;
85};
86
87} // namespace onert::backend::train
88
89#endif // __ONERT_BACKEND_TRAIN_MEMORY_MANAGER_H__
void releasePlan(const DisposableTensorIndex &ind)
uint8_t * getBuffer(const DisposableTensorIndex &ind) const
void claimPlan(const DisposableTensorIndex &ind, uint32_t size)
std::shared_ptr< basic::Allocator > getMemAlloc()
Class that is index of DisposableTensor.
void claimPlan(const LayerScopeTensorIndex &ind, uint32_t size)
uint8_t * getBuffer(const LayerScopeTensorIndex &ind) const
void releasePlan(const LayerScopeTensorIndex &ind)
uint8_t * getOptVarBuffer(const ir::OperandIndex &ind, uint32_t pos_var) const
int32_t size[5]
Definition Slice.cpp:35