ONE - On-device Neural Engine
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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
31{
32
34{
35public:
36 TensorBuilder(const std::shared_ptr<TensorRegistry> &tensor_reg,
37 const ir::OperandIndexMap<ir::OperandIndex> &shared_memory_operand_indexes = {});
38 TensorBuilder(const std::shared_ptr<TensorRegistry> &tensor_reg, const std::string planner_id,
39 const ir::OperandIndexMap<ir::OperandIndex> &shared_memory_operand_indexes = {});
40
47
48 void notifyFirstUse(const ir::OperandIndex &);
49 void notifyLastUse(const ir::OperandIndex &);
50
51 bool isRegistered(const ir::OperandIndex &) const;
52
53 void allocate(void);
54
56
57 DynamicTensorManager *dynamicTensorManager(void) { return _dynamic_tensor_mgr.get(); }
58
59private:
60 const std::shared_ptr<TensorRegistry> _tensor_reg;
61 std::unique_ptr<DynamicTensorManager> _dynamic_tensor_mgr;
62 std::unique_ptr<StaticTensorManager> _static_tensor_mgr;
64 ir::OperandIndexMap<ir::OperandIndex> _shared_memory_operand_indexes;
65};
66
67} // namespace onert::backend::basic
68
69#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:54
volatile const char info[]
std::unordered_map< OperandIndex, T > OperandIndexMap