ONE - On-device Neural Engine
Loading...
Searching...
No Matches
DepthwiseConvolutionLayer.h
Go to the documentation of this file.
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
21#include "OperationUtils.h"
22#include "../ExternalContext.h"
23
24#include <exec/IFunction.h>
25
27{
28
30{
31public:
33
34public:
35 void convFloat32();
36
37 void convQ8uPerTensor();
38 void convQ8uPerChannel();
39
40 void convQ8i();
42
43 void configure(const IPortableTensor *input, const IPortableTensor *kernel,
44 const IPortableTensor *bias, const uint32_t paddingLeft,
45 const uint32_t paddingRight, const uint32_t paddingTop,
46 const uint32_t paddingBottom, const uint32_t strideW, const uint32_t strideH,
47 const uint32_t multiplier, const uint32_t dilationWidth,
48 const uint32_t dilationHeight, const ir::Activation activation,
49 IPortableTensor *output, const std::shared_ptr<ExternalContext> &external_context);
50
51 void run() override;
52
53private:
54 void prepareQ8i();
55 void prepareQ8uPerChannel();
56 void prepareQ8iHybridPerChannel();
57 void ensureQ8iHybridPerChannel();
58
59protected:
60 const IPortableTensor *_input{nullptr};
61 const IPortableTensor *_kernel{nullptr};
62 const IPortableTensor *_bias{nullptr};
64
65 uint32_t _paddingLeft{0};
66 uint32_t _paddingTop{0};
67 uint32_t _paddingRight{0};
68 uint32_t _paddingBottom{0};
69
70 uint32_t _strideWidth{0};
71 uint32_t _strideHeight{0};
72
73 uint32_t _multiplier{0};
74
75 uint32_t _dilationWidth{1};
76 uint32_t _dilationHeight{1};
77
79
80private:
81 std::shared_ptr<ExternalContext> _external_context;
82
83 bool _prepared{false};
84
85 // Per channel output multiplier and shift.
86 std::vector<int32_t> _per_channel_output_multiplier;
87 std::vector<int> _per_channel_output_shift;
88
89 // For hybrid
90 bool _is_hybrid{false};
91 std::vector<int8_t> _input_quantized;
92 std::vector<float> _input_scaling_factors;
93 std::vector<int32_t> _input_offsets;
94};
95
96} // namespace onert::backend::cpu::ops
97
98#endif // __ONERT_KERNEL_CPU_DEPTHWISECONVOLUTIONLAYER_H__
A tensor class that is portable for other backends.
void configure(const IPortableTensor *input, const IPortableTensor *kernel, const IPortableTensor *bias, const uint32_t paddingLeft, const uint32_t paddingRight, const uint32_t paddingTop, const uint32_t paddingBottom, const uint32_t strideW, const uint32_t strideH, const uint32_t multiplier, const uint32_t dilationWidth, const uint32_t dilationHeight, const ir::Activation activation, IPortableTensor *output, const std::shared_ptr< ExternalContext > &external_context)