1 /*
2 * SPDX-FileCopyrightText: Copyright 2023 Arm Limited and/or its affiliates <open-source-office@arm.com>
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 *
6 * Licensed under the Apache License, Version 2.0 (the License); you may
7 * not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
14 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19 /* ----------------------------------------------------------------------
20 * Project: CMSIS NN Library
21 * Title: arm_depthwise_conv_wrapper_s4.c
22 * Description: Wrapper API to select appropriate depthwise conv s4 API based
23 * on dimensions.
24 *
25 * $Date: 30 October 2023
26 * $Revision: V.1.0.0
27 *
28 * Target : Arm(R) M-Profile Architecture
29 *
30 * -------------------------------------------------------------------- */
31
32 #include "arm_nnfunctions.h"
33
34 /**
35 * @ingroup Public
36 */
37
38 /**
39 * @addtogroup NNConv
40 * @{
41 */
42
43 /*
44 * s4 Depthwise conv wrapper function
45 *
46 * Refer header file for details.
47 *
48 */
arm_depthwise_conv_wrapper_s4(const cmsis_nn_context * ctx,const cmsis_nn_dw_conv_params * dw_conv_params,const cmsis_nn_per_channel_quant_params * quant_params,const cmsis_nn_dims * input_dims,const int8_t * input,const cmsis_nn_dims * filter_dims,const int8_t * filter,const cmsis_nn_dims * bias_dims,const int32_t * bias,const cmsis_nn_dims * output_dims,int8_t * output)49 arm_cmsis_nn_status arm_depthwise_conv_wrapper_s4(const cmsis_nn_context *ctx,
50 const cmsis_nn_dw_conv_params *dw_conv_params,
51 const cmsis_nn_per_channel_quant_params *quant_params,
52 const cmsis_nn_dims *input_dims,
53 const int8_t *input,
54 const cmsis_nn_dims *filter_dims,
55 const int8_t *filter,
56 const cmsis_nn_dims *bias_dims,
57 const int32_t *bias,
58 const cmsis_nn_dims *output_dims,
59 int8_t *output)
60 {
61 arm_cmsis_nn_status status = ARM_CMSIS_NN_SUCCESS;
62 if (1 == dw_conv_params->ch_mult && input_dims->n == 1 && dw_conv_params->dilation.w == 1 &&
63 dw_conv_params->dilation.h == 1)
64 {
65 status = arm_depthwise_conv_s4_opt(ctx,
66 dw_conv_params,
67 quant_params,
68 input_dims,
69 input,
70 filter_dims,
71 filter,
72 bias_dims,
73 bias,
74 output_dims,
75 output);
76 }
77 else
78 {
79 status = arm_depthwise_conv_s4(ctx,
80 dw_conv_params,
81 quant_params,
82 input_dims,
83 input,
84 filter_dims,
85 filter,
86 bias_dims,
87 bias,
88 output_dims,
89 output);
90 }
91
92 /* Return to application */
93 return status;
94 }
95
96 /**
97 * @} end of NNConv group
98 */
99