// Auto-generated file. Do not edit! // Template: src/f32-spmm/scalar.c.in // Generator: tools/xngen // // Copyright 2019 Google LLC // // This source code is licensed under the BSD-style license found in the // LICENSE file in the root directory of this source tree. #include #include #include void xnn_f32_spmm_minmax_ukernel_4x1__scalar( size_t mc, size_t nc, const float*restrict input, const float*restrict weights, const int32_t*restrict widx_dmap, const uint32_t*restrict nidx_nnzmap, float*restrict output, size_t output_stride, const union xnn_f32_minmax_params params[restrict XNN_MIN_ELEMENTS(1)]) { assert(mc != 0); assert(mc % sizeof(float) == 0); assert(nc != 0); const float vmin = params->scalar.min; const float vmax = params->scalar.max; size_t output_decrement = output_stride * nc - 4 * sizeof(float); while (mc >= 4 * sizeof(float)) { const float*restrict w = weights; const int32_t* dmap = widx_dmap; const uint32_t* nnzmap = nidx_nnzmap; size_t n = nc; while (n >= 1) { uint32_t nnz = *nnzmap++; float vacc0x0 = *w++; float vacc1x0 = vacc0x0; float vacc2x0 = vacc0x0; float vacc3x0 = vacc0x0; if XNN_LIKELY(nnz != 0) { do { const intptr_t diff = *dmap++; const float vi0 = input[0]; const float vi1 = input[1]; const float vi2 = input[2]; const float vi3 = input[3]; input = (const float*restrict) ((uintptr_t) input + (uintptr_t) diff); const float vw0 = *w++; vacc0x0 += vi0 * vw0; vacc1x0 += vi1 * vw0; vacc2x0 += vi2 * vw0; vacc3x0 += vi3 * vw0; } while (--nnz != 0); } float vout0x0 = math_min_f32(vacc0x0, vmax); float vout1x0 = math_min_f32(vacc1x0, vmax); float vout2x0 = math_min_f32(vacc2x0, vmax); float vout3x0 = math_min_f32(vacc3x0, vmax); vout0x0 = math_max_f32(vout0x0, vmin); vout1x0 = math_max_f32(vout1x0, vmin); vout2x0 = math_max_f32(vout2x0, vmin); vout3x0 = math_max_f32(vout3x0, vmin); output[0] = vout0x0; output[1] = vout1x0; output[2] = vout2x0; output[3] = vout3x0; output[0] = vout0x0; output[1] = vout1x0; output[2] = vout2x0; output[3] = vout3x0; output = (float*restrict) ((uintptr_t) output + output_stride); n -= 1; } if XNN_UNLIKELY(n != 0) { do { uint32_t nnz = *nnzmap++; float vacc0 = *w++; float vacc1 = vacc0; float vacc2 = vacc0; float vacc3 = vacc0; if XNN_LIKELY(nnz != 0) { do { const intptr_t diff = *dmap++; const float vi0 = input[0]; const float vi1 = input[1]; const float vi2 = input[2]; const float vi3 = input[3]; input = (const float*restrict) ((uintptr_t) input + (uintptr_t) diff); const float vw = *w++; vacc0 += vi0 * vw; vacc1 += vi1 * vw; vacc2 += vi2 * vw; vacc3 += vi3 * vw; } while (--nnz != 0); } float vout0 = math_min_f32(vacc0, vmax); float vout1 = math_min_f32(vacc1, vmax); float vout2 = math_min_f32(vacc2, vmax); float vout3 = math_min_f32(vacc3, vmax); vout0 = math_max_f32(vout0, vmin); vout1 = math_max_f32(vout1, vmin); vout2 = math_max_f32(vout2, vmin); vout3 = math_max_f32(vout3, vmin); output[0] = vout0; output[1] = vout1; output[2] = vout2; output[3] = vout3; output = (float*restrict) ((uintptr_t) output + output_stride); n -= 1; } while (n != 0); } output = (float*restrict) ((uintptr_t) output - output_decrement); input += 4; mc -= 4 * sizeof(float); } if XNN_UNLIKELY(mc != 0) { output_decrement += 2 * sizeof(float); if (mc & (2 * sizeof(float))) { const float*restrict w = weights; const int32_t* dmap = widx_dmap; const uint32_t* nnzmap = nidx_nnzmap; size_t n = nc; while (n >= 1) { uint32_t nnz = *nnzmap++; float vacc0x0 = *w++; float vacc1x0 = vacc0x0; if XNN_LIKELY(nnz != 0) { do { const intptr_t diff = *dmap++; const float vi0 = input[0]; const float vi1 = input[1]; input = (const float*restrict) ((uintptr_t) input + (uintptr_t) diff); const float vw0 = *w++; vacc0x0 += vi0 * vw0; vacc1x0 += vi1 * vw0; } while (--nnz != 0); } float vout0x0 = math_min_f32(vacc0x0, vmax); float vout1x0 = math_min_f32(vacc1x0, vmax); vout0x0 = math_max_f32(vout0x0, vmin); vout1x0 = math_max_f32(vout1x0, vmin); output[0] = vout0x0; output[1] = vout1x0; output = (float*restrict) ((uintptr_t) output + output_stride); n -= 1; } if XNN_UNLIKELY(n != 0) { do { uint32_t nnz = *nnzmap++; float vacc0 = *w++; float vacc1 = vacc0; if XNN_LIKELY(nnz != 0) { do { const intptr_t diff = *dmap++; const float vi0 = input[0]; const float vi1 = input[1]; input = (const float*restrict) ((uintptr_t) input + (uintptr_t) diff); const float vw = *w++; vacc0 += vi0 * vw; vacc1 += vi1 * vw; } while (--nnz != 0); } float vout0 = math_min_f32(vacc0, vmax); float vout1 = math_min_f32(vacc1, vmax); vout0 = math_max_f32(vout0, vmin); vout1 = math_max_f32(vout1, vmin); output[0] = vout0; output[1] = vout1; output = (float*restrict) ((uintptr_t) output + output_stride); n -= 1; } while (n != 0); } output = (float*restrict) ((uintptr_t) output - output_decrement); input += 2; } output_decrement += 1 * sizeof(float); if (mc & (1 * sizeof(float))) { const float*restrict w = weights; const int32_t* dmap = widx_dmap; const uint32_t* nnzmap = nidx_nnzmap; size_t n = nc; while (n >= 1) { uint32_t nnz = *nnzmap++; float vacc0x0 = *w++; if XNN_LIKELY(nnz != 0) { do { const intptr_t diff = *dmap++; const float vi0 = input[0]; input = (const float*restrict) ((uintptr_t) input + (uintptr_t) diff); const float vw0 = *w++; vacc0x0 += vi0 * vw0; } while (--nnz != 0); } float vout0x0 = math_min_f32(vacc0x0, vmax); vout0x0 = math_max_f32(vout0x0, vmin); output[0] = vout0x0; output = (float*restrict) ((uintptr_t) output + output_stride); n -= 1; } if XNN_UNLIKELY(n != 0) { do { uint32_t nnz = *nnzmap++; float vacc0 = *w++; if XNN_LIKELY(nnz != 0) { do { const intptr_t diff = *dmap++; const float vi0 = input[0]; input = (const float*restrict) ((uintptr_t) input + (uintptr_t) diff); const float vw = *w++; vacc0 += vi0 * vw; } while (--nnz != 0); } float vout0 = math_min_f32(vacc0, vmax); vout0 = math_max_f32(vout0, vmin); output[0] = vout0; output = (float*restrict) ((uintptr_t) output + output_stride); n -= 1; } while (n != 0); } output = (float*restrict) ((uintptr_t) output - output_decrement); input += 1; } } }