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