1*c217d954SCole Faust /*
2*c217d954SCole Faust * Copyright (c) 2021-2022 Arm Limited.
3*c217d954SCole Faust *
4*c217d954SCole Faust * SPDX-License-Identifier: MIT
5*c217d954SCole Faust *
6*c217d954SCole Faust * Permission is hereby granted, free of charge, to any person obtaining a copy
7*c217d954SCole Faust * of this software and associated documentation files (the "Software"), to
8*c217d954SCole Faust * deal in the Software without restriction, including without limitation the
9*c217d954SCole Faust * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10*c217d954SCole Faust * sell copies of the Software, and to permit persons to whom the Software is
11*c217d954SCole Faust * furnished to do so, subject to the following conditions:
12*c217d954SCole Faust *
13*c217d954SCole Faust * The above copyright notice and this permission notice shall be included in all
14*c217d954SCole Faust * copies or substantial portions of the Software.
15*c217d954SCole Faust *
16*c217d954SCole Faust * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17*c217d954SCole Faust * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18*c217d954SCole Faust * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19*c217d954SCole Faust * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20*c217d954SCole Faust * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21*c217d954SCole Faust * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22*c217d954SCole Faust * SOFTWARE.
23*c217d954SCole Faust */
24*c217d954SCole Faust #include "src/cpu/kernels/internal/CpuDepthwiseConv2dAssemblyWrapperKernel.h"
25*c217d954SCole Faust
26*c217d954SCole Faust #include "arm_compute/core/Utils.h"
27*c217d954SCole Faust #include "arm_compute/core/Validate.h"
28*c217d954SCole Faust #include "arm_compute/core/utils/misc/ShapeCalculator.h"
29*c217d954SCole Faust #include "arm_compute/core/utils/quantization/AsymmHelpers.h"
30*c217d954SCole Faust #include "src/core/CPP/Validate.h"
31*c217d954SCole Faust #include "src/core/helpers/AutoConfiguration.h"
32*c217d954SCole Faust #include "src/core/helpers/WindowHelpers.h"
33*c217d954SCole Faust #include "src/core/utils/AssemblyUtils.h"
34*c217d954SCole Faust
35*c217d954SCole Faust #include "src/core/NEON/kernels/assembly/depthwise.hpp"
36*c217d954SCole Faust
37*c217d954SCole Faust #include "depthwise_common.hpp"
38*c217d954SCole Faust
39*c217d954SCole Faust #include <arm_neon.h>
40*c217d954SCole Faust
41*c217d954SCole Faust namespace arm_compute
42*c217d954SCole Faust {
43*c217d954SCole Faust namespace cpu
44*c217d954SCole Faust {
45*c217d954SCole Faust namespace kernels
46*c217d954SCole Faust {
47*c217d954SCole Faust using namespace arm_compute::misc::shape_calculator;
48*c217d954SCole Faust
49*c217d954SCole Faust namespace
50*c217d954SCole Faust {
51*c217d954SCole Faust constexpr unsigned int idx_width = 1;
52*c217d954SCole Faust constexpr unsigned int idx_height = 2;
53*c217d954SCole Faust constexpr unsigned int idx_channels = 0;
54*c217d954SCole Faust constexpr unsigned int idx_batches = 3;
55*c217d954SCole Faust
56*c217d954SCole Faust template <typename TSrc, typename TWeights, typename TDst>
create_arm_dwc(const ITensorInfo * src,const ITensorInfo * weights,ITensorInfo * dst,const ConvolutionInfo & info,const CPUInfo & cpu_info,std::unique_ptr<arm_conv::depthwise::IDepthwiseCommon> & kernel,std::string & _name)57*c217d954SCole Faust void create_arm_dwc(const ITensorInfo *src, const ITensorInfo *weights, ITensorInfo *dst,
58*c217d954SCole Faust const ConvolutionInfo &info, const CPUInfo &cpu_info,
59*c217d954SCole Faust std::unique_ptr<arm_conv::depthwise::IDepthwiseCommon> &kernel, std::string &_name)
60*c217d954SCole Faust {
61*c217d954SCole Faust unsigned int stride_cols{};
62*c217d954SCole Faust unsigned int stride_rows{};
63*c217d954SCole Faust std::tie(stride_cols, stride_rows) = info.pad_stride_info.stride();
64*c217d954SCole Faust
65*c217d954SCole Faust const arm_conv::PaddingValues padding = assembly_utils::map_to_arm_conv_padding(info.pad_stride_info);
66*c217d954SCole Faust
67*c217d954SCole Faust const unsigned int n_batches = src->dimension(idx_batches);
68*c217d954SCole Faust const unsigned int src_rows = src->dimension(idx_height);
69*c217d954SCole Faust const unsigned int src_cols = src->dimension(idx_width);
70*c217d954SCole Faust const unsigned int n_channels = src->dimension(idx_channels);
71*c217d954SCole Faust const unsigned int dst_rows = dst->dimension(idx_height);
72*c217d954SCole Faust const unsigned int dst_cols = dst->dimension(idx_width);
73*c217d954SCole Faust
74*c217d954SCole Faust const unsigned int kernel_cols = weights->dimension(idx_width);
75*c217d954SCole Faust const unsigned int kernel_rows = weights->dimension(idx_height);
76*c217d954SCole Faust
77*c217d954SCole Faust const arm_gemm::Activation activation = assembly_utils::map_to_arm_gemm_activation(info.act_info);
78*c217d954SCole Faust
79*c217d954SCole Faust arm_conv::depthwise::DepthwiseArgs args(&cpu_info, kernel_rows, kernel_cols, stride_rows, stride_cols,
80*c217d954SCole Faust n_batches, src_rows, src_cols, n_channels, dst_rows, dst_cols, info.depth_multiplier,
81*c217d954SCole Faust padding, activation, nullptr);
82*c217d954SCole Faust
83*c217d954SCole Faust // Configure assembly pooling kernel
84*c217d954SCole Faust auto dwc_kernel_asm = arm_conv::depthwise::depthwise<TSrc, TWeights, TDst>(args);
85*c217d954SCole Faust if(dwc_kernel_asm == nullptr)
86*c217d954SCole Faust {
87*c217d954SCole Faust // Configuration not supported: Leave function unconfigured:
88*c217d954SCole Faust return;
89*c217d954SCole Faust }
90*c217d954SCole Faust
91*c217d954SCole Faust _name = dwc_kernel_asm->name();
92*c217d954SCole Faust kernel = std::move(dwc_kernel_asm);
93*c217d954SCole Faust }
94*c217d954SCole Faust
95*c217d954SCole Faust template <typename TSrc, typename TWeights, typename TDst>
create_arm_dwc_quant(const ITensorInfo * src,const ITensorInfo * weights,ITensorInfo * dst,const ConvolutionInfo & info,const CPUInfo & cpu_info,std::unique_ptr<arm_conv::depthwise::IDepthwiseCommon> & kernel,std::vector<int32_t> & multipliers,std::vector<int32_t> & right_shifts,std::vector<int32_t> & left_shifts,std::string & _name)96*c217d954SCole Faust void create_arm_dwc_quant(const ITensorInfo *src, const ITensorInfo *weights, ITensorInfo *dst,
97*c217d954SCole Faust const ConvolutionInfo &info, const CPUInfo &cpu_info,
98*c217d954SCole Faust std::unique_ptr<arm_conv::depthwise::IDepthwiseCommon> &kernel,
99*c217d954SCole Faust std::vector<int32_t> &multipliers, std::vector<int32_t> &right_shifts, std::vector<int32_t> &left_shifts,
100*c217d954SCole Faust std::string &_name)
101*c217d954SCole Faust {
102*c217d954SCole Faust unsigned int stride_cols{};
103*c217d954SCole Faust unsigned int stride_rows{};
104*c217d954SCole Faust std::tie(stride_cols, stride_rows) = info.pad_stride_info.stride();
105*c217d954SCole Faust
106*c217d954SCole Faust const arm_conv::PaddingValues padding = assembly_utils::map_to_arm_conv_padding(info.pad_stride_info);
107*c217d954SCole Faust
108*c217d954SCole Faust const unsigned int n_batches = src->dimension(idx_batches);
109*c217d954SCole Faust const unsigned int src_rows = src->dimension(idx_height);
110*c217d954SCole Faust const unsigned int src_cols = src->dimension(idx_width);
111*c217d954SCole Faust const unsigned int n_channels = src->dimension(idx_channels);
112*c217d954SCole Faust const unsigned int dst_rows = dst->dimension(idx_height);
113*c217d954SCole Faust const unsigned int dst_cols = dst->dimension(idx_width);
114*c217d954SCole Faust
115*c217d954SCole Faust const unsigned int kernel_cols = weights->dimension(idx_width);
116*c217d954SCole Faust const unsigned int kernel_rows = weights->dimension(idx_height);
117*c217d954SCole Faust
118*c217d954SCole Faust const arm_gemm::Activation activation = assembly_utils::map_to_arm_gemm_activation(info.act_info);
119*c217d954SCole Faust
120*c217d954SCole Faust arm_conv::depthwise::DepthwiseArgs args(&cpu_info, kernel_rows, kernel_cols, stride_rows, stride_cols,
121*c217d954SCole Faust n_batches, src_rows, src_cols, n_channels, dst_rows, dst_cols, info.depth_multiplier,
122*c217d954SCole Faust padding, activation, nullptr);
123*c217d954SCole Faust
124*c217d954SCole Faust const auto src_qinfo = src->quantization_info().uniform();
125*c217d954SCole Faust const auto weights_qinfo = weights->quantization_info();
126*c217d954SCole Faust const auto dst_qinfo = dst->quantization_info().uniform();
127*c217d954SCole Faust
128*c217d954SCole Faust const unsigned int num_filters = weights_qinfo.scale().size();
129*c217d954SCole Faust
130*c217d954SCole Faust multipliers.resize(num_filters);
131*c217d954SCole Faust std::vector<int32_t> dst_shifts(num_filters);
132*c217d954SCole Faust quantization::compute_quantized_multipliers_and_shifts(src,
133*c217d954SCole Faust weights,
134*c217d954SCole Faust dst,
135*c217d954SCole Faust multipliers.data(),
136*c217d954SCole Faust dst_shifts.data());
137*c217d954SCole Faust
138*c217d954SCole Faust // Quantize activation bounds
139*c217d954SCole Faust int32_t min_activation = std::numeric_limits<TSrc>::lowest();
140*c217d954SCole Faust int32_t max_activation = std::numeric_limits<TSrc>::max();
141*c217d954SCole Faust if(info.act_info.enabled())
142*c217d954SCole Faust {
143*c217d954SCole Faust std::tie(min_activation, max_activation) = get_quantized_activation_min_max(info.act_info, src->data_type(), dst_qinfo);
144*c217d954SCole Faust }
145*c217d954SCole Faust
146*c217d954SCole Faust // Set quantization parameters for assembly kernels
147*c217d954SCole Faust arm_gemm::Requantize32 requant_args{};
148*c217d954SCole Faust if(is_data_type_quantized_per_channel(weights->data_type()))
149*c217d954SCole Faust {
150*c217d954SCole Faust left_shifts.resize(num_filters);
151*c217d954SCole Faust right_shifts.resize(num_filters);
152*c217d954SCole Faust bool need_left_shift = false; // Select more optimized path if left shift is not needed
153*c217d954SCole Faust for(unsigned int i = 0; i < num_filters; ++i)
154*c217d954SCole Faust {
155*c217d954SCole Faust left_shifts[i] = std::max(-dst_shifts[i], static_cast<int32_t>(0));
156*c217d954SCole Faust right_shifts[i] = std::min(-dst_shifts[i], static_cast<int32_t>(0));
157*c217d954SCole Faust if(dst_shifts[i] < 0 && !need_left_shift)
158*c217d954SCole Faust {
159*c217d954SCole Faust need_left_shift = true;
160*c217d954SCole Faust }
161*c217d954SCole Faust }
162*c217d954SCole Faust
163*c217d954SCole Faust requant_args = arm_gemm::Requantize32(nullptr,
164*c217d954SCole Faust 0,
165*c217d954SCole Faust src_qinfo.offset,
166*c217d954SCole Faust weights_qinfo.uniform().offset,
167*c217d954SCole Faust dst_qinfo.offset,
168*c217d954SCole Faust (need_left_shift) ? left_shifts.data() : nullptr,
169*c217d954SCole Faust right_shifts.data(),
170*c217d954SCole Faust multipliers.data(),
171*c217d954SCole Faust static_cast<TSrc>(min_activation),
172*c217d954SCole Faust static_cast<TSrc>(max_activation));
173*c217d954SCole Faust }
174*c217d954SCole Faust else
175*c217d954SCole Faust {
176*c217d954SCole Faust requant_args = arm_gemm::Requantize32(nullptr,
177*c217d954SCole Faust 0,
178*c217d954SCole Faust src_qinfo.offset,
179*c217d954SCole Faust weights_qinfo.uniform().offset,
180*c217d954SCole Faust dst_qinfo.offset,
181*c217d954SCole Faust -dst_shifts[0],
182*c217d954SCole Faust multipliers[0],
183*c217d954SCole Faust static_cast<TSrc>(min_activation),
184*c217d954SCole Faust static_cast<TSrc>(max_activation));
185*c217d954SCole Faust }
186*c217d954SCole Faust
187*c217d954SCole Faust // Configure assembly pooling kernel with requantization
188*c217d954SCole Faust auto dwc_kernel_asm = arm_conv::depthwise::depthwise<TSrc, TWeights, TDst, arm_gemm::Requantize32>(args, requant_args);
189*c217d954SCole Faust if(dwc_kernel_asm == nullptr)
190*c217d954SCole Faust {
191*c217d954SCole Faust // Configuration not supported: Leave function unconfigured:
192*c217d954SCole Faust return;
193*c217d954SCole Faust }
194*c217d954SCole Faust _name = dwc_kernel_asm->name();
195*c217d954SCole Faust kernel = std::move(dwc_kernel_asm);
196*c217d954SCole Faust }
197*c217d954SCole Faust } // namespace
198*c217d954SCole Faust
CpuDepthwiseConv2dAssemblyWrapperKernel()199*c217d954SCole Faust CpuDepthwiseConv2dAssemblyWrapperKernel::CpuDepthwiseConv2dAssemblyWrapperKernel()
200*c217d954SCole Faust : _kernel_asm(nullptr),
201*c217d954SCole Faust _multipliers(),
202*c217d954SCole Faust _left_shifts(),
203*c217d954SCole Faust _right_shifts(),
204*c217d954SCole Faust _name()
205*c217d954SCole Faust {
206*c217d954SCole Faust }
207*c217d954SCole Faust
208*c217d954SCole Faust CpuDepthwiseConv2dAssemblyWrapperKernel::~CpuDepthwiseConv2dAssemblyWrapperKernel() = default;
209*c217d954SCole Faust
configure(const ITensorInfo * src,const ITensorInfo * weights,const ITensorInfo *,ITensorInfo * dst,const ConvolutionInfo & info,const CPUInfo & cpu_info)210*c217d954SCole Faust void CpuDepthwiseConv2dAssemblyWrapperKernel::configure(const ITensorInfo *src, const ITensorInfo *weights, const ITensorInfo *, ITensorInfo *dst,
211*c217d954SCole Faust const ConvolutionInfo &info, const CPUInfo &cpu_info)
212*c217d954SCole Faust {
213*c217d954SCole Faust ARM_COMPUTE_UNUSED(cpu_info);
214*c217d954SCole Faust ARM_COMPUTE_ERROR_ON_NULLPTR(src, weights, dst);
215*c217d954SCole Faust
216*c217d954SCole Faust // Destination initialization if not yet initialized
217*c217d954SCole Faust const TensorShape dst_shape = compute_depthwise_convolution_shape(*src, *weights, info);
218*c217d954SCole Faust auto_init_if_empty(*dst, src->clone()->set_tensor_shape(dst_shape));
219*c217d954SCole Faust _name = "CpuDepthwiseConv2dAssemblyWrapperKernel";
220*c217d954SCole Faust std::string asm_kernel_name("");
221*c217d954SCole Faust #if defined(__aarch64__)
222*c217d954SCole Faust switch(src->data_type())
223*c217d954SCole Faust {
224*c217d954SCole Faust case DataType::QASYMM8:
225*c217d954SCole Faust if(is_data_type_quantized_per_channel(weights->data_type()))
226*c217d954SCole Faust {
227*c217d954SCole Faust create_arm_dwc_quant<uint8_t, int8_t, uint8_t>(src, weights, dst, info, cpu_info, _kernel_asm, _multipliers, _right_shifts, _left_shifts, asm_kernel_name);
228*c217d954SCole Faust }
229*c217d954SCole Faust else
230*c217d954SCole Faust {
231*c217d954SCole Faust create_arm_dwc_quant<uint8_t, uint8_t, uint8_t>(src, weights, dst, info, cpu_info, _kernel_asm, _multipliers, _right_shifts, _left_shifts, asm_kernel_name);
232*c217d954SCole Faust }
233*c217d954SCole Faust break;
234*c217d954SCole Faust case DataType::QASYMM8_SIGNED:
235*c217d954SCole Faust create_arm_dwc_quant<int8_t, int8_t, int8_t>(src, weights, dst, info, cpu_info, _kernel_asm, _multipliers, _right_shifts, _left_shifts, asm_kernel_name);
236*c217d954SCole Faust break;
237*c217d954SCole Faust #if defined(__ARM_FEATURE_FP16_VECTOR_ARITHMETIC)
238*c217d954SCole Faust case DataType::F16:
239*c217d954SCole Faust create_arm_dwc<float16_t, float16_t, float16_t>(src, weights, dst, info, cpu_info, _kernel_asm, asm_kernel_name);
240*c217d954SCole Faust break;
241*c217d954SCole Faust #endif // defined(__ARM_FEATURE_FP16_VECTOR_ARITHMETIC)
242*c217d954SCole Faust case DataType::F32:
243*c217d954SCole Faust create_arm_dwc<float, float, float>(src, weights, dst, info, cpu_info, _kernel_asm, asm_kernel_name);
244*c217d954SCole Faust break;
245*c217d954SCole Faust default:
246*c217d954SCole Faust break;
247*c217d954SCole Faust }
248*c217d954SCole Faust #endif // defined(__aarch64__)
249*c217d954SCole Faust
250*c217d954SCole Faust Window win = calculate_max_window(*dst, Steps());
251*c217d954SCole Faust ICpuKernel::configure(win);
252*c217d954SCole Faust if(_kernel_asm != nullptr)
253*c217d954SCole Faust {
254*c217d954SCole Faust _name += "/" + asm_kernel_name;
255*c217d954SCole Faust }
256*c217d954SCole Faust }
257*c217d954SCole Faust
validate(const ITensorInfo * src,const ITensorInfo * weights,const ITensorInfo * bias,const ITensorInfo * dst,const ConvolutionInfo & info)258*c217d954SCole Faust Status CpuDepthwiseConv2dAssemblyWrapperKernel::validate(const ITensorInfo *src, const ITensorInfo *weights, const ITensorInfo *bias, const ITensorInfo *dst, const ConvolutionInfo &info)
259*c217d954SCole Faust {
260*c217d954SCole Faust ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(src, dst);
261*c217d954SCole Faust
262*c217d954SCole Faust #if !defined(__aarch64__)
263*c217d954SCole Faust ARM_COMPUTE_RETURN_ERROR_MSG("32-bit is not supported by assembly kernels");
264*c217d954SCole Faust #endif // !defined(__aarch64__)
265*c217d954SCole Faust ARM_COMPUTE_RETURN_ERROR_ON_CPU_F16_UNSUPPORTED(src);
266*c217d954SCole Faust ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(src, 1, DataType::QASYMM8, DataType::QASYMM8_SIGNED, DataType::F16, DataType::F32);
267*c217d954SCole Faust ARM_COMPUTE_RETURN_ERROR_ON_MSG(src->data_layout() != DataLayout::NHWC, "Only NHWC is supported by assembly kernels");
268*c217d954SCole Faust ARM_COMPUTE_RETURN_ERROR_ON_MSG(info.dilation != Size2D(1, 1), "Assembly kernels do not support dilation != (1, 1)");
269*c217d954SCole Faust
270*c217d954SCole Faust if(is_data_type_quantized_per_channel(weights->data_type()))
271*c217d954SCole Faust {
272*c217d954SCole Faust ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(weights, 1, DataType::QSYMM8_PER_CHANNEL);
273*c217d954SCole Faust ARM_COMPUTE_RETURN_ERROR_ON(weights->dimension(0) != weights->quantization_info().scale().size());
274*c217d954SCole Faust }
275*c217d954SCole Faust else
276*c217d954SCole Faust {
277*c217d954SCole Faust ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(src, weights);
278*c217d954SCole Faust }
279*c217d954SCole Faust
280*c217d954SCole Faust if(bias != nullptr)
281*c217d954SCole Faust {
282*c217d954SCole Faust ARM_COMPUTE_RETURN_ERROR_ON(bias->num_dimensions() > 1);
283*c217d954SCole Faust ARM_COMPUTE_RETURN_ERROR_ON(bias->dimension(0) != weights->dimension(0));
284*c217d954SCole Faust
285*c217d954SCole Faust if(is_data_type_quantized(src->data_type()))
286*c217d954SCole Faust {
287*c217d954SCole Faust ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(bias, 1, DataType::S32);
288*c217d954SCole Faust }
289*c217d954SCole Faust else
290*c217d954SCole Faust {
291*c217d954SCole Faust ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(src, bias);
292*c217d954SCole Faust }
293*c217d954SCole Faust }
294*c217d954SCole Faust
295*c217d954SCole Faust if(dst->total_size() > 0)
296*c217d954SCole Faust {
297*c217d954SCole Faust const TensorShape dst_shape = misc::shape_calculator::compute_depthwise_convolution_shape(*src, *weights, info);
298*c217d954SCole Faust ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DIMENSIONS(dst->tensor_shape(), dst_shape);
299*c217d954SCole Faust ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(src, dst);
300*c217d954SCole Faust }
301*c217d954SCole Faust return Status{};
302*c217d954SCole Faust }
303*c217d954SCole Faust
run_op(ITensorPack & tensors,const Window & window,const ThreadInfo & info)304*c217d954SCole Faust void CpuDepthwiseConv2dAssemblyWrapperKernel::run_op(ITensorPack &tensors, const Window &window, const ThreadInfo &info)
305*c217d954SCole Faust {
306*c217d954SCole Faust ARM_COMPUTE_ERROR_ON_NULLPTR(_kernel_asm.get());
307*c217d954SCole Faust ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this);
308*c217d954SCole Faust ARM_COMPUTE_UNUSED(window);
309*c217d954SCole Faust ARM_COMPUTE_UNUSED(info);
310*c217d954SCole Faust
311*c217d954SCole Faust ARM_COMPUTE_ERROR_ON(tensors.empty());
312*c217d954SCole Faust
313*c217d954SCole Faust const ITensor *src = tensors.get_const_tensor(TensorType::ACL_SRC_0);
314*c217d954SCole Faust ITensor *dst = tensors.get_tensor(TensorType::ACL_DST);
315*c217d954SCole Faust ITensor *workspace = tensors.get_tensor(TensorType::ACL_INT_0);
316*c217d954SCole Faust ITensor *storage = tensors.get_tensor(TensorType::ACL_INT_1);
317*c217d954SCole Faust
318*c217d954SCole Faust const auto src_ptr = src->buffer() + src->info()->offset_first_element_in_bytes();
319*c217d954SCole Faust auto dst_ptr = dst->buffer() + dst->info()->offset_first_element_in_bytes();
320*c217d954SCole Faust auto working_space = workspace->buffer() + workspace->info()->offset_first_element_in_bytes();
321*c217d954SCole Faust auto parameters_ptr = storage->buffer() + storage->info()->offset_first_element_in_bytes();
322*c217d954SCole Faust
323*c217d954SCole Faust const auto src_shape = src->info()->tensor_shape();
324*c217d954SCole Faust const auto dst_shape = dst->info()->tensor_shape();
325*c217d954SCole Faust const auto src_padding = src->info()->padding();
326*c217d954SCole Faust const auto dst_padding = dst->info()->padding();
327*c217d954SCole Faust
328*c217d954SCole Faust const size_t ld_src_col = src_shape[0] + src_padding.left + src_padding.right;
329*c217d954SCole Faust const size_t ld_src_row = ld_src_col * (src_shape[1] + src_padding.top + src_padding.bottom);
330*c217d954SCole Faust const size_t ld_src_batch = ld_src_row * src_shape[2];
331*c217d954SCole Faust const size_t ld_dst_col = dst_shape[0] + dst_padding.left + dst_padding.right;
332*c217d954SCole Faust const size_t ld_dst_row = ld_dst_col * (dst_shape[1] + dst_padding.top + dst_padding.bottom);
333*c217d954SCole Faust const size_t ld_dst_batch = ld_dst_row * dst_shape[2];
334*c217d954SCole Faust
335*c217d954SCole Faust _kernel_asm->execute(src_ptr, ld_src_col, ld_src_row, ld_src_batch,
336*c217d954SCole Faust parameters_ptr,
337*c217d954SCole Faust dst_ptr, ld_dst_col, ld_dst_row, ld_dst_batch,
338*c217d954SCole Faust working_space, info.thread_id, info.num_threads);
339*c217d954SCole Faust }
340*c217d954SCole Faust
pack_parameters(void * parameters_ptr,void * bias_ptr,void * weights_ptr,size_t ld_weights_col,size_t ld_weight_row)341*c217d954SCole Faust void CpuDepthwiseConv2dAssemblyWrapperKernel::pack_parameters(void *parameters_ptr, void *bias_ptr, void *weights_ptr, size_t ld_weights_col, size_t ld_weight_row)
342*c217d954SCole Faust {
343*c217d954SCole Faust _kernel_asm->pack_parameters(parameters_ptr, bias_ptr, weights_ptr, ld_weights_col, ld_weight_row);
344*c217d954SCole Faust }
345*c217d954SCole Faust
get_storage_size() const346*c217d954SCole Faust size_t CpuDepthwiseConv2dAssemblyWrapperKernel::get_storage_size() const
347*c217d954SCole Faust {
348*c217d954SCole Faust return _kernel_asm->get_storage_size();
349*c217d954SCole Faust }
350*c217d954SCole Faust
get_working_size(unsigned int num_threads,unsigned int num_input_channels) const351*c217d954SCole Faust size_t CpuDepthwiseConv2dAssemblyWrapperKernel::get_working_size(unsigned int num_threads, unsigned int num_input_channels) const
352*c217d954SCole Faust {
353*c217d954SCole Faust return _kernel_asm->get_working_size(num_threads, num_input_channels);
354*c217d954SCole Faust }
355*c217d954SCole Faust
is_configured() const356*c217d954SCole Faust bool CpuDepthwiseConv2dAssemblyWrapperKernel::is_configured() const
357*c217d954SCole Faust {
358*c217d954SCole Faust return _kernel_asm != nullptr;
359*c217d954SCole Faust }
360*c217d954SCole Faust
name() const361*c217d954SCole Faust const char *CpuDepthwiseConv2dAssemblyWrapperKernel::name() const
362*c217d954SCole Faust {
363*c217d954SCole Faust return _name.c_str();
364*c217d954SCole Faust }
365*c217d954SCole Faust
get_mws(const CPUInfo & platform,size_t thread_count) const366*c217d954SCole Faust size_t CpuDepthwiseConv2dAssemblyWrapperKernel::get_mws(const CPUInfo &platform, size_t thread_count) const
367*c217d954SCole Faust {
368*c217d954SCole Faust ARM_COMPUTE_UNUSED(thread_count);
369*c217d954SCole Faust ARM_COMPUTE_UNUSED(platform);
370*c217d954SCole Faust
371*c217d954SCole Faust return ICPPKernel::default_mws;
372*c217d954SCole Faust }
373*c217d954SCole Faust } // namespace kernels
374*c217d954SCole Faust } // namespace cpu
375*c217d954SCole Faust } // namespace arm_compute
376