arm_depthwise_conv_wrapper_s16.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. * SPDX-FileCopyrightText: Copyright 2010-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_s16.c
  21. * Description: Wrapper API to select appropriate depthwise conv API based
  22. * on dimensions.
  23. *
  24. * $Date: 20 January 2023
  25. * $Revision: V.1.1.0
  26. *
  27. * Target : Arm(R) M-Profile Architecture
  28. *
  29. * -------------------------------------------------------------------- */
  30. #include "arm_nnfunctions.h"
  31. #include "arm_nnsupportfunctions.h"
  32. /**
  33. * @ingroup Public
  34. */
  35. /**
  36. * @addtogroup NNConv
  37. * @{
  38. */
  39. /*
  40. * s16 Depthwise conv wrapper function
  41. *
  42. * Refer header file for details.
  43. *
  44. */
  45. arm_cmsis_nn_status arm_depthwise_conv_wrapper_s16(const cmsis_nn_context *ctx,
  46. const cmsis_nn_dw_conv_params *dw_conv_params,
  47. const cmsis_nn_per_channel_quant_params *quant_params,
  48. const cmsis_nn_dims *input_dims,
  49. const int16_t *input,
  50. const cmsis_nn_dims *filter_dims,
  51. const int8_t *filter,
  52. const cmsis_nn_dims *bias_dims,
  53. const int64_t *bias,
  54. const cmsis_nn_dims *output_dims,
  55. int16_t *output)
  56. {
  57. arm_cmsis_nn_status status = ARM_CMSIS_NN_SUCCESS;
  58. if (USE_FAST_DW_CONV_S16_FUNCTION(dw_conv_params, filter_dims, input_dims))
  59. {
  60. status = arm_depthwise_conv_fast_s16(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_s16(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. */