ONE - On-device Neural Engine
Loading...
Searching...
No Matches
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
29namespace onert
30{
31namespace backend
32{
33namespace builtin
34{
35
37{
38public:
39 KernelGenerator(const ir::Graph &graph, DynamicTensorManager *dyn_tensor_manager,
40 const std::shared_ptr<TensorRegistry> &tensor_reg,
41 const std::shared_ptr<ExternalContext> &external_context);
42
43 void setTensorRegistries(const compiler::TensorRegistries &tensor_registries)
44 {
45 _tensor_registries = tensor_registries;
46 }
47 void setExecutors(const std::shared_ptr<exec::IExecutors> &executors)
48 {
49 // FIXME Using shared_ptr's raw pointer!
50 _executors = executors.get();
51 }
52
53 void setModelIndex(const ir::ModelIndex &index) { _model_index = index; }
54
55 std::unique_ptr<exec::FunctionSequence> generate(ir::OperationIndex ind) override;
56
57private:
58 void visit(const ir::operation::If &) override;
59 void visit(const ir::operation::Permute &) override;
60 void visit(const ir::operation::While &) override;
61
62private:
63 backend::ITensor *getTensor(const ir::OperandIndex &index);
64 backend::IPortableTensor *getPortableTensor(const ir::OperandIndex &index);
65
66private:
67 DynamicTensorManager *_dyn_tensor_manager;
68 std::shared_ptr<TensorRegistry> _tensor_reg;
69 compiler::TensorRegistries _tensor_registries;
70 exec::IExecutors *_executors;
71 ir::ModelIndex _model_index;
72 const std::shared_ptr<ExternalContext> _external_context;
73};
74
75} // namespace builtin
76} // namespace backend
77} // namespace onert
78
79#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:31
Class to represent Permute operation.
Definition Permute.h:56