ONE - On-device Neural Engine
Loading...
Searching...
No Matches
TensorBuilder.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018 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_TENSOR_BUILDER_H__
18#define __ONERT_BACKEND_BASIC_TENSOR_BUILDER_H__
19
23
24#include <ir/OperandIndexMap.h>
25
26#include "Tensor.h"
27
28#include <unordered_map>
29
30namespace onert
31{
32namespace backend
33{
34namespace basic
35{
36
38{
39public:
40 TensorBuilder(const std::shared_ptr<TensorRegistry> &tensor_reg,
41 const ir::OperandIndexMap<ir::OperandIndex> &shared_memory_operand_indexes = {});
42 TensorBuilder(const std::shared_ptr<TensorRegistry> &tensor_reg, const std::string planner_id,
43 const ir::OperandIndexMap<ir::OperandIndex> &shared_memory_operand_indexes = {});
44
51
52 void notifyFirstUse(const ir::OperandIndex &);
53 void notifyLastUse(const ir::OperandIndex &);
54
55 bool isRegistered(const ir::OperandIndex &) const;
56
57 void allocate(void);
58
60
61 DynamicTensorManager *dynamicTensorManager(void) { return _dynamic_tensor_mgr.get(); }
62
63private:
64 const std::shared_ptr<TensorRegistry> _tensor_reg;
65 std::unique_ptr<DynamicTensorManager> _dynamic_tensor_mgr;
66 std::unique_ptr<StaticTensorManager> _static_tensor_mgr;
68 ir::OperandIndexMap<ir::OperandIndex> _shared_memory_operand_indexes;
69};
70
71} // namespace basic
72} // namespace backend
73} // namespace onert
74
75#endif // __ONERT_BACKEND_BASIC_TENSOR_BUILDER_H__
Class to manage dynamic tensor and its memory.
void registerTensorInfo(const ir::OperandIndex &ind, const ir::OperandInfo &info)
Register tensor information to allocate on CPU backend.
DynamicTensorManager * dynamicTensorManager(void)
void notifyLastUse(const ir::OperandIndex &)
const ir::OperandIndexMap< ir::OperandIndex > & getSharedMemoryOperandIndexes() const
void notifyFirstUse(const ir::OperandIndex &)
bool isRegistered(const ir::OperandIndex &) const
Class to save tensor's shape and type.
Definition OperandInfo.h:56
volatile const char info[]
std::unordered_map< OperandIndex, T > OperandIndexMap