|
|
|
|
|
|
|
|
|
|
|
#include <assert.h> |
|
|
|
#include <xnnpack/argmaxpool.h> |
|
#include <xnnpack/math.h> |
|
|
|
|
|
void xnn_f32_argmaxpool_ukernel_4x__scalar_c1( |
|
size_t output_pixels, |
|
size_t pooling_elements, |
|
size_t channels, |
|
const float** input, |
|
size_t input_offset, |
|
float* output, |
|
uint32_t* index, |
|
size_t input_increment, |
|
size_t output_increment) |
|
{ |
|
assert(output_pixels != 0); |
|
assert(pooling_elements != 0); |
|
assert(pooling_elements <= 4); |
|
assert(channels != 0); |
|
|
|
do { |
|
const float* i0 = input[0]; |
|
const float* i1 = input[1]; |
|
const float* i2 = input[2]; |
|
const float* i3 = input[3]; |
|
i0 = (const float*) ((uintptr_t) i0 + input_offset); |
|
i1 = (const float*) ((uintptr_t) i1 + input_offset); |
|
i2 = (const float*) ((uintptr_t) i2 + input_offset); |
|
i3 = (const float*) ((uintptr_t) i3 + input_offset); |
|
if (pooling_elements < 2) { |
|
i1 = i0; |
|
} |
|
if (pooling_elements <= 2) { |
|
i2 = i0; |
|
} |
|
if (pooling_elements != 4) { |
|
i3 = i0; |
|
} |
|
|
|
size_t c = channels; |
|
do { |
|
const float vi0 = *i0++; |
|
const float vi1 = *i1++; |
|
const float vi2 = *i2++; |
|
const float vi3 = *i3++; |
|
|
|
float vmax = vi0; |
|
uint32_t vidx = 0; |
|
|
|
if (vi1 > vmax) { |
|
vmax = vi1; |
|
vidx = 1; |
|
} |
|
|
|
if (vi2 > vmax) { |
|
vmax = vi2; |
|
vidx = 2; |
|
} |
|
|
|
if (vi3 > vmax) { |
|
vmax = vi3; |
|
vidx = 3; |
|
} |
|
|
|
*output++ = vmax; |
|
*index++ = vidx; |
|
} while (--c != 0); |
|
input = (const float**) ((uintptr_t) input + input_increment); |
|
output = (float*) ((uintptr_t) output + output_increment); |
|
} while (--output_pixels != 0); |
|
} |
|
|