1 /*
2  * SPDX-FileCopyrightText: Copyright 2010-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 #include "unity.h"
20 #include <arm_nnfunctions.h>
21 
22 #include "../Common/Softmax/exp_lut_data.h"
23 #include "../Common/Softmax/one_by_one_lut_data.h"
24 #include "../TestData/softmax_s16/test_data.h"
25 #include "../Utils/validate.h"
26 
27 #define REPEAT_NUM (2)
28 
softmax_s16_arm_softmax_s16(void)29 void softmax_s16_arm_softmax_s16(void)
30 {
31     const int32_t num_rows = SOFTMAX_S16_NUM_ROWS;
32     const int32_t row_size = SOFTMAX_S16_ROW_SIZE;
33     const int32_t mult = SOFTMAX_S16_INPUT_MULT;
34     const int32_t shift = SOFTMAX_S16_INPUT_LEFT_SHIFT;
35     const int16_t *input_data = softmax_s16_input;
36     const cmsis_nn_softmax_lut_s16 softmax_params = {.exp_lut = softmax_s16_exp_lut,
37                                                      .one_by_one_lut = softmax_s16_one_by_one_lut};
38     int16_t output[SOFTMAX_S16_DST_SIZE];
39 
40     for (int i = 0; i < REPEAT_NUM; i++)
41     {
42         arm_softmax_s16(input_data, num_rows, row_size, mult, shift, &softmax_params, output);
43         TEST_ASSERT_TRUE(validate_s16(output, softmax_s16_output_ref, SOFTMAX_S16_DST_SIZE));
44     }
45 }
46