|
|
|
|
|
|
|
|
|
|
|
$assert BATCH_TILE % 4 == 0 |
|
$assert BATCH_TILE >= 4 |
|
$SIMD_TILE = BATCH_TILE |
|
#include <assert.h> |
|
#include <stddef.h> |
|
#include <stdint.h> |
|
|
|
#include <arm_neon.h> |
|
|
|
#include <xnnpack/vsquareabs.h> |
|
|
|
|
|
void xnn_cs16_vsquareabs_ukernel__neon_mlal_ld128_x${BATCH_TILE}( |
|
size_t batch, |
|
const int16_t* input, |
|
uint32_t* output) XNN_OOB_READS |
|
{ |
|
assert(batch != 0); |
|
assert(batch % (sizeof(int16_t) * 2) == 0); |
|
assert(input != NULL); |
|
assert(output != NULL); |
|
|
|
$if BATCH_TILE > 4: |
|
for (; batch >= ${BATCH_TILE * 2} * sizeof(int16_t); batch -= ${BATCH_TILE * 2} * sizeof(int16_t)) { |
|
$for N in range(SIMD_TILE): |
|
const int16x4x2_t vi${N} = vld2_s16(input); input += 8; |
|
|
|
$for N in range(SIMD_TILE): |
|
int32x4_t vacc${N} = vmull_s16(vi${N}.val[0], vi${N}.val[0]); |
|
|
|
$for N in range(SIMD_TILE): |
|
vacc${N} = vmlal_s16(vacc${N}, vi${N}.val[1], vi${N}.val[1]); |
|
|
|
$for N in range(SIMD_TILE): |
|
vst1q_u32(output, vreinterpretq_u32_s32(vacc${N})); output += 4; |
|
} |
|
for (; batch >= 8 * sizeof(int16_t); batch -= 8 * sizeof(int16_t)) { |
|
const int16x4x2_t vi = vld2_s16(input); input += 8; |
|
int32x4_t vacc = vmull_s16(vi.val[0], vi.val[0]); |
|
vacc = vmlal_s16(vacc, vi.val[1], vi.val[1]); |
|
vst1q_u32(output, vreinterpretq_u32_s32(vacc)); output += 4; |
|
} |
|
if XNN_LIKELY(batch != 0) { |
|
const int16x4x2_t vi = vld2_s16(input); |
|
int32x4_t vacc = vmull_s16(vi.val[0], vi.val[0]); |
|
vacc = vmlal_s16(vacc, vi.val[1], vi.val[1]); |
|
uint32x2_t vacc_lo = vreinterpret_u32_s32(vget_low_s32(vacc)); |
|
if (batch & (4 * sizeof(int16_t))) { |
|
vst1_u32(output, vacc_lo); output += 2; |
|
vacc_lo = vreinterpret_u32_s32(vget_high_s32(vacc)); |
|
} |
|
if (batch & (2 * sizeof(int16_t))) { |
|
vst1_lane_u32(output, vacc_lo, 0); |
|
} |
|
} |
|
} |
|
|