Imported Upstream version 1.12.0
[platform/core/ml/nnfw.git] / runtime / onert / backend / xnnpack / KernelGenerator.h
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_XNNPACK_KERNEL_GENERATOR_H__
18 #define __ONERT_BACKEND_XNNPACK_KERNEL_GENERATOR_H__
19
20 #include "ExternalContext.h"
21 #include "TensorBuilder.h"
22 #include "backend/cpu_common/TensorRegistry.h"
23 #include "Tensor.h"
24
25 #include <backend/CustomKernelBuilder.h>
26 #include <backend/cpu_common/KernelGeneratorBase.h>
27 #include <ir/Operands.h>
28 #include <ir/Operations.h>
29
30 namespace onert
31 {
32 namespace backend
33 {
34 namespace xnnpack
35 {
36
37 class KernelGenerator : public cpu_common::KernelGeneratorBase
38 {
39 public:
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);
45
46   void visit(const ir::OpSequence &) override;
47   void visit(const ir::operation::Conv2D &) override;
48   void visit(const ir::operation::DepthwiseConv2D &) override;
49   void visit(const ir::operation::FullyConnected &) override;
50
51 private:
52   const ir::Operands &_ctx;
53   const ir::Operations &_operations_ctx;
54   std::shared_ptr<TensorBuilder> _tensor_builder;
55   std::shared_ptr<cpu_common::TensorRegistry> _tensor_reg;
56   std::shared_ptr<backend::custom::IKernelBuilder> _kernel_builder;
57   ir::Layout _current_layout;
58   const std::shared_ptr<ExternalContext> _external_context;
59 };
60
61 } // namespace xnnpack
62 } // namespace backend
63 } // namespace onert
64
65 #endif // __ONERT_BACKEND_XNNPACK_KERNEL_GENERATOR_H__