ONE - On-device Neural Engine
Loading...
Searching...
No Matches
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
27namespace onert
28{
29namespace backend
30{
31namespace train
32{
33
35{
36public:
37 // Minimum alignment for buffers
38 //
39 // _align is equal to EIGEN_MAX_ALIGN_BYTES, though including Eigen headers
40 // here to get that symbol may not be a good idea.
41 static constexpr uint64_t _align = 16;
42
43public:
44 TensorManager(const std::shared_ptr<TensorRegistry> &reg, uint32_t optim_vars_count);
45 virtual ~TensorManager() = default;
46
53 // TODO Add member functions to deallocate tensors
54
55 void claimNonConstPlan(const ir::OperandIndex &ind);
57 void claimTrainablePlan(const ir::OperandIndex &ind);
59 void claimBackPropPlan(const ir::OperandIndex &ind);
61 void claimGradientPlan(const ir::OperandIndex &ind);
67
68private:
69 std::unique_ptr<MemoryManager> _nonconst_mgr;
70 std::unique_ptr<TrainableMemoryManager> _trainable_mgr;
71 std::unique_ptr<MemoryManager> _back_prop_mgr;
72 std::unique_ptr<MemoryManager> _gradient_mgr;
73 std::unique_ptr<DisposableMemoryManager> _disposable_back_prop_mgr;
74 std::unique_ptr<LayerScopeMemoryManager> _layer_scope_mgr;
75 const std::shared_ptr<TensorRegistry> _tensors;
76};
77
78} // namespace train
79} // namespace backend
80} // namespace onert
81
82#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)