1 // Auto-generated file. Do not edit!
2 // Template: src/f32-dwconv/up-avx512.c.in
3 // Generator: tools/xngen
4 //
5 // Copyright 2019 Google LLC
6 //
7 // This source code is licensed under the BSD-style license found in the
8 // LICENSE file in the root directory of this source tree.
9
10 #include <assert.h>
11
12 #include <immintrin.h>
13
14 #include <xnnpack/dwconv.h>
15 #include <xnnpack/intrinsics-polyfill.h>
16
17
xnn_f32_dwconv_ukernel_up16x4__avx512f(size_t channels,size_t output_width,const float ** input,const float * weights,float * output,size_t input_stride,size_t output_increment,const union xnn_f32_output_params params[restrict static1])18 void xnn_f32_dwconv_ukernel_up16x4__avx512f(
19 size_t channels,
20 size_t output_width,
21 const float** input,
22 const float* weights,
23 float* output,
24 size_t input_stride,
25 size_t output_increment,
26 const union xnn_f32_output_params params[restrict static 1])
27 {
28 assert(channels != 0);
29 assert(output_width != 0);
30
31 const __m512 vmax = _mm512_broadcast_f32x4(_mm_load_ps(params->sse.max));
32 const __m512 vmin = _mm512_broadcast_f32x4(_mm_load_ps(params->sse.min));
33 do {
34 const float* i0 = input[0];
35 assert(i0 != NULL);
36 const float* i1 = input[1];
37 assert(i1 != NULL);
38 const float* i2 = input[2];
39 assert(i2 != NULL);
40 const float* i3 = input[3];
41 assert(i3 != NULL);
42 input = (const float**) ((uintptr_t) input + input_stride);
43
44 size_t c = channels;
45 const float* w = weights;
46 for (; c >= 16; c -= 16) {
47 __m512 vacc0123456789ABCDEFp0 = _mm512_load_ps(w);
48
49
50 const __m512 vi0x0123456789ABCDEF = _mm512_loadu_ps(i0);
51 i0 += 16;
52
53 const __m512 vk0x0123456789ABCDEF = _mm512_load_ps(w + 16);
54 vacc0123456789ABCDEFp0 = _mm512_fmadd_ps(vi0x0123456789ABCDEF, vk0x0123456789ABCDEF, vacc0123456789ABCDEFp0);
55
56 const __m512 vi1x0123456789ABCDEF = _mm512_loadu_ps(i1);
57 i1 += 16;
58
59 const __m512 vk1x0123456789ABCDEF = _mm512_load_ps(w + 32);
60 vacc0123456789ABCDEFp0 = _mm512_fmadd_ps(vi1x0123456789ABCDEF, vk1x0123456789ABCDEF, vacc0123456789ABCDEFp0);
61
62 const __m512 vi2x0123456789ABCDEF = _mm512_loadu_ps(i2);
63 i2 += 16;
64
65 const __m512 vk2x0123456789ABCDEF = _mm512_load_ps(w + 48);
66 vacc0123456789ABCDEFp0 = _mm512_fmadd_ps(vi2x0123456789ABCDEF, vk2x0123456789ABCDEF, vacc0123456789ABCDEFp0);
67
68 const __m512 vi3x0123456789ABCDEF = _mm512_loadu_ps(i3);
69 i3 += 16;
70
71 const __m512 vk3x0123456789ABCDEF = _mm512_load_ps(w + 64);
72 vacc0123456789ABCDEFp0 = _mm512_fmadd_ps(vi3x0123456789ABCDEF, vk3x0123456789ABCDEF, vacc0123456789ABCDEFp0);
73
74 w += 80;
75
76
77 __m512 vacc0123456789ABCDEF = _mm512_max_ps(vacc0123456789ABCDEFp0, vmin);
78 vacc0123456789ABCDEF = _mm512_min_ps(vacc0123456789ABCDEF, vmax);
79
80 _mm512_storeu_ps(output, vacc0123456789ABCDEF);
81 output += 16;
82 }
83 if XNN_UNLIKELY(c != 0) {
84 assert(c >= 1);
85 assert(c <= 16);
86 // Prepare mask for valid 32-bit elements (depends on nc).
87 const __mmask16 vmask = _cvtu32_mask16((uint16_t) ((uint32_t) (UINT32_C(1) << c) - UINT32_C(1)));
88
89 __m512 vacc0123456789ABCDEFp0 = _mm512_maskz_loadu_ps(vmask, w);
90
91 const __m512 vi0x0123456789ABCDEF = _mm512_maskz_loadu_ps(vmask, i0);
92 const __m512 vk0x0123456789ABCDEF = _mm512_maskz_loadu_ps(vmask, w + 16);
93 vacc0123456789ABCDEFp0 = _mm512_fmadd_ps(vi0x0123456789ABCDEF, vk0x0123456789ABCDEF, vacc0123456789ABCDEFp0);
94
95 const __m512 vi1x0123456789ABCDEF = _mm512_maskz_loadu_ps(vmask, i1);
96 const __m512 vk1x0123456789ABCDEF = _mm512_maskz_loadu_ps(vmask, w + 32);
97 vacc0123456789ABCDEFp0 = _mm512_fmadd_ps(vi1x0123456789ABCDEF, vk1x0123456789ABCDEF, vacc0123456789ABCDEFp0);
98
99 const __m512 vi2x0123456789ABCDEF = _mm512_maskz_loadu_ps(vmask, i2);
100 const __m512 vk2x0123456789ABCDEF = _mm512_maskz_loadu_ps(vmask, w + 48);
101 vacc0123456789ABCDEFp0 = _mm512_fmadd_ps(vi2x0123456789ABCDEF, vk2x0123456789ABCDEF, vacc0123456789ABCDEFp0);
102
103 const __m512 vi3x0123456789ABCDEF = _mm512_maskz_loadu_ps(vmask, i3);
104 const __m512 vk3x0123456789ABCDEF = _mm512_maskz_loadu_ps(vmask, w + 64);
105 vacc0123456789ABCDEFp0 = _mm512_fmadd_ps(vi3x0123456789ABCDEF, vk3x0123456789ABCDEF, vacc0123456789ABCDEFp0);
106
107
108 __m512 vacc0123456789ABCDEF = _mm512_max_ps(vacc0123456789ABCDEFp0, vmin);
109 vacc0123456789ABCDEF = _mm512_min_ps(vacc0123456789ABCDEF, vmax);
110
111 _mm512_mask_storeu_ps(output, vmask, vacc0123456789ABCDEF);
112 output += c;
113 }
114
115 output = (float*) ((uintptr_t) output + output_increment);
116 } while (--output_width != 0);
117 }
118