arm_depthwise_conv_wrapper_s4.c 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. * Project: CMSIS NN Library
  20. * Title: arm_depthwise_conv_wrapper_s4.c
  21. * Description: Wrapper API to select appropriate depthwise conv s4 API based
  22. * on dimensions.
  23. *
  24. * $Date: 30 October 2023
  25. * $Revision: V.1.0.0
  26. *
  27. * Target : Arm(R) M-Profile Architecture
  28. *
  29. * -------------------------------------------------------------------- */
  30. #include "arm_nnfunctions.h"
  31. /**
  32. * @ingroup Public
  33. */
  34. /**
  35. * @addtogroup NNConv
  36. * @{
  37. */
  38. /*
  39. * s4 Depthwise conv wrapper function
  40. *
  41. * Refer header file for details.
  42. *
  43. */
  44. arm_cmsis_nn_status arm_depthwise_conv_wrapper_s4(const cmsis_nn_context *ctx,
  45. const cmsis_nn_dw_conv_params *dw_conv_params,
  46. const cmsis_nn_per_channel_quant_params *quant_params,
  47. const cmsis_nn_dims *input_dims,
  48. const int8_t *input,
  49. const cmsis_nn_dims *filter_dims,
  50. const int8_t *filter,
  51. const cmsis_nn_dims *bias_dims,
  52. const int32_t *bias,
  53. const cmsis_nn_dims *output_dims,
  54. int8_t *output)
  55. {
  56. arm_cmsis_nn_status status = ARM_CMSIS_NN_SUCCESS;
  57. if (1 == dw_conv_params->ch_mult && input_dims->n == 1 && dw_conv_params->dilation.w == 1 &&
  58. dw_conv_params->dilation.h == 1)
  59. {
  60. status = arm_depthwise_conv_s4_opt(ctx,
  61. dw_conv_params,
  62. quant_params,
  63. input_dims,
  64. input,
  65. filter_dims,
  66. filter,
  67. bias_dims,
  68. bias,
  69. output_dims,
  70. output);
  71. }
  72. else
  73. {
  74. status = arm_depthwise_conv_s4(ctx,
  75. dw_conv_params,
  76. quant_params,
  77. input_dims,
  78. input,
  79. filter_dims,
  80. filter,
  81. bias_dims,
  82. bias,
  83. output_dims,
  84. output);
  85. }
  86. /* Return to application */
  87. return status;
  88. }
  89. /**
  90. * @} end of NNConv group
  91. */