ONE - On-device Neural Engine
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
KernelGenerator.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020 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_BUILTIN_KERNEL_GENERATOR_H__
18#define __ONERT_BACKEND_BUILTIN_KERNEL_GENERATOR_H__
19
21#include "ExternalContext.h"
22#include "TensorRegistry.h"
23#include "../../compiler/TensorRegistries.h"
24
26#include "exec/IExecutors.h"
27#include "ir/Graph.h"
28
30{
31
33{
34public:
35 KernelGenerator(const ir::Graph &graph, DynamicTensorManager *dyn_tensor_manager,
36 const std::shared_ptr<TensorRegistry> &tensor_reg,
37 const std::shared_ptr<ExternalContext> &external_context);
38
39 void setTensorRegistries(const compiler::TensorRegistries &tensor_registries)
40 {
41 _tensor_registries = tensor_registries;
42 }
43 void setExecutors(const std::shared_ptr<exec::IExecutors> &executors)
44 {
45 // FIXME Using shared_ptr's raw pointer!
46 _executors = executors.get();
47 }
48
49 void setModelIndex(const ir::ModelIndex &index) { _model_index = index; }
50
51 std::unique_ptr<exec::FunctionSequence> generate(ir::OperationIndex ind) override;
52
53private:
54 void visit(const ir::operation::If &) override;
55 void visit(const ir::operation::Permute &) override;
56 void visit(const ir::operation::While &) override;
57
58private:
59 backend::ITensor *getTensor(const ir::OperandIndex &index);
60 backend::IPortableTensor *getPortableTensor(const ir::OperandIndex &index);
61
62private:
63 DynamicTensorManager *_dyn_tensor_manager;
64 std::shared_ptr<TensorRegistry> _tensor_reg;
65 compiler::TensorRegistries _tensor_registries;
66 exec::IExecutors *_executors;
67 ir::ModelIndex _model_index;
68 const std::shared_ptr<ExternalContext> _external_context;
69};
70
71} // namespace onert::backend::builtin
72
73#endif // __ONERT_BACKEND_BUILTIN_KERNEL_GENERATOR_H__
A tensor class that is portable for other backends.
Class to manage dynamic tensor and its memory.
void setTensorRegistries(const compiler::TensorRegistries &tensor_registries)
std::unique_ptr< exec::FunctionSequence > generate(ir::OperationIndex ind) override
void setModelIndex(const ir::ModelIndex &index)
void setExecutors(const std::shared_ptr< exec::IExecutors > &executors)
Class to gather NN package's executor set.
Definition IExecutors.h:29
Class to represent Permute operation.
Definition Permute.h:49