1 /*
2  * SPDX-FileCopyrightText: Copyright 2010-2024 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 "../TestData/pad_int8_1/test_data.h"
20 #include "../TestData/pad_int8_2/test_data.h"
21 #include "../Utils/validate.h"
22 #include "arm_nn_types.h"
23 #include "arm_nnfunctions.h"
24 #include "unity.h"
25 
pad_int8_1_arm_pad_s8(void)26 void pad_int8_1_arm_pad_s8(void)
27 {
28     const int8_t *input_ptr = pad_int8_1_input_tensor;
29     int8_t output_ptr[PAD_INT8_1_OUTPUT_SIZE] = {0};
30 
31     const cmsis_nn_dims input_size = {PAD_INT8_1_INPUT_N, PAD_INT8_1_INPUT_H, PAD_INT8_1_INPUT_W, PAD_INT8_1_INPUT_C};
32     const cmsis_nn_dims pre_pad = {
33         PAD_INT8_1_PRE_PAD_N, PAD_INT8_1_PRE_PAD_H, PAD_INT8_1_PRE_PAD_W, PAD_INT8_1_PRE_PAD_C};
34     const cmsis_nn_dims post_pad = {
35         PAD_INT8_1_POST_PAD_N, PAD_INT8_1_POST_PAD_H, PAD_INT8_1_POST_PAD_W, PAD_INT8_1_POST_PAD_C};
36 
37     const arm_cmsis_nn_status result =
38         arm_pad_s8(input_ptr, output_ptr, PAD_INT8_1_PAD_VALUE, &input_size, &pre_pad, &post_pad);
39     TEST_ASSERT_EQUAL(ARM_CMSIS_NN_SUCCESS, result);
40     TEST_ASSERT_TRUE(validate(output_ptr, pad_int8_1_output, PAD_INT8_1_OUTPUT_SIZE));
41 }
42 
pad_int8_2_arm_pad_s8(void)43 void pad_int8_2_arm_pad_s8(void)
44 {
45     const int8_t *input_ptr = pad_int8_2_input_tensor;
46     int8_t output_ptr[PAD_INT8_2_OUTPUT_SIZE] = {0};
47 
48     const cmsis_nn_dims input_size = {PAD_INT8_2_INPUT_N, PAD_INT8_2_INPUT_H, PAD_INT8_2_INPUT_W, PAD_INT8_2_INPUT_C};
49     const cmsis_nn_dims pre_pad = {
50         PAD_INT8_2_PRE_PAD_N, PAD_INT8_2_PRE_PAD_H, PAD_INT8_2_PRE_PAD_W, PAD_INT8_2_PRE_PAD_C};
51     const cmsis_nn_dims post_pad = {
52         PAD_INT8_2_POST_PAD_N, PAD_INT8_2_POST_PAD_H, PAD_INT8_2_POST_PAD_W, PAD_INT8_2_POST_PAD_C};
53 
54     const arm_cmsis_nn_status result =
55         arm_pad_s8(input_ptr, output_ptr, PAD_INT8_2_PAD_VALUE, &input_size, &pre_pad, &post_pad);
56     TEST_ASSERT_EQUAL(ARM_CMSIS_NN_SUCCESS, result);
57     TEST_ASSERT_TRUE(validate(output_ptr, pad_int8_2_output, PAD_INT8_2_OUTPUT_SIZE));
58 }
59