arm_relu6_s8.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * Copyright (C) 2010-2019 Arm Limited or its affiliates. All rights reserved.
  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_relu6_s8.c
  21. * Description: Basic s8 version of ReLU6
  22. *
  23. * $Date: 09. October 2020
  24. * $Revision: V.1.0.1
  25. *
  26. * Target Processor: Cortex-M cores
  27. *
  28. * -------------------------------------------------------------------- */
  29. #include "arm_nnfunctions.h"
  30. #include "arm_nnsupportfunctions.h"
  31. /**
  32. * @ingroup groupNN
  33. */
  34. /**
  35. * @addtogroup Acti
  36. * @{
  37. */
  38. /*
  39. * Basic ReLU6 function
  40. *
  41. * Refer to header file for details.
  42. *
  43. */
  44. void arm_relu6_s8(q7_t *data, uint16_t size)
  45. {
  46. int32_t i;
  47. for (i = 0; i < size; i++)
  48. {
  49. int32_t ip = data[i];
  50. ip = MAX(ip, 0);
  51. data[i] = MIN(ip, 6);
  52. }
  53. }
  54. /**
  55. * @} end of Acti group
  56. */