xref: /aosp_15_r20/external/XNNPACK/test/global-average-pooling-ncw.cc (revision 4bdc94577ba0e567308109d787f7fec7b531ce36)
1 // Copyright 2019 Google LLC
2 //
3 // This source code is licensed under the BSD-style license found in the
4 // LICENSE file in the root directory of this source tree.
5 
6 #include <gtest/gtest.h>
7 
8 #include "global-average-pooling-operator-tester.h"
9 
10 
TEST(GLOBAL_AVERAGE_POOLING_NCW_F32,single_channel)11 TEST(GLOBAL_AVERAGE_POOLING_NCW_F32, single_channel) {
12   ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
13   GlobalAveragePoolingOperatorTester()
14     .width(27)
15     .channels(1)
16     .TestNCWxF32();
17 }
18 
TEST(GLOBAL_AVERAGE_POOLING_NCW_F32,varying_channels)19 TEST(GLOBAL_AVERAGE_POOLING_NCW_F32, varying_channels) {
20   ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
21   for (size_t channels = 2; channels <= 16; channels += 3) {
22     GlobalAveragePoolingOperatorTester()
23       .width(27)
24       .channels(channels)
25       .TestNCWxF32();
26   }
27 }
28 
TEST(GLOBAL_AVERAGE_POOLING_NCW_F32,varying_width)29 TEST(GLOBAL_AVERAGE_POOLING_NCW_F32, varying_width) {
30   ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
31   for (size_t width = 25; width <= 31; width++) {
32     GlobalAveragePoolingOperatorTester()
33       .width(width)
34       .channels(19)
35       .TestNCWxF32();
36   }
37 }
38 
TEST(GLOBAL_AVERAGE_POOLING_NCW_F32,qmin)39 TEST(GLOBAL_AVERAGE_POOLING_NCW_F32, qmin) {
40   ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
41   GlobalAveragePoolingOperatorTester()
42     .width(27)
43     .channels(19)
44     .qmin(128)
45     .TestNCWxF32();
46 }
47 
TEST(GLOBAL_AVERAGE_POOLING_NCW_F32,qmax)48 TEST(GLOBAL_AVERAGE_POOLING_NCW_F32, qmax) {
49   ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
50   GlobalAveragePoolingOperatorTester()
51     .width(27)
52     .channels(19)
53     .qmax(128)
54     .TestNCWxF32();
55 }
56