1 /*
2  * SPDX-FileCopyrightText: Copyright 2010-2019, 2022 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_relu6_s8.c
22  * Description:  Basic s8 version of ReLU6
23  *
24  * $Date:        26 October 2022
25  * $Revision:    V.1.0.2
26  *
27  * Target Processor:  Cortex-M cores
28  *
29  * -------------------------------------------------------------------- */
30 
31 #include "arm_nnfunctions.h"
32 #include "arm_nnsupportfunctions.h"
33 
34 /**
35  *  @ingroup Public
36  */
37 
38 /**
39  * @addtogroup Acti
40  * @{
41  */
42 
43 /*
44  *  Basic ReLU6 function
45  *
46  * Refer to header file for details.
47  *
48  */
49 
arm_relu6_s8(int8_t * data,uint16_t size)50 void arm_relu6_s8(int8_t *data, uint16_t size)
51 {
52     int32_t i;
53 
54     for (i = 0; i < size; i++)
55     {
56         int32_t ip = data[i];
57 
58         ip = MAX(ip, 0);
59         data[i] = MIN(ip, 6);
60     }
61 }
62 
63 /**
64  * @} end of Acti group
65  */
66