Imported Upstream version 1.12.0
[platform/core/ml/nnfw.git] / runtime / onert / backend / cpu / ops / DepthwiseConvolutionLayer.h
1 /*
2  * Copyright (c) 2019 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_KERNEL_CPU_DEPTHWISECONVOLUTIONLAYER_H__
18 #define __ONERT_KERNEL_CPU_DEPTHWISECONVOLUTIONLAYER_H__
19
20 #include <backend/IPortableTensor.h>
21 #include "OperationUtils.h"
22 #include "../ExternalContext.h"
23
24 #include <exec/IFunction.h>
25
26 namespace onert
27 {
28 namespace backend
29 {
30 namespace cpu
31 {
32 namespace ops
33 {
34
35 class DepthwiseConvolutionLayer : public ::onert::exec::IFunction
36 {
37 public:
38   DepthwiseConvolutionLayer() = default;
39
40 public:
41   void convFloat32();
42
43   void convQuant8();
44
45   void configure(const IPortableTensor *input, const IPortableTensor *kernel,
46                  const IPortableTensor *bias, const uint32_t paddingLeft,
47                  const uint32_t paddingRight, const uint32_t paddingTop,
48                  const uint32_t paddingBottom, const uint32_t strideW, const uint32_t strideH,
49                  const uint32_t multiplier, const uint32_t dilationWidth,
50                  const uint32_t dilationHeight, const ir::Activation activation,
51                  IPortableTensor *output, const std::shared_ptr<ExternalContext> &external_context);
52
53   void run() override;
54
55 private:
56   const IPortableTensor *_input{nullptr};
57   const IPortableTensor *_kernel{nullptr};
58   const IPortableTensor *_bias{nullptr};
59   IPortableTensor *_output{nullptr};
60
61   uint32_t _paddingLeft{0};
62   uint32_t _paddingTop{0};
63   uint32_t _paddingRight{0};
64   uint32_t _paddingBottom{0};
65
66   uint32_t _strideWidth{0};
67   uint32_t _strideHeight{0};
68
69   uint32_t _multiplier{0};
70
71   uint32_t _dilationWidth{1};
72   uint32_t _dilationHeight{1};
73
74   ir::Activation _activation{ir::Activation::NONE};
75
76   std::shared_ptr<ExternalContext> _external_context;
77 };
78
79 } // namespace ops
80 } // namespace cpu
81 } // namespace backend
82 } // namespace onert
83
84 #endif // __ONERT_KERNEL_CPU_DEPTHWISECONVOLUTIONLAYER_H__