2 * Copyright (c) 2019 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_KERNEL_CPU_DEPTHWISECONVOLUTIONLAYER_H__
18 #define __ONERT_KERNEL_CPU_DEPTHWISECONVOLUTIONLAYER_H__
20 #include <backend/IPortableTensor.h>
21 #include "OperationUtils.h"
22 #include "../ExternalContext.h"
24 #include <exec/IFunction.h>
35 class DepthwiseConvolutionLayer : public ::onert::exec::IFunction
38 DepthwiseConvolutionLayer() = default;
43 void convQ8uPerTensor();
44 void convQ8uPerChannel();
48 void configure(const IPortableTensor *input, const IPortableTensor *kernel,
49 const IPortableTensor *bias, const uint32_t paddingLeft,
50 const uint32_t paddingRight, const uint32_t paddingTop,
51 const uint32_t paddingBottom, const uint32_t strideW, const uint32_t strideH,
52 const uint32_t multiplier, const uint32_t dilationWidth,
53 const uint32_t dilationHeight, const ir::Activation activation,
54 IPortableTensor *output, const std::shared_ptr<ExternalContext> &external_context);
60 void prepareQ8uPerChannel();
63 const IPortableTensor *_input{nullptr};
64 const IPortableTensor *_kernel{nullptr};
65 const IPortableTensor *_bias{nullptr};
66 IPortableTensor *_output{nullptr};
68 uint32_t _paddingLeft{0};
69 uint32_t _paddingTop{0};
70 uint32_t _paddingRight{0};
71 uint32_t _paddingBottom{0};
73 uint32_t _strideWidth{0};
74 uint32_t _strideHeight{0};
76 uint32_t _multiplier{0};
78 uint32_t _dilationWidth{1};
79 uint32_t _dilationHeight{1};
81 ir::Activation _activation{ir::Activation::NONE};
83 std::shared_ptr<ExternalContext> _external_context;
85 bool _prepared{false};
87 // Per channel output multiplier and shift.
88 std::vector<int32_t> _per_channel_output_multiplier;
89 std::vector<int> _per_channel_output_shift;
94 } // namespace backend
97 #endif // __ONERT_KERNEL_CPU_DEPTHWISECONVOLUTIONLAYER_H__