• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) Facebook, Inc. and its affiliates.
2 // All rights reserved.
3 //
4 // Copyright 2019 Google LLC
5 //
6 // This source code is licensed under the BSD-style license found in the
7 // LICENSE file in the root directory of this source tree.
8 
9 #include <assert.h>
10 #include <math.h>
11 #include <stddef.h>
12 #include <stdint.h>
13 #include <stdlib.h>
14 
15 #include <fp16.h>
16 
17 #include <xnnpack.h>
18 #include <xnnpack/allocator.h>
19 #include <xnnpack/log.h>
20 #include <xnnpack/operator.h>
21 #include <xnnpack/params-init.h>
22 #include <xnnpack/params.h>
23 
24 
create_global_average_pooling_nwc(size_t channels,size_t input_stride,size_t output_stride,uint32_t flags,uint32_t log2_element_size,size_t params_offset,const void * params,size_t params_size,uint32_t datatype_init_flags,enum xnn_operator_type operator_type,xnn_operator_t * global_average_pooling_op_out)25 static enum xnn_status create_global_average_pooling_nwc(
26     size_t channels,
27     size_t input_stride,
28     size_t output_stride,
29     uint32_t flags,
30     uint32_t log2_element_size,
31     size_t params_offset,
32     const void* params,
33     size_t params_size,
34     uint32_t datatype_init_flags,
35     enum xnn_operator_type operator_type,
36     xnn_operator_t* global_average_pooling_op_out)
37 {
38   xnn_operator_t global_average_pooling_op = NULL;
39   enum xnn_status status = xnn_status_uninitialized;
40 
41   if ((xnn_params.init_flags & XNN_INIT_FLAG_XNNPACK) == 0) {
42     xnn_log_error("failed to create %s operator: XNNPACK is not initialized",
43       xnn_operator_type_to_string(operator_type));
44     goto error;
45   }
46 
47   status = xnn_status_unsupported_hardware;
48 
49   if ((xnn_params.init_flags & datatype_init_flags) == 0) {
50     xnn_log_error("failed to create %s operator: operations on data type are not supported",
51       xnn_operator_type_to_string(operator_type));
52     goto error;
53   }
54 
55   status = xnn_status_invalid_parameter;
56 
57   if (channels == 0) {
58     xnn_log_error(
59       "failed to create %s operator with %zu channels: number of channels must be non-zero",
60       xnn_operator_type_to_string(operator_type), channels);
61     goto error;
62   }
63 
64   if (input_stride < channels) {
65     xnn_log_error(
66       "failed to create %s operator with input element stride of %zu: "
67       "stride must be at least as large as the number of channels (%zu)",
68       xnn_operator_type_to_string(operator_type), input_stride, channels);
69     goto error;
70   }
71 
72   if (output_stride < channels) {
73     xnn_log_error(
74       "failed to create %s operator with output element stride of %zu: "
75       "stride must be at least as large as the number of channels (%zu)",
76       xnn_operator_type_to_string(operator_type), output_stride, channels);
77     goto error;
78   }
79 
80   status = xnn_status_out_of_memory;
81 
82   global_average_pooling_op = xnn_allocate_zero_simd_memory(sizeof(struct xnn_operator));
83   if (global_average_pooling_op == NULL) {
84     xnn_log_error(
85       "failed to allocate %zu bytes for %s operator descriptor",
86       sizeof(struct xnn_operator), xnn_operator_type_to_string(operator_type));
87     goto error;
88   }
89 
90   const size_t zero_size = (channels << log2_element_size) + XNN_EXTRA_BYTES;
91   void* zero_buffer = xnn_allocate_zero_simd_memory(zero_size);
92   if (zero_buffer == NULL) {
93     xnn_log_error(
94       "failed to allocate %zu bytes for %s operator zero padding",
95       zero_size, xnn_operator_type_to_string(operator_type));
96     goto error;
97   }
98   global_average_pooling_op->zero_buffer = zero_buffer;
99 
100   global_average_pooling_op->channels = channels;
101   global_average_pooling_op->input_pixel_stride = input_stride;
102   global_average_pooling_op->output_pixel_stride = output_stride;
103   memcpy((void*) ((uintptr_t) global_average_pooling_op + params_offset), params, params_size);
104 
105   global_average_pooling_op->type = operator_type;
106 
107   global_average_pooling_op->state = xnn_run_state_invalid;
108 
109   *global_average_pooling_op_out = global_average_pooling_op;
110   return xnn_status_success;
111 
112 error:
113   xnn_delete_operator(global_average_pooling_op);
114   return status;
115 }
116 
setup_global_average_pooling_nwc(xnn_operator_t global_average_pooling_op,size_t batch_size,size_t width,const void * input,void * output,size_t log2_element_size,const struct gavgpool_parameters gavgpool[restrict XNN_MIN_ELEMENTS (1)],uint32_t datatype_init_flags,enum xnn_operator_type expected_operator_type,const void * params,size_t params_size,void (* update_params)(xnn_operator_t,size_t),pthreadpool_t threadpool)117 static enum xnn_status setup_global_average_pooling_nwc(
118     xnn_operator_t global_average_pooling_op,
119     size_t batch_size,
120     size_t width,
121     const void* input,
122     void* output,
123     size_t log2_element_size,
124     const struct gavgpool_parameters gavgpool[restrict XNN_MIN_ELEMENTS(1)],
125     uint32_t datatype_init_flags,
126     enum xnn_operator_type expected_operator_type,
127     const void* params,
128     size_t params_size,
129     void (*update_params)(xnn_operator_t, size_t),
130     pthreadpool_t threadpool)
131 {
132   if (global_average_pooling_op->type != expected_operator_type) {
133     xnn_log_error("failed to setup operator: operator type mismatch (expected %s, got %s)",
134       xnn_operator_type_to_string(expected_operator_type),
135       xnn_operator_type_to_string(global_average_pooling_op->type));
136     return xnn_status_invalid_parameter;
137   }
138   global_average_pooling_op->state = xnn_run_state_invalid;
139 
140   if ((xnn_params.init_flags & XNN_INIT_FLAG_XNNPACK) == 0) {
141     xnn_log_error("failed to setup %s operator: XNNPACK is not initialized",
142       xnn_operator_type_to_string(global_average_pooling_op->type));
143     return xnn_status_uninitialized;
144   }
145 
146   if ((xnn_params.init_flags & datatype_init_flags) == 0) {
147     xnn_log_error("failed to setup %s operator: operations on data type are not supported",
148       xnn_operator_type_to_string(global_average_pooling_op->type));
149     return xnn_status_unsupported_hardware;
150   }
151 
152   if (width == 0) {
153     xnn_log_error("failed to setup %s operator with width %zu: width must be non-zero",
154       xnn_operator_type_to_string(global_average_pooling_op->type), width);
155     return xnn_status_invalid_parameter;
156   }
157 
158   if (batch_size == 0) {
159     global_average_pooling_op->state = xnn_run_state_skip;
160     return xnn_status_success;
161   }
162 
163   global_average_pooling_op->batch_size = batch_size;
164   global_average_pooling_op->input_width = width;
165   global_average_pooling_op->input = input;
166   global_average_pooling_op->output = output;
167 
168   update_params(global_average_pooling_op, width);
169 
170   assert(gavgpool->mr != 0);
171 
172   const size_t input_stride_in_bytes = global_average_pooling_op->input_pixel_stride << log2_element_size;
173   const size_t channels = global_average_pooling_op->channels;
174   global_average_pooling_op->context.global_average_pooling_nwc = (struct global_average_pooling_nwc_context) {
175       .input = input,
176       .zero = global_average_pooling_op->zero_buffer,
177       .input_pixel_stride = input_stride_in_bytes,
178       .input_batch_stride = input_stride_in_bytes * width,
179       .input_elements = width,
180       .channels = channels,
181       .output = output,
182       .output_batch_stride = (global_average_pooling_op->output_pixel_stride << log2_element_size),
183   };
184   memcpy(&global_average_pooling_op->context.global_average_pooling_nwc.params, params, params_size);
185   global_average_pooling_op->compute.type = xnn_parallelization_type_1d;
186   global_average_pooling_op->compute.range[0] = batch_size;
187 
188   if (width <= gavgpool->mr) {
189     global_average_pooling_op->compute.task_1d = (pthreadpool_task_1d_t) xnn_compute_global_average_pooling_nwc_unipass;
190     global_average_pooling_op->context.global_average_pooling_nwc.unipass_ukernel = gavgpool->up;
191   } else {
192     global_average_pooling_op->compute.task_1d = (pthreadpool_task_1d_t) xnn_compute_global_average_pooling_nwc_multipass;
193     global_average_pooling_op->context.global_average_pooling_nwc.multipass_ukernel = gavgpool->mp;
194   }
195   global_average_pooling_op->state = xnn_run_state_ready;
196 
197   return xnn_status_success;
198 }
199 
xnn_create_global_average_pooling_nwc_qu8(size_t channels,size_t input_stride,size_t output_stride,uint8_t input_zero_point,float input_scale,uint8_t output_zero_point,float output_scale,uint8_t output_min,uint8_t output_max,uint32_t flags,xnn_operator_t * global_average_pooling_op_out)200 enum xnn_status xnn_create_global_average_pooling_nwc_qu8(
201     size_t channels,
202     size_t input_stride,
203     size_t output_stride,
204     uint8_t input_zero_point,
205     float input_scale,
206     uint8_t output_zero_point,
207     float output_scale,
208     uint8_t output_min,
209     uint8_t output_max,
210     uint32_t flags,
211     xnn_operator_t* global_average_pooling_op_out)
212 {
213   if (input_scale <= 0.0f || !isnormal(input_scale)) {
214     xnn_log_error(
215       "failed to create %s operator with %.7g input scale: scale must be finite, normalized, and positive",
216       xnn_operator_type_to_string(xnn_operator_type_global_average_pooling_nwc_qu8), input_scale);
217     return xnn_status_invalid_parameter;
218   }
219 
220   if (output_scale <= 0.0f || !isnormal(output_scale)) {
221     xnn_log_error(
222       "failed to create %s operator with %.7g output scale: scale must be finite, normalized, and positive",
223       xnn_operator_type_to_string(xnn_operator_type_global_average_pooling_nwc_qu8), output_scale);
224     return xnn_status_invalid_parameter;
225   }
226 
227   if (output_min >= output_max) {
228     xnn_log_error(
229       "failed to create %s operator with [%" PRIu8 ", %" PRIu8 "] output range: range min must be below range max",
230       xnn_operator_type_to_string(xnn_operator_type_global_average_pooling_nwc_qu8), output_min, output_max);
231     return xnn_status_invalid_parameter;
232   }
233 
234   const float input_output_scale = input_scale / output_scale;
235   if (input_output_scale < 0x1.0p-8f || input_output_scale >= 0x1.0p+8f) {
236     xnn_log_error(
237       "failed to create %s operator with %.7g input-to-output scale ratio: scale ratio must be in [2**-8, 2**8) range",
238       xnn_operator_type_to_string(xnn_operator_type_global_average_pooling_nwc_qu8), input_output_scale);
239     return xnn_status_unsupported_parameter;
240   }
241 
242   const union xnn_qu8_avgpool_params params =
243     xnn_init_qu8_avgpool_params(
244       0 /* bias */, 1.0f /* scale */,
245       output_zero_point, output_min, output_max);
246   const enum xnn_status status = create_global_average_pooling_nwc(
247     channels, input_stride, output_stride, flags,
248     0 /* log2(sizeof(uint8_t)) */,
249     offsetof(struct xnn_operator, params.qu8_gavgpool),
250     &params, sizeof(params),
251     XNN_INIT_FLAG_QU8,
252     xnn_operator_type_global_average_pooling_nwc_qu8,
253     global_average_pooling_op_out);
254   if (status == xnn_status_success) {
255     xnn_operator_t global_average_pooling_op = *global_average_pooling_op_out;
256     global_average_pooling_op->input_zero_point = (int32_t) (uint32_t) input_zero_point;
257     global_average_pooling_op->input_scale = input_scale;
258     global_average_pooling_op->output_scale = output_scale;
259   }
260   return status;
261 }
262 
xnn_create_global_average_pooling_nwc_qs8(size_t channels,size_t input_stride,size_t output_stride,int8_t input_zero_point,float input_scale,int8_t output_zero_point,float output_scale,int8_t output_min,int8_t output_max,uint32_t flags,xnn_operator_t * global_average_pooling_op_out)263 enum xnn_status xnn_create_global_average_pooling_nwc_qs8(
264     size_t channels,
265     size_t input_stride,
266     size_t output_stride,
267     int8_t input_zero_point,
268     float input_scale,
269     int8_t output_zero_point,
270     float output_scale,
271     int8_t output_min,
272     int8_t output_max,
273     uint32_t flags,
274     xnn_operator_t* global_average_pooling_op_out)
275 {
276   if (input_scale <= 0.0f || !isnormal(input_scale)) {
277     xnn_log_error(
278       "failed to create %s operator with %.7g input scale: scale must be finite, normalized, and positive",
279       xnn_operator_type_to_string(xnn_operator_type_global_average_pooling_nwc_qs8), input_scale);
280     return xnn_status_invalid_parameter;
281   }
282 
283   if (output_scale <= 0.0f || !isnormal(output_scale)) {
284     xnn_log_error(
285       "failed to create %s operator with %.7g output scale: scale must be finite, normalized, and positive",
286       xnn_operator_type_to_string(xnn_operator_type_global_average_pooling_nwc_qs8), output_scale);
287     return xnn_status_invalid_parameter;
288   }
289 
290   if (output_min >= output_max) {
291     xnn_log_error(
292       "failed to create %s operator with [%" PRId8 ", %" PRId8 "] output range: range min must be below range max",
293       xnn_operator_type_to_string(xnn_operator_type_global_average_pooling_nwc_qs8), output_min, output_max);
294     return xnn_status_invalid_parameter;
295   }
296 
297   const float input_output_scale = input_scale / output_scale;
298   if (input_output_scale < 0x1.0p-8f || input_output_scale >= 0x1.0p+8f) {
299     xnn_log_error(
300       "failed to create %s operator with %.7g input-to-output scale ratio: scale ratio must be in [2**-8, 2**8) range",
301       xnn_operator_type_to_string(xnn_operator_type_global_average_pooling_nwc_qs8), input_output_scale);
302     return xnn_status_unsupported_parameter;
303   }
304 
305   const union xnn_qs8_avgpool_params params =
306     xnn_init_qs8_avgpool_params(
307       0 /* bias */, 1.0f /* scale */,
308       output_zero_point, output_min, output_max);
309   const enum xnn_status status = create_global_average_pooling_nwc(
310     channels, input_stride, output_stride, flags,
311     0 /* log2(sizeof(int8_t)) */,
312     offsetof(struct xnn_operator, params.qs8_gavgpool),
313     &params, sizeof(params),
314     XNN_INIT_FLAG_QS8,
315     xnn_operator_type_global_average_pooling_nwc_qs8,
316     global_average_pooling_op_out);
317   if (status == xnn_status_success) {
318     xnn_operator_t global_average_pooling_op = *global_average_pooling_op_out;
319     global_average_pooling_op->input_zero_point = (int32_t) input_zero_point;
320     global_average_pooling_op->input_scale = input_scale;
321     global_average_pooling_op->output_scale = output_scale;
322   }
323   return status;
324 }
325 
xnn_create_global_average_pooling_nwc_f16(size_t channels,size_t input_stride,size_t output_stride,float output_min,float output_max,uint32_t flags,xnn_operator_t * global_average_pooling_op_out)326 enum xnn_status xnn_create_global_average_pooling_nwc_f16(
327     size_t channels,
328     size_t input_stride,
329     size_t output_stride,
330     float output_min,
331     float output_max,
332     uint32_t flags,
333     xnn_operator_t* global_average_pooling_op_out)
334 {
335   if (isnan(output_min)) {
336     xnn_log_error(
337       "failed to create %s operator with NaN output lower bound: lower bound must be non-NaN",
338       xnn_operator_type_to_string(xnn_operator_type_global_average_pooling_nwc_f16));
339     return xnn_status_invalid_parameter;
340   }
341 
342   if (isnan(output_max)) {
343     xnn_log_error(
344       "failed to create %s operator with NaN output upper bound: upper bound must be non-NaN",
345       xnn_operator_type_to_string(xnn_operator_type_global_average_pooling_nwc_f16));
346     return xnn_status_invalid_parameter;
347   }
348 
349   if (fp16_ieee_to_fp32_value(fp16_ieee_from_fp32_value(output_min)) >= fp16_ieee_to_fp32_value(fp16_ieee_from_fp32_value(output_max))) {
350     xnn_log_error(
351       "failed to create %s operator with [%.7g, %.7g] output range: lower bound must be below upper bound",
352       xnn_operator_type_to_string(xnn_operator_type_global_average_pooling_nwc_f16),
353       fp16_ieee_to_fp32_value(fp16_ieee_from_fp32_value(output_min)),
354       fp16_ieee_to_fp32_value(fp16_ieee_from_fp32_value(output_max)));
355     return xnn_status_invalid_parameter;
356   }
357 
358   const struct xnn_f16_scaleminmax_params params =
359     xnn_init_f16_scaleminmax_params(
360       UINT16_C(0x7E00) /* NaN */,
361       fp16_ieee_from_fp32_value(output_min),
362       fp16_ieee_from_fp32_value(output_max));
363   return create_global_average_pooling_nwc(
364     channels, input_stride, output_stride, flags,
365     1 /* log2(sizeof(uint16_t)) */,
366     offsetof(struct xnn_operator, params.f16_scaleminmax),
367     &params, sizeof(params),
368     XNN_INIT_FLAG_F16,
369     xnn_operator_type_global_average_pooling_nwc_f16,
370     global_average_pooling_op_out);
371 }
372 
xnn_create_global_average_pooling_nwc_f32(size_t channels,size_t input_stride,size_t output_stride,float output_min,float output_max,uint32_t flags,xnn_operator_t * global_average_pooling_op_out)373 enum xnn_status xnn_create_global_average_pooling_nwc_f32(
374     size_t channels,
375     size_t input_stride,
376     size_t output_stride,
377     float output_min,
378     float output_max,
379     uint32_t flags,
380     xnn_operator_t* global_average_pooling_op_out)
381 {
382   if (isnan(output_min)) {
383     xnn_log_error(
384       "failed to create %s operator with NaN output lower bound: lower bound must be non-NaN",
385       xnn_operator_type_to_string(xnn_operator_type_global_average_pooling_nwc_f32));
386     return xnn_status_invalid_parameter;
387   }
388 
389   if (isnan(output_max)) {
390     xnn_log_error(
391       "failed to create %s operator with NaN output upper bound: upper bound must be non-NaN",
392       xnn_operator_type_to_string(xnn_operator_type_global_average_pooling_nwc_f32));
393     return xnn_status_invalid_parameter;
394   }
395 
396   if (output_min >= output_max) {
397     xnn_log_error(
398       "failed to create %s operator with [%.7g, %.7g] output range: lower bound must be below upper bound",
399       xnn_operator_type_to_string(xnn_operator_type_global_average_pooling_nwc_f32), output_min, output_max);
400     return xnn_status_invalid_parameter;
401   }
402 
403   const union xnn_f32_scaleminmax_params params =
404     xnn_init_f32_scaleminmax_params(
405       0.0f /* scale */, output_min, output_max);
406   return create_global_average_pooling_nwc(
407     channels, input_stride, output_stride, flags,
408     2 /* log2(sizeof(float)) */,
409     offsetof(struct xnn_operator, params.f32_scaleminmax),
410     &params, sizeof(params),
411     XNN_INIT_FLAG_F32,
412     xnn_operator_type_global_average_pooling_nwc_f32,
413     global_average_pooling_op_out);
414 }
415 
update_params_qu8(xnn_operator_t global_average_pooling_op,size_t width)416 static void update_params_qu8(
417   xnn_operator_t global_average_pooling_op,
418   size_t width)
419 {
420   const int32_t bias = -((int32_t) width * global_average_pooling_op->input_zero_point);
421   const float scale = global_average_pooling_op->input_scale / (global_average_pooling_op->output_scale * (float) width);
422   xnn_update_qu8_avgpool_params(&global_average_pooling_op->params.qu8_gavgpool, bias, scale);
423 }
424 
xnn_setup_global_average_pooling_nwc_qu8(xnn_operator_t global_average_pooling_op,size_t batch_size,size_t width,const uint8_t * input,uint8_t * output,pthreadpool_t threadpool)425 enum xnn_status xnn_setup_global_average_pooling_nwc_qu8(
426     xnn_operator_t global_average_pooling_op,
427     size_t batch_size,
428     size_t width,
429     const uint8_t* input,
430     uint8_t* output,
431     pthreadpool_t threadpool)
432 {
433   return setup_global_average_pooling_nwc(
434     global_average_pooling_op,
435     batch_size, width,
436     input, output,
437     0 /* log2(sizeof(uint8_t)) */,
438     &xnn_params.qu8.gavgpool,
439     XNN_INIT_FLAG_QU8,
440     xnn_operator_type_global_average_pooling_nwc_qu8,
441     &global_average_pooling_op->params.qu8_gavgpool,
442     sizeof(global_average_pooling_op->params.qu8_gavgpool),
443     update_params_qu8,
444     threadpool);
445 }
446 
update_params_qs8(xnn_operator_t global_average_pooling_op,size_t width)447 static void update_params_qs8(
448   xnn_operator_t global_average_pooling_op,
449   size_t width)
450 {
451   const int32_t bias = -((int32_t) width * global_average_pooling_op->input_zero_point);
452   const float scale = global_average_pooling_op->input_scale / (global_average_pooling_op->output_scale * (float) width);
453   xnn_update_qs8_avgpool_params(&global_average_pooling_op->params.qs8_gavgpool, bias, scale);
454 }
455 
xnn_setup_global_average_pooling_nwc_qs8(xnn_operator_t global_average_pooling_op,size_t batch_size,size_t width,const int8_t * input,int8_t * output,pthreadpool_t threadpool)456 enum xnn_status xnn_setup_global_average_pooling_nwc_qs8(
457     xnn_operator_t global_average_pooling_op,
458     size_t batch_size,
459     size_t width,
460     const int8_t* input,
461     int8_t* output,
462     pthreadpool_t threadpool)
463 {
464   return setup_global_average_pooling_nwc(
465     global_average_pooling_op,
466     batch_size, width,
467     input, output,
468     0 /* log2(sizeof(int8_t)) */,
469     &xnn_params.qs8.gavgpool,
470     XNN_INIT_FLAG_QS8,
471     xnn_operator_type_global_average_pooling_nwc_qs8,
472     &global_average_pooling_op->params.qs8_gavgpool,
473     sizeof(global_average_pooling_op->params.qs8_gavgpool),
474     update_params_qs8,
475     threadpool);
476 }
477 
update_params_f16(xnn_operator_t global_average_pooling_op,size_t width)478 static void update_params_f16(
479   xnn_operator_t global_average_pooling_op,
480   size_t width)
481 {
482   xnn_update_f16_scaleminmax_params(
483     &global_average_pooling_op->params.f16_scaleminmax,
484     fp16_ieee_from_fp32_value(1.0f / (float) width));
485 }
486 
xnn_setup_global_average_pooling_nwc_f16(xnn_operator_t global_average_pooling_op,size_t batch_size,size_t width,const void * input,void * output,pthreadpool_t threadpool)487 enum xnn_status xnn_setup_global_average_pooling_nwc_f16(
488     xnn_operator_t global_average_pooling_op,
489     size_t batch_size,
490     size_t width,
491     const void* input,
492     void* output,
493     pthreadpool_t threadpool)
494 {
495   return setup_global_average_pooling_nwc(
496     global_average_pooling_op,
497     batch_size, width,
498     input, output,
499     1 /* log2(sizeof(uint16_t)) */,
500     &xnn_params.f16.gavgpool,
501     XNN_INIT_FLAG_F16,
502     xnn_operator_type_global_average_pooling_nwc_f16,
503     &global_average_pooling_op->params.f16_scaleminmax,
504     sizeof(global_average_pooling_op->params.f16_scaleminmax),
505     update_params_f16,
506     threadpool);
507 }
508 
update_params_f32(xnn_operator_t global_average_pooling_op,size_t width)509 static void update_params_f32(
510   xnn_operator_t global_average_pooling_op,
511   size_t width)
512 {
513   xnn_update_f32_scaleminmax_params(&global_average_pooling_op->params.f32_scaleminmax, 1.0f / (float) width);
514 }
515 
xnn_setup_global_average_pooling_nwc_f32(xnn_operator_t global_average_pooling_op,size_t batch_size,size_t width,const float * input,float * output,pthreadpool_t threadpool)516 enum xnn_status xnn_setup_global_average_pooling_nwc_f32(
517     xnn_operator_t global_average_pooling_op,
518     size_t batch_size,
519     size_t width,
520     const float* input,
521     float* output,
522     pthreadpool_t threadpool)
523 {
524   return setup_global_average_pooling_nwc(
525     global_average_pooling_op,
526     batch_size, width,
527     input, output,
528     2 /* log2(sizeof(float)) */,
529     &xnn_params.f32.gavgpool,
530     XNN_INIT_FLAG_F32,
531     xnn_operator_type_global_average_pooling_nwc_f32,
532     &global_average_pooling_op->params.f32_scaleminmax,
533     sizeof(global_average_pooling_op->params.f32_scaleminmax),
534     update_params_f32,
535     threadpool);
536 }
537