ONE - On-device Neural Engine
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
TensorManager.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_TENSOR_MANAGER_H__
18#define __ONERT_BACKEND_TRAIN_TENSOR_MANAGER_H__
19
21#include "MemoryManager.h"
22#include "TensorRegistry.h"
23
24#include <ir/OperandIndexMap.h>
25#include <ir/OperandInfo.h>
26
28{
29
31{
32public:
33 // Minimum alignment for buffers
34 //
35 // _align is equal to EIGEN_MAX_ALIGN_BYTES, though including Eigen headers
36 // here to get that symbol may not be a good idea.
37 static constexpr uint64_t _align = 16;
38
39public:
40 TensorManager(const std::shared_ptr<TensorRegistry> &reg, uint32_t optim_vars_count);
41 virtual ~TensorManager() = default;
42
49 // TODO Add member functions to deallocate tensors
50
51 void claimNonConstPlan(const ir::OperandIndex &ind);
53 void claimTrainablePlan(const ir::OperandIndex &ind);
55 void claimBackPropPlan(const ir::OperandIndex &ind);
57 void claimGradientPlan(const ir::OperandIndex &ind);
63
64private:
65 std::unique_ptr<MemoryManager> _nonconst_mgr;
66 std::unique_ptr<TrainableMemoryManager> _trainable_mgr;
67 std::unique_ptr<MemoryManager> _back_prop_mgr;
68 std::unique_ptr<MemoryManager> _gradient_mgr;
69 std::unique_ptr<DisposableMemoryManager> _disposable_back_prop_mgr;
70 std::unique_ptr<LayerScopeMemoryManager> _layer_scope_mgr;
71 const std::shared_ptr<TensorRegistry> _tensors;
72};
73
74} // namespace onert::backend::train
75
76#endif // __ONERT_BACKEND_TRAIN_TENSOR_MANAGER_H__
This file contains OperandInfo class.
Class that is index of DisposableTensor.
void releaseBackPropPlan(const ir::OperandIndex &ind)
void releaseGradientPlan(const ir::OperandIndex &ind)
void releaseNonConstPlan(const ir::OperandIndex &ind)
void claimNonConstPlan(const ir::OperandIndex &ind)
void claimTrainablePlan(const ir::OperandIndex &ind)
void claimGradientPlan(const ir::OperandIndex &ind)
static constexpr uint64_t _align
void releaseLayerScopePlan(const LayerScopeTensorIndex &ind)
void claimBackPropPlan(const ir::OperandIndex &ind)
void claimLayerScopePlan(const LayerScopeTensorIndex &ind)
void claimDisposableBackPropPlan(const DisposableTensorIndex &ind)
void releaseDisposableBackPropPlan(const DisposableTensorIndex &ind)
void releaseTrainablePlan(const ir::OperandIndex &ind)