2 * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef __ONERT_BACKEND_CPU_KERNEL_GENERATOR_H__
18 #define __ONERT_BACKEND_CPU_KERNEL_GENERATOR_H__
20 #include "ExternalContext.h"
21 #include "TensorBuilder.h"
22 #include "backend/cpu_common/TensorRegistry.h"
25 #include <backend/CustomKernelBuilder.h>
26 #include <backend/IKernelGenerator.h>
27 #include <ir/Operands.h>
28 #include <ir/Operations.h>
37 class KernelGenerator : public IKernelGenerator
40 KernelGenerator(const ir::Operands &operands_ctx, const ir::Operations &operations_ctx,
41 const std::shared_ptr<TensorBuilder> &tensor_builder,
42 const std::shared_ptr<cpu_common::TensorRegistry> &tensor_reg,
43 const std::shared_ptr<custom::IKernelBuilder> &kernel_builder,
44 const std::shared_ptr<ExternalContext> &external_context);
46 using IKernelGenerator::visit;
48 void visit(const ir::OpSequence &) override;
49 void visit(const ir::operation::Conv2D &) override;
50 void visit(const ir::operation::DepthwiseConv2D &) override;
51 void visit(const ir::operation::Concat &) override;
52 void visit(const ir::operation::Fill &) override;
53 void visit(const ir::operation::FullyConnected &) override;
54 void visit(const ir::operation::Reshape &) override;
55 void visit(const ir::operation::Squeeze &) override;
56 void visit(const ir::operation::Softmax &) override;
57 void visit(const ir::operation::Comparison &) override;
58 void visit(const ir::operation::BinaryArithmetic &) override;
59 void visit(const ir::operation::Einsum &) override;
60 void visit(const ir::operation::Gather &) override;
61 void visit(const ir::operation::Custom &node) override;
62 void visit(const ir::operation::ElementwiseActivation &) override;
63 void visit(const ir::operation::ElementwiseBinary &) override;
64 void visit(const ir::operation::ElementwiseUnary &) override;
65 void visit(const ir::operation::ExpandDims &) override;
66 void visit(const ir::operation::Pad &) override;
67 void visit(const ir::operation::Pack &) override;
68 void visit(const ir::operation::Unpack &) override;
69 void visit(const ir::operation::OneHot &) override;
70 void visit(const ir::operation::Transpose &) override;
71 void visit(const ir::operation::Reduce &) override;
72 void visit(const ir::operation::Select &) override;
73 void visit(const ir::operation::Slice &) override;
74 void visit(const ir::operation::StridedSlice &) override;
75 void visit(const ir::operation::Split &) override;
76 void visit(const ir::operation::Shape &) override;
77 void visit(const ir::operation::ResizeBilinear &node) override;
78 void visit(const ir::operation::Reverse &) override;
79 void visit(const ir::operation::ArgMax &) override;
80 void visit(const ir::operation::Pool2D &) override;
81 void visit(const ir::operation::Pow &) override;
82 void visit(const ir::operation::SquaredDifference &) override;
83 void visit(const ir::operation::Tile &) override;
84 void visit(const ir::operation::L2Normalization &) override;
85 void visit(const ir::operation::Range &) override;
86 void visit(const ir::operation::Rank &) override;
87 void visit(const ir::operation::MatrixBandPart &) override;
88 void visit(const ir::operation::BatchMatMul &) override;
89 void visit(const ir::operation::BatchToSpaceND &) override;
90 void visit(const ir::operation::BroadcastTo &) override;
91 void visit(const ir::operation::FusedBatchNorm &) override;
92 void visit(const ir::operation::LogSoftmax &) override;
93 void visit(const ir::operation::SpaceToBatchND &) override;
94 void visit(const ir::operation::SpaceToDepth &) override;
95 void visit(const ir::operation::StatelessRandomUniform &) override;
96 void visit(const ir::operation::SplitV &) override;
99 const ir::Operands &_ctx;
100 const ir::Operations &_operations_ctx;
101 std::shared_ptr<TensorBuilder> _tensor_builder;
102 std::shared_ptr<cpu_common::TensorRegistry> _tensor_reg;
103 std::shared_ptr<backend::custom::IKernelBuilder> _kernel_builder;
104 ir::Layout _current_op_seq_layout;
105 const std::shared_ptr<ExternalContext> _external_context;
109 } // namespace backend
112 #endif // __ONERT_BACKEND_CPU_KERNEL_GENERATOR_H__