blob: 054308525761784243c4fba59b94a5bd89e7e5e9 [file] [log] [blame]
Marat Dukhan08c4a432019-10-03 09:29:21 -07001# Copyright 2019 Google LLC
2#
3# This source code is licensed under the BSD-style license found in the
4# LICENSE file in the root directory of this source tree.
5#
6# Description:
7# XNNPACK - optimized floating-point neural network operators library
8
9licenses(["notice"])
10
11exports_files(["LICENSE"])
12
13load(":build_defs.bzl", "xnnpack_aggregate_library", "xnnpack_benchmark", "xnnpack_binary", "xnnpack_cc_library", "xnnpack_min_size_copts", "xnnpack_optional_armcl_copts", "xnnpack_optional_armcl_deps", "xnnpack_optional_gemmlowp_copts", "xnnpack_optional_gemmlowp_deps", "xnnpack_optional_ruy_copts", "xnnpack_optional_ruy_deps", "xnnpack_optional_tflite_copts", "xnnpack_optional_tflite_deps", "xnnpack_std_copts", "xnnpack_unit_test", "xnnpack_visibility")
14
15OPERATOR_BENCHMARK_DEPS = [
16 ":XNNPACK",
17 ":bench_utils",
18 "@cpuinfo",
19 "@pthreadpool",
20]
21
22MICROKERNEL_BENCHMARK_DEPS = [
23 ":ukernels",
24 ":bench_utils",
25 "@cpuinfo",
26 "@FP16",
27 "@pthreadpool",
28]
29
30MICROKERNEL_TEST_DEPS = [
31 ":ukernels",
32 "@cpuinfo",
33 "@FP16",
34 "@pthreadpool",
35]
36
37OPERATOR_TEST_DEPS = [
38 ":XNNPACK",
39 "@pthreadpool",
40 "@FP16",
41]
42
43OPERATOR_SRCS = [
44 "src/add.c",
45 "src/argmax-pooling.c",
46 "src/average-pooling.c",
47 "src/channel-pad.c",
48 "src/channel-shuffle.c",
49 "src/clamp.c",
50 "src/convolution-spnchw.c",
51 "src/convolution.c",
52 "src/deconvolution.c",
53 "src/fully-connected.c",
54 "src/global-average-pooling-spnchw.c",
55 "src/global-average-pooling.c",
56 "src/hardswish.c",
57 "src/leaky-relu.c",
58 "src/max-pooling.c",
59 "src/prelu.c",
60 "src/sigmoid.c",
61 "src/softargmax.c",
62 "src/unpooling.c",
63]
64
65SCALAR_UKERNELS = [
66 "src/f32-argmaxpool/mp9p8q-scalar.c",
67 "src/f32-argmaxpool/up4-scalar.c",
68 "src/f32-argmaxpool/up9-scalar.c",
69 "src/f32-avgpool/mp9p8q-scalar.c",
70 "src/f32-avgpool/up9-scalar.c",
71 "src/f32-clamp/scalar.c",
72 "src/f32-igemm/1x4-scalar.c",
73 "src/f32-igemm/2x4-scalar.c",
74 "src/f32-igemm/4x2-scalar.c",
75 "src/f32-igemm/4x4-scalar.c",
76 "src/f32-dwconv/up1x25-scalar.c",
77 "src/f32-dwconv/up1x4-scalar.c",
78 "src/f32-dwconv/up1x9-scalar.c",
79 "src/f32-gavgpool/mp7p7q-scalar.c",
80 "src/f32-gavgpool/up7-scalar.c",
81 "src/f32-gemm/1x4-scalar.c",
82 "src/f32-gemm/2x4-scalar.c",
83 "src/f32-gemm/4x2-scalar.c",
84 "src/f32-gemm/4x4-scalar.c",
85 "src/f32-gemminc/1x4-scalar.c",
86 "src/f32-gemminc/2x4-scalar.c",
87 "src/f32-gemminc/4x4-scalar.c",
88 "src/f32-hswish/scalar.c",
89 "src/f32-maxpool/9p8q-scalar.c",
90 "src/f32-pavgpool/mp9p8q-scalar.c",
91 "src/f32-pavgpool/up9-scalar.c",
92 "src/f32-ppmm/2x4-scalar.c",
93 "src/f32-ppmm/3x3-scalar.c",
94 "src/f32-ppmm/4x2-scalar.c",
95 "src/f32-ppmm/4x4-scalar.c",
96 "src/f32-prelu/x4-scalar.c",
97 "src/f32-rmax/scalar.c",
98 "src/f32-spmm/1x1-scalar-pipelined.c",
99 "src/f32-spmm/1x1-scalar-unroll2.c",
100 "src/f32-spmm/1x1-scalar.c",
101 "src/f32-spmm/2x1-scalar-pipelined.c",
102 "src/f32-spmm/2x1-scalar-unroll2.c",
103 "src/f32-spmm/2x1-scalar.c",
104 "src/f32-spmm/4x1-scalar-pipelined.c",
105 "src/f32-spmm/4x1-scalar-unroll2.c",
106 "src/f32-spmm/4x1-scalar.c",
107 "src/f32-spmm/8x1-scalar-pipelined.c",
108 "src/f32-spmm/8x1-scalar-unroll2.c",
109 "src/f32-spmm/8x1-scalar.c",
110 "src/f32-vadd/scalar.c",
111 "src/f32-vmul/scalar.c",
112 "src/f32-vmulcaddc/c1-scalar-x2.c",
113 "src/f32-vsub/scalar.c",
114 "src/q8-avgpool/mp9p8q-scalar.c",
115 "src/q8-avgpool/up9-scalar.c",
116 "src/q8-igemm/2x2-scalar.c",
117 "src/q8-dwconv/up1x9-scalar.c",
118 "src/q8-gavgpool/mp7p7q-scalar.c",
119 "src/q8-gavgpool/up7-scalar.c",
120 "src/q8-gemm/2x2-scalar.c",
121 "src/q8-vadd/scalar.c",
122 "src/u8-clamp/scalar.c",
123 "src/u8-lut32norm/scalar.c",
124 "src/u8-maxpool/9p8q-scalar.c",
125 "src/u8-rmax/scalar.c",
126 "src/x32-packx/x2-scalar.c",
127 "src/x32-packx/x3-scalar.c",
128 "src/x32-packx/x4-scalar.c",
129 "src/x32-pad/x2-scalar.c",
130 "src/x32-unpool/scalar.c",
131 "src/x32-zip/x2-scalar.c",
132 "src/x32-zip/x3-scalar.c",
133 "src/x32-zip/x4-scalar.c",
134 "src/x32-zip/xm-scalar.c",
135 "src/x8-lut/scalar.c",
136 "src/x8-zip/x2-scalar.c",
137 "src/x8-zip/x3-scalar.c",
138 "src/x8-zip/x4-scalar.c",
139 "src/x8-zip/xm-scalar.c",
140]
141
142PSIMD_UKERNELS = [
143 "src/f32-argmaxpool/mp9p8q-psimd.c",
144 "src/f32-argmaxpool/up4-psimd.c",
145 "src/f32-argmaxpool/up9-psimd.c",
146 "src/f32-avgpool/mp9p8q-psimd.c",
147 "src/f32-avgpool/up9-psimd.c",
148 "src/f32-clamp/psimd.c",
149 "src/f32-igemm/1x8-psimd-loadsplat.c",
150 "src/f32-igemm/1x8-psimd-splat.c",
151 "src/f32-igemm/1x8s4-psimd.c",
152 "src/f32-igemm/4x2c4-psimd.c",
153 "src/f32-igemm/4x8-psimd-loadsplat.c",
154 "src/f32-igemm/4x8-psimd-splat.c",
155 "src/f32-igemm/4x8s4-psimd.c",
156 "src/f32-igemm/6x8-psimd-loadsplat.c",
157 "src/f32-igemm/6x8-psimd-splat.c",
158 "src/f32-igemm/6x8s4-psimd.c",
159 "src/f32-dwconv/up4x25-psimd.c",
160 "src/f32-dwconv/up4x4-psimd.c",
161 "src/f32-dwconv/up4x9-psimd.c",
162 "src/f32-gavgpool/mp7p7q-psimd.c",
163 "src/f32-gavgpool/up7-psimd.c",
164 "src/f32-gemm/1x8-psimd-loadsplat.c",
165 "src/f32-gemm/1x8-psimd-splat.c",
166 "src/f32-gemm/1x8s4-psimd.c",
167 "src/f32-gemm/4x8-psimd-loadsplat.c",
168 "src/f32-gemm/4x8-psimd-splat.c",
169 "src/f32-gemm/4x8s4-psimd.c",
170 "src/f32-gemm/6x8-psimd-loadsplat.c",
171 "src/f32-gemm/6x8-psimd-splat.c",
172 "src/f32-gemm/6x8s4-psimd.c",
173 "src/f32-gemminc/1x8-psimd-loadsplat.c",
174 "src/f32-gemminc/1x8-psimd-splat.c",
175 "src/f32-gemminc/1x8s4-psimd.c",
176 "src/f32-gemminc/4x8-psimd-loadsplat.c",
177 "src/f32-gemminc/4x8-psimd-splat.c",
178 "src/f32-gemminc/4x8s4-psimd.c",
179 "src/f32-gemminc/6x8-psimd-loadsplat.c",
180 "src/f32-gemminc/6x8-psimd-splat.c",
181 "src/f32-gemminc/6x8s4-psimd.c",
182 "src/f32-hswish/psimd.c",
183 "src/f32-maxpool/9p8q-psimd.c",
184 "src/f32-pavgpool/mp9p8q-psimd.c",
185 "src/f32-pavgpool/up9-psimd.c",
186 "src/f32-ppmm/4x8-psimd.c",
187 "src/f32-prelu/x4-psimd.c",
188 "src/f32-vadd/psimd.c",
189 "src/f32-vmul/psimd.c",
190 "src/f32-vmulcaddc/c4-psimd-x2.c",
191 "src/f32-vsub/psimd.c",
192 "src/x32-packx/x4-psimd.c",
193 "src/x32-pad/x2-psimd.c",
194 "src/x32-unpool/psimd.c",
195 "src/x32-zip/x2-psimd.c",
196 "src/x32-zip/x3-psimd.c",
197 "src/x32-zip/x4-psimd.c",
198 "src/x32-zip/xm-psimd.c",
199]
200
201# ISA-specific micro-kernels
202NEON_UKERNELS = [
203 "src/f32-avgpool/mp9p8q-neon.c",
204 "src/f32-avgpool/up9-neon.c",
205 "src/f32-clamp/neon.c",
206 "src/f32-igemm/1x8-neon-ld64.c",
207 "src/f32-igemm/4x12-neon-ld64.c",
208 "src/f32-igemm/4x2-neon-ld64.c",
209 "src/f32-igemm/4x4-neon-ld64.c",
210 "src/f32-igemm/4x8-neon-ld128.c",
211 "src/f32-igemm/4x8-neon-ld64.c",
212 "src/f32-igemm/6x8-neon-ld64.c",
213 "src/f32-dwconv/up4x9-neon.c",
214 "src/f32-gavgpool-spchw/neon-x4.c",
215 "src/f32-gavgpool/mp7p7q-neon.c",
216 "src/f32-gavgpool/up7-neon.c",
217 "src/f32-gemm/1x8-neon-ld64.c",
218 "src/f32-gemm/4x12-neon-ld64.c",
219 "src/f32-gemm/4x2-neon-ld64.c",
220 "src/f32-gemm/4x8-neon-ld128.c",
221 "src/f32-gemm/4x8-neon-ld64.c",
222 "src/f32-gemm/5x8-neon-ld64.c",
223 "src/f32-gemm/6x8-neon-ld64.c",
224 "src/f32-gemminc/1x8-neon-ld64.c",
225 "src/f32-gemminc/4x12-neon-ld64.c",
226 "src/f32-gemminc/4x8-neon-ld128.c",
227 "src/f32-gemminc/4x8-neon-ld64.c",
228 "src/f32-gemminc/5x8-neon-ld64.c",
229 "src/f32-gemminc/6x8-neon-ld64.c",
230 "src/f32-hswish/neon.c",
231 "src/f32-pavgpool/mp9p8q-neon.c",
232 "src/f32-pavgpool/up9-neon.c",
233 "src/f32-ppmm/4x8-neon.c",
234 "src/f32-ppmm/8x8-neon.c",
235 "src/f32-rmax/neon.c",
236 "src/f32-vmulcaddc/c4-neon-x2.c",
237 "src/q8-avgpool/mp9p8q-neon.c",
238 "src/q8-avgpool/up9-neon.c",
239 "src/q8-igemm/4x8-neon.c",
240 "src/q8-igemm/8x8-neon.c",
241 "src/q8-dwconv/up8x9-neon.c",
242 "src/q8-gavgpool/mp7p7q-neon.c",
243 "src/q8-gavgpool/up7-neon.c",
244 "src/q8-gemm/4x8-neon.c",
245 "src/q8-gemm/8x8-neon.c",
246 "src/q8-vadd/neon.c",
247 "src/u8-clamp/neon.c",
248 "src/u8-maxpool/9p8q-neon.c",
249 "src/u8-rmax/neon.c",
250 "src/x32-packx/x4-neon-st4.c",
251 "src/x32-pad/x2-neon.c",
252 "src/x32-zip/x2-neon.c",
253 "src/x32-zip/x3-neon.c",
254 "src/x32-zip/x4-neon.c",
255 "src/x32-zip/xm-neon.c",
256 "src/x8-zip/x2-neon.c",
257 "src/x8-zip/x3-neon.c",
258 "src/x8-zip/x4-neon.c",
259 "src/x8-zip/xm-neon.c",
260]
261
262NEONFMA_UKERNELS = [
Frank Barcharddb45b6a2019-10-09 16:42:45 -0700263 "src/f32-igemm/1x8-neonfma-ld64.c",
Marat Dukhan08c4a432019-10-03 09:29:21 -0700264 "src/f32-igemm/4x12-neonfma-ld64.c",
265 "src/f32-igemm/4x2-neonfma-ld64.c",
266 "src/f32-igemm/4x4-neonfma-ld64.c",
267 "src/f32-igemm/4x8-neonfma-ld128.c",
268 "src/f32-igemm/4x8-neonfma-ld64.c",
269 "src/f32-igemm/6x8-neonfma-ld64.c",
270 "src/f32-dwconv/up4x9-neonfma.c",
271 "src/f32-dwconv/up8x9-neonfma.c",
272 "src/f32-gemm/1x8-neonfma-ld64.c",
273 "src/f32-gemm/4x12-neonfma-ld64.c",
274 "src/f32-gemm/4x2-neonfma-ld64.c",
275 "src/f32-gemm/4x8-neonfma-ld128.c",
276 "src/f32-gemm/4x8-neonfma-ld64.c",
277 "src/f32-gemm/5x8-neonfma-ld64.c",
278 "src/f32-gemm/6x8-neonfma-ld64.c",
279 "src/f32-gemminc/1x8-neonfma-ld64.c",
280 "src/f32-gemminc/4x12-neonfma-ld64.c",
281 "src/f32-gemminc/4x8-neonfma-ld128.c",
282 "src/f32-gemminc/4x8-neonfma-ld64.c",
283 "src/f32-gemminc/5x8-neonfma-ld64.c",
284 "src/f32-gemminc/6x8-neonfma-ld64.c",
285 "src/f32-hswish/neonfma.c",
286 "src/f32-ppmm/4x8-neonfma.c",
287 "src/f32-ppmm/8x8-neonfma.c",
288 "src/f32-vmulcaddc/c4-neonfma-x2.c",
289]
290
291AARCH64_NEONFMA_UKERNELS = [
292 "src/f32-conv-hwc/3x3s2p1c3x4-neonfma-2x2.c",
293 "src/f32-conv-hwc/3x3s2p1c3x8-neonfma-2x2.c",
294 "src/f32-conv-hwc2spchw/3x3s2p1c3x4-neonfma-2x2.c",
295 "src/f32-dwconv-spchw/3x3p1-neonfma.c",
296 "src/f32-dwconv-spchw/5x5p2-neonfma.c",
297 "src/f32-dwconv-spchw/3x3s2p1-neonfma.c",
298 "src/f32-dwconv-spchw/5x5s2p2-neonfma.c",
299 "src/f32-spmm/12x1-neonfma.c",
300 "src/f32-spmm/12x2-neonfma.c",
301 "src/f32-spmm/12x4-neonfma.c",
302 "src/f32-spmm/16x1-neonfma-pipelined.c",
303 "src/f32-spmm/16x1-neonfma-unroll2.c",
304 "src/f32-spmm/16x1-neonfma.c",
305 "src/f32-spmm/16x2-neonfma.c",
306 "src/f32-spmm/16x4-neonfma.c",
307 "src/f32-spmm/4x1-neonfma-pipelined.c",
308 "src/f32-spmm/4x1-neonfma-unroll2.c",
309 "src/f32-spmm/4x1-neonfma.c",
310 "src/f32-spmm/4x2-neonfma.c",
311 "src/f32-spmm/4x4-neonfma.c",
312 "src/f32-spmm/8x1-neonfma-pipelined.c",
313 "src/f32-spmm/8x1-neonfma-unroll2.c",
314 "src/f32-spmm/8x1-neonfma.c",
315 "src/f32-spmm/8x2-neonfma.c",
316 "src/f32-spmm/8x4-neonfma.c",
317]
318
319AARCH64_NEONFP16ARITH_UKERNELS = [
320 "src/f16-gemm/4x8-neonfp16arith-ld64.c",
321 "src/f16-gemm/6x8-neonfp16arith-ld64.c",
322 "src/f16-gemm/8x8-neonfp16arith-ld64.c",
323]
324
325SSE_UKERNELS = [
326 "src/f32-avgpool/mp9p8q-sse.c",
327 "src/f32-avgpool/up9-sse.c",
328 "src/f32-clamp/sse.c",
329 "src/f32-igemm/1x8-sse-dup.c",
330 "src/f32-igemm/1x8-sse-load1.c",
331 "src/f32-igemm/1x8s4-sse.c",
332 "src/f32-igemm/4x2c4-sse.c",
333 "src/f32-igemm/4x8-sse-dup.c",
334 "src/f32-igemm/4x8-sse-load1.c",
335 "src/f32-igemm/4x8s4-sse.c",
336 "src/f32-dwconv/up4x25-sse.c",
337 "src/f32-dwconv/up4x4-sse.c",
338 "src/f32-dwconv/up4x9-sse.c",
339 "src/f32-gavgpool-spchw/sse-x4.c",
340 "src/f32-gavgpool/mp7p7q-sse.c",
341 "src/f32-gavgpool/up7-sse.c",
342 "src/f32-gemm/1x8-sse-dup.c",
343 "src/f32-gemm/1x8-sse-load1.c",
344 "src/f32-gemm/1x8s4-sse.c",
345 "src/f32-gemm/4x8-sse-dup.c",
346 "src/f32-gemm/4x8-sse-load1.c",
347 "src/f32-gemm/4x8s4-sse.c",
348 "src/f32-gemminc/1x8-sse-dup.c",
349 "src/f32-gemminc/1x8-sse-load1.c",
350 "src/f32-gemminc/1x8s4-sse.c",
351 "src/f32-gemminc/4x8-sse-dup.c",
352 "src/f32-gemminc/4x8-sse-load1.c",
353 "src/f32-gemminc/4x8s4-sse.c",
354 "src/f32-hswish/sse.c",
355 "src/f32-maxpool/9p8q-sse.c",
356 "src/f32-pavgpool/mp9p8q-sse.c",
357 "src/f32-pavgpool/up9-sse.c",
358 "src/f32-dwconv-spchw/3x3p1-sse.c",
359 "src/f32-dwconv-spchw/3x3s2p1-sse.c",
360 "src/f32-ppmm/4x8-sse.c",
361 "src/f32-prelu/x4-sse.c",
362 "src/f32-rmax/sse.c",
363 "src/f32-spmm/4x1-sse.c",
364 "src/f32-spmm/8x1-sse.c",
365 "src/f32-vadd/sse.c",
366 "src/f32-vmul/sse.c",
367 "src/f32-vmulcaddc/c4-sse-x2.c",
368 "src/f32-vsub/sse.c",
369 "src/x32-packx/x4-sse.c",
370]
371
372SSE2_UKERNELS = [
373 "src/f32-argmaxpool/mp9p8q-sse2.c",
374 "src/f32-argmaxpool/up4-sse2.c",
375 "src/f32-argmaxpool/up9-sse2.c",
376 "src/q8-avgpool/mp9p8q-sse2.c",
377 "src/q8-avgpool/up9-sse2.c",
378 "src/q8-igemm/4x4c2-sse2.c",
379 "src/q8-dwconv/up8x9-sse2.c",
380 "src/q8-gavgpool/mp7p7q-sse2.c",
381 "src/q8-gavgpool/up7-sse2.c",
382 "src/q8-gemm/2x4c8-sse2.c",
383 "src/q8-gemm/4x4c2-sse2.c",
384 "src/q8-vadd/sse2.c",
385 "src/u8-clamp/sse2.c",
386 "src/u8-maxpool/9p8q-sse2.c",
387 "src/u8-rmax/sse2.c",
388 "src/x32-pad/x2-sse2.c",
389 "src/x32-zip/x2-sse2.c",
390 "src/x32-zip/x3-sse2.c",
391 "src/x32-zip/x4-sse2.c",
392 "src/x32-zip/xm-sse2.c",
393 "src/x8-zip/x2-sse2.c",
394 "src/x8-zip/x3-sse2.c",
395 "src/x8-zip/x4-sse2.c",
396 "src/x8-zip/xm-sse2.c",
397]
398
399AVX_UKERNELS = [
400 "src/f32-rmax/avx.c",
401]
402
403AVX512F_UKERNELS = [
404 "src/f32-rmax/avx512f.c",
405]
406
407AARCH32_ASM_UKERNELS = [
408 "src/q8-dwconv/up8x9-aarch32-neon.S",
409]
410
411AARCH64_ASM_UKERNELS = [
412 "src/f32-dwconv/up4x9-aarch64-neonfma-cortex-a55.S",
413 "src/f32-dwconv/up4x9-aarch64-neonfma.S",
414 "src/f32-gemm/1x12-aarch64-neonfma-cortex-a53.S",
Frank Barchard21be34f2019-10-09 19:32:19 -0700415 "src/f32-gemm/1x8-aarch64-neonfma-cortex-a53.S",
Marat Dukhan08c4a432019-10-03 09:29:21 -0700416 "src/f32-gemm/1x8-aarch64-neonfma-cortex-a57.S",
417 "src/f32-gemm/1x8-aarch64-neonfma-cortex-a75.S",
418 "src/f32-gemm/4x12-aarch64-neonfma-cortex-a53.S",
419 "src/f32-gemm/4x8-aarch64-neonfma-cortex-a57.S",
420 "src/f32-gemm/4x8-aarch64-neonfma-cortex-a75.S",
421 "src/f32-gemm/4x8-aarch64-neonfma-ld128.S",
422 "src/f32-gemm/4x8-aarch64-neonfma-ld64.S",
423 "src/f32-gemm/5x8-aarch64-neonfma-cortex-a75.S",
424 "src/f32-gemm/6x8-aarch64-neonfma-cortex-a57.S",
425 "src/f32-gemm/6x8-aarch64-neonfma-cortex-a73.S",
426 "src/f32-gemm/6x8-aarch64-neonfma-cortex-a75.S",
427 "src/f32-gemm/6x8-aarch64-neonfma-ld128.S",
428 "src/f32-gemm/6x8-aarch64-neonfma-ld64.S",
429 "src/f32-gemminc/1x12-aarch64-neonfma-cortex-a53.S",
Frank Barchard21be34f2019-10-09 19:32:19 -0700430 "src/f32-gemminc/1x8-aarch64-neonfma-cortex-a53.S",
Marat Dukhan08c4a432019-10-03 09:29:21 -0700431 "src/f32-gemminc/1x8-aarch64-neonfma-cortex-a57.S",
432 "src/f32-gemminc/1x8-aarch64-neonfma-cortex-a75.S",
433 "src/f32-gemminc/4x12-aarch64-neonfma-cortex-a53.S",
434 "src/f32-gemminc/4x8-aarch64-neonfma-cortex-a57.S",
435 "src/f32-gemminc/4x8-aarch64-neonfma-cortex-a75.S",
436 "src/f32-gemminc/4x8-aarch64-neonfma-ld128.S",
437 "src/f32-gemminc/4x8-aarch64-neonfma-ld64.S",
438 "src/f32-gemminc/5x8-aarch64-neonfma-cortex-a75.S",
439 "src/f32-gemminc/6x8-aarch64-neonfma-cortex-a57.S",
440 "src/f32-gemminc/6x8-aarch64-neonfma-cortex-a73.S",
441 "src/f32-gemminc/6x8-aarch64-neonfma-cortex-a75.S",
442 "src/f32-gemminc/6x8-aarch64-neonfma-ld128.S",
443 "src/f32-gemminc/6x8-aarch64-neonfma-ld64.S",
444 "src/f32-igemm/1x12-aarch64-neonfma-cortex-a53.S",
Frank Barchard21be34f2019-10-09 19:32:19 -0700445 "src/f32-igemm/1x8-aarch64-neonfma-cortex-a53.S",
Marat Dukhan08c4a432019-10-03 09:29:21 -0700446 "src/f32-igemm/1x8-aarch64-neonfma-cortex-a57.S",
447 "src/f32-igemm/1x8-aarch64-neonfma-cortex-a75.S",
448 "src/f32-igemm/4x12-aarch64-neonfma-cortex-a53.S",
449 "src/f32-igemm/4x8-aarch64-neonfma-cortex-a75.S",
450 "src/f32-igemm/5x8-aarch64-neonfma-cortex-a75.S",
451 "src/f32-igemm/6x8-aarch64-neonfma-cortex-a57.S",
452 "src/f32-igemm/6x8-aarch64-neonfma-cortex-a73.S",
453 "src/f32-igemm/6x8-aarch64-neonfma-cortex-a75.S",
454]
455
456INTERNAL_MICROKERNEL_HDRS = [
457 "src/xnnpack/argmaxpool.h",
458 "src/xnnpack/avgpool.h",
459 "src/xnnpack/clamp.h",
460 "src/xnnpack/common.h",
461 "src/xnnpack/conv.h",
462 "src/xnnpack/dwconv.h",
463 "src/xnnpack/gavgpool.h",
464 "src/xnnpack/gemm.h",
465 "src/xnnpack/hswish.h",
466 "src/xnnpack/igemm.h",
467 "src/xnnpack/lut.h",
468 "src/xnnpack/math.h",
469 "src/xnnpack/maxpool.h",
470 "src/xnnpack/packx.h",
471 "src/xnnpack/pad.h",
472 "src/xnnpack/params.h",
473 "src/xnnpack/pavgpool.h",
474 "src/xnnpack/ppmm.h",
475 "src/xnnpack/prelu.h",
476 "src/xnnpack/rmax.h",
477 "src/xnnpack/scalar-utils.h",
478 "src/xnnpack/spmm.h",
479 "src/xnnpack/unpool.h",
480 "src/xnnpack/vadd.h",
481 "src/xnnpack/vmul.h",
482 "src/xnnpack/vmulcaddc.h",
483 "src/xnnpack/vsub.h",
484 "src/xnnpack/zip.h",
485]
486
487INTERNAL_HDRS = INTERNAL_MICROKERNEL_HDRS + [
488 "include/xnnpack.h",
489 "src/xnnpack/allocator.h",
490 "src/xnnpack/compute.h",
491 "src/xnnpack/im2col.h",
492 "src/xnnpack/indirection.h",
Marat Dukhan08c4a432019-10-03 09:29:21 -0700493 "src/xnnpack/operator.h",
494 "src/xnnpack/pack.h",
495 "src/xnnpack/requantization.h",
496 "src/xnnpack/requantization-stubs.h",
497]
498
499MICROKERNEL_BENCHMARK_HDRS = INTERNAL_MICROKERNEL_HDRS + [
500 "src/xnnpack/requantization.h",
501 "include/xnnpack.h",
502]
503
504MICROKERNEL_TEST_HDRS = INTERNAL_MICROKERNEL_HDRS + [
505 "src/xnnpack/isa-checks.h",
506 "src/xnnpack/requantization.h",
507 "include/xnnpack.h",
508]
509
510OPERATOR_TEST_PARAMS_HDRS = [
511 "src/xnnpack/params.h",
512 "src/xnnpack/common.h",
513]
514
515WEIGHTS_PACK_HDRS = [
516 "src/xnnpack/pack.h",
517 "src/xnnpack/operator.h",
518 "src/xnnpack/compute.h",
519]
520
Marat Dukhanc8e00eb2019-10-04 14:55:26 -0700521LOGGING_COPTS = select({
522 # No logging in optimized mode
523 ":optimized_build": ["-DXNN_LOG_LEVEL=0"],
524 # Full logging in debug mode
525 ":debug_build": ["-DXNN_LOG_LEVEL=5"],
526 # Error-only logging in default (fastbuild) mode
527 "//conditions:default": ["-DXNN_LOG_LEVEL=2"],
528})
529
530LOGGING_HDRS = [
531 "src/xnnpack/log.h",
532]
533
Marat Dukhan08c4a432019-10-03 09:29:21 -0700534xnnpack_cc_library(
535 name = "scalar_ukernels",
536 srcs = SCALAR_UKERNELS,
537 hdrs = INTERNAL_HDRS,
538 aarch32_copts = ["-marm"],
539 copts = xnnpack_std_copts(),
540 deps = [
541 "@FP16",
542 "@FXdiv",
543 ],
544)
545
546xnnpack_cc_library(
547 name = "psimd_ukernels",
548 srcs = PSIMD_UKERNELS,
549 hdrs = INTERNAL_HDRS,
550 aarch32_copts = [
551 "-marm",
552 "-mfpu=neon",
553 ],
554 copts = xnnpack_std_copts(),
555 optimized_copts = [
556 "-O3",
557 "-ffast-math",
558 ],
559 deps = [
560 "@FP16",
561 "@psimd",
562 ],
563)
564
565xnnpack_cc_library(
566 name = "neon_ukernels",
567 hdrs = INTERNAL_HDRS,
568 aarch32_copts = [
569 "-marm",
570 "-mfpu=neon",
571 ],
572 aarch32_srcs = NEON_UKERNELS,
573 aarch64_srcs = NEON_UKERNELS,
574 copts = xnnpack_std_copts(),
575 deps = ["@FP16"],
576)
577
578xnnpack_cc_library(
579 name = "neonfma_ukernels",
580 hdrs = INTERNAL_HDRS,
581 aarch32_copts = [
582 "-marm",
583 "-mfpu=neon-vfpv4",
584 ],
585 aarch32_srcs = NEONFMA_UKERNELS,
586 aarch64_srcs = NEONFMA_UKERNELS + AARCH64_NEONFMA_UKERNELS,
587 copts = xnnpack_std_copts(),
588 deps = ["@FP16"],
589)
590
591xnnpack_cc_library(
592 name = "neonfp16arith_ukernels",
593 hdrs = INTERNAL_HDRS,
594 aarch64_copts = ["-march=armv8.2-a+fp16"],
595 aarch64_srcs = AARCH64_NEONFP16ARITH_UKERNELS,
596 copts = xnnpack_std_copts(),
597 deps = ["@FP16"],
598)
599
600xnnpack_cc_library(
601 name = "sse2_ukernels",
602 hdrs = INTERNAL_HDRS,
603 copts = xnnpack_std_copts(),
604 x86_copts = ["-msse2"],
605 x86_srcs = SSE_UKERNELS + SSE2_UKERNELS,
606 deps = ["@FP16"],
607)
608
609xnnpack_cc_library(
610 name = "avx_ukernels",
611 hdrs = INTERNAL_HDRS,
612 copts = xnnpack_std_copts(),
613 x86_copts = ["-mavx"],
614 x86_srcs = AVX_UKERNELS,
615 deps = ["@FP16"],
616)
617
618xnnpack_cc_library(
619 name = "avx512f_ukernels",
620 hdrs = INTERNAL_HDRS,
621 copts = xnnpack_std_copts(),
622 x86_copts = ["-mavx512f"],
623 x86_srcs = AVX512F_UKERNELS,
624 deps = ["@FP16"],
625)
626
627xnnpack_cc_library(
628 name = "asm_ukernels",
629 hdrs = ["src/xnnpack/assembly.h"],
630 aarch32_srcs = AARCH32_ASM_UKERNELS,
631 aarch64_srcs = AARCH64_ASM_UKERNELS,
632)
633
634xnnpack_aggregate_library(
635 name = "ukernels",
636 aarch32_deps = [
637 ":psimd_ukernels",
638 ":neon_ukernels",
639 ":neonfma_ukernels",
640 ":asm_ukernels",
641 ],
642 aarch64_deps = [
643 ":psimd_ukernels",
644 ":neon_ukernels",
645 ":neonfma_ukernels",
646 ":neonfp16arith_ukernels",
647 ":asm_ukernels",
648 ],
649 generic_deps = [":scalar_ukernels"],
650 wasmsimd_deps = [
651 ":psimd_ukernels",
652 ],
653 x86_deps = [
654 ":psimd_ukernels",
655 ":sse2_ukernels",
656 ":avx_ukernels",
657 ":avx512f_ukernels",
658 ],
659)
660
661xnnpack_cc_library(
662 name = "im2col",
663 srcs = ["src/im2col.c"],
664 hdrs = [
665 "src/xnnpack/common.h",
666 "src/xnnpack/im2col.h",
667 ],
668 copts = xnnpack_std_copts(),
669)
670
671xnnpack_cc_library(
672 name = "indirection",
673 srcs = ["src/indirection.c"],
674 hdrs = INTERNAL_HDRS,
675 copts = xnnpack_std_copts(),
676 deps = [
677 "@FP16",
678 "@FXdiv",
679 "@pthreadpool",
680 ],
681)
682
683xnnpack_cc_library(
684 name = "operator_run",
685 srcs = ["src/operator-run.c"],
Marat Dukhanc8e00eb2019-10-04 14:55:26 -0700686 hdrs = INTERNAL_HDRS + LOGGING_HDRS,
687 copts = xnnpack_std_copts() + LOGGING_COPTS + [
Marat Dukhan08c4a432019-10-03 09:29:21 -0700688 # Wrappers for multi-pass microkernels use VLAs for temporary buffers.
689 "-Wno-vla",
690 ],
691 deps = [
692 "@FP16",
693 "@FXdiv",
694 "@clog",
695 "@pthreadpool",
696 ],
697)
698
699cc_library(
700 name = "enable_assembly",
701 defines = select({
702 ":xnn_enable_assembly_explicit_true": ["XNN_ENABLE_ASSEMBLY=1"],
703 ":xnn_enable_assembly_explicit_false": ["XNN_ENABLE_ASSEMBLY=0"],
Frank Barchard810171d2019-10-10 10:34:51 -0700704 "//conditions:default": ["XNN_ENABLE_ASSEMBLY=1"],
Marat Dukhan08c4a432019-10-03 09:29:21 -0700705 }),
706)
707
Marat Dukhancf056b22019-10-07 10:26:29 -0700708xnnpack_cc_library(
Marat Dukhan08c4a432019-10-03 09:29:21 -0700709 name = "operators",
710 srcs = OPERATOR_SRCS + [
711 "src/init.c",
712 "src/operator-delete.c",
Marat Dukhancf056b22019-10-07 10:26:29 -0700713 ],
714 hdrs = INTERNAL_HDRS + LOGGING_HDRS,
Marat Dukhanc8e00eb2019-10-04 14:55:26 -0700715 copts = xnnpack_std_copts() + LOGGING_COPTS + [
Marat Dukhan08c4a432019-10-03 09:29:21 -0700716 "-Isrc",
717 "-Iinclude",
718 ] + select({
719 ":debug_build": [],
720 "//conditions:default": xnnpack_min_size_copts(),
721 }),
Marat Dukhancf056b22019-10-07 10:26:29 -0700722 wasm_srcs = ["src/wasm-stubs.c"],
723 wasmsimd_srcs = ["src/wasm-stubs.c"],
Marat Dukhan08c4a432019-10-03 09:29:21 -0700724 deps = [
725 ":enable_assembly",
726 ":indirection",
727 ":ukernels",
728 "@FP16",
729 "@FXdiv",
730 "@clog",
Marat Dukhan08c4a432019-10-03 09:29:21 -0700731 "@pthreadpool",
Marat Dukhand343c222019-10-07 09:22:14 -0700732 ] + select({
733 ":emscripten": [],
734 "//conditions:default": ["@cpuinfo"],
735 }),
Marat Dukhan08c4a432019-10-03 09:29:21 -0700736)
737
738cc_library(
739 name = "XNNPACK",
740 hdrs = ["include/xnnpack.h"],
741 includes = ["include"],
742 linkstatic = True,
Marat Dukhan08c4a432019-10-03 09:29:21 -0700743 visibility = xnnpack_visibility(),
744 deps = [
745 ":operator_run",
746 ":operators",
747 "@pthreadpool",
748 ],
749)
750
Marat Dukhancf056b22019-10-07 10:26:29 -0700751xnnpack_cc_library(
Marat Dukhan08c4a432019-10-03 09:29:21 -0700752 name = "bench_utils",
753 srcs = ["bench/utils.cc"],
754 hdrs = ["bench/utils.h"],
755 copts = ["-Wno-unused-result"],
Marat Dukhan08c4a432019-10-03 09:29:21 -0700756 deps = ["@cpuinfo"],
757)
758
759######################### Unit tests for micro-kernels #########################
760
761xnnpack_benchmark(
762 name = "q8_gemm_bench",
763 srcs = [
764 "bench/gemm.h",
765 "bench/q8-gemm.cc",
766 "src/xnnpack/AlignedAllocator.h",
767 ] + WEIGHTS_PACK_HDRS + MICROKERNEL_BENCHMARK_HDRS,
768 copts = ["-Wno-unused-function"] + xnnpack_optional_ruy_copts() + xnnpack_optional_gemmlowp_copts(),
769 deps = MICROKERNEL_BENCHMARK_DEPS + xnnpack_optional_ruy_deps() + xnnpack_optional_gemmlowp_deps(),
770)
771
772xnnpack_benchmark(
773 name = "f16_gemm_bench",
774 srcs = [
775 "bench/f16-gemm.cc",
776 "bench/gemm.h",
777 "src/xnnpack/AlignedAllocator.h",
778 ] + WEIGHTS_PACK_HDRS + MICROKERNEL_BENCHMARK_HDRS,
779 copts = ["-Wno-unused-function"],
780 deps = MICROKERNEL_BENCHMARK_DEPS,
781)
782
783xnnpack_benchmark(
784 name = "f32_igemm_bench",
785 srcs = [
786 "bench/f32-igemm.cc",
787 "bench/conv.h",
788 "src/xnnpack/AlignedAllocator.h",
789 ] + MICROKERNEL_BENCHMARK_HDRS,
Frank Barcharddbafc582019-10-09 16:30:48 -0700790 deps = MICROKERNEL_BENCHMARK_DEPS + [
791 ":enable_assembly",
792 ":indirection",
793 ],
Marat Dukhan08c4a432019-10-03 09:29:21 -0700794)
795
796xnnpack_benchmark(
797 name = "f32_conv_hwc_bench",
798 srcs = [
799 "bench/f32-conv-hwc.cc",
800 "bench/dconv.h",
801 "src/xnnpack/AlignedAllocator.h",
802 ] + WEIGHTS_PACK_HDRS + MICROKERNEL_BENCHMARK_HDRS,
803 copts = ["-Wno-unused-function"],
804 deps = MICROKERNEL_BENCHMARK_DEPS,
805)
806
807xnnpack_benchmark(
808 name = "f32_dwconv_bench",
809 srcs = [
810 "bench/f32-dwconv.cc",
811 "bench/dwconv.h",
812 "src/xnnpack/AlignedAllocator.h",
813 ] + MICROKERNEL_BENCHMARK_HDRS,
814 deps = MICROKERNEL_BENCHMARK_DEPS + [":indirection"],
815)
816
817xnnpack_benchmark(
818 name = "f32_dwconv_spchw_bench",
819 srcs = [
820 "bench/f32-dwconv-spchw.cc",
821 "bench/dwconv.h",
822 "src/xnnpack/AlignedAllocator.h",
823 ] + WEIGHTS_PACK_HDRS + MICROKERNEL_BENCHMARK_HDRS,
824 deps = MICROKERNEL_BENCHMARK_DEPS + [":indirection"],
825)
826
827xnnpack_benchmark(
828 name = "f32_gemm_bench",
829 srcs = [
830 "bench/f32-gemm.cc",
831 "bench/gemm.h",
832 "src/xnnpack/AlignedAllocator.h",
833 ] + WEIGHTS_PACK_HDRS + MICROKERNEL_BENCHMARK_HDRS,
834 copts = ["-Wno-unused-function"] + xnnpack_optional_ruy_copts(),
Frank Barcharddbafc582019-10-09 16:30:48 -0700835 deps = MICROKERNEL_BENCHMARK_DEPS + xnnpack_optional_ruy_deps() + [
836 ":enable_assembly",
837 ],
Marat Dukhan08c4a432019-10-03 09:29:21 -0700838)
839
840xnnpack_benchmark(
841 name = "f32_rmax_bench",
842 srcs = [
843 "bench/f32-rmax.cc",
844 "src/xnnpack/AlignedAllocator.h",
845 ] + MICROKERNEL_BENCHMARK_HDRS,
846 deps = MICROKERNEL_BENCHMARK_DEPS,
847)
848
849xnnpack_benchmark(
850 name = "f32_spmm_bench",
851 srcs = [
852 "bench/f32-spmm.cc",
853 "bench/gemm.h",
854 "src/xnnpack/AlignedAllocator.h",
855 ] + MICROKERNEL_BENCHMARK_HDRS,
856 copts = ["-Wno-unused-function"],
857 deps = MICROKERNEL_BENCHMARK_DEPS,
858)
859
860xnnpack_benchmark(
861 name = "f32_im2col_gemm_bench",
862 srcs = [
863 "bench/f32-im2col-gemm.cc",
864 "bench/conv.h",
865 "src/xnnpack/AlignedAllocator.h",
866 ] + WEIGHTS_PACK_HDRS + MICROKERNEL_BENCHMARK_HDRS,
867 deps = MICROKERNEL_BENCHMARK_DEPS + [":im2col"],
868)
869
870########################### Benchmarks for operators ###########################
871
872xnnpack_benchmark(
873 name = "add_bench",
874 srcs = ["bench/add.cc"],
875 deps = OPERATOR_BENCHMARK_DEPS,
876)
877
878xnnpack_benchmark(
879 name = "average_pooling_bench",
880 srcs = ["bench/average-pooling.cc"],
881 deps = OPERATOR_BENCHMARK_DEPS,
882)
883
884xnnpack_benchmark(
885 name = "channel_shuffle_bench",
886 srcs = ["bench/channel-shuffle.cc"],
887 deps = OPERATOR_BENCHMARK_DEPS,
888)
889
890xnnpack_benchmark(
891 name = "convolution_bench",
892 srcs = ["bench/convolution.cc"],
893 copts = xnnpack_optional_tflite_copts() + xnnpack_optional_armcl_copts(),
894 deps = OPERATOR_BENCHMARK_DEPS + xnnpack_optional_tflite_deps() + xnnpack_optional_armcl_deps(),
895)
896
897xnnpack_benchmark(
898 name = "deconvolution_bench",
899 srcs = ["bench/deconvolution.cc"],
900 copts = xnnpack_optional_tflite_copts(),
901 deps = OPERATOR_BENCHMARK_DEPS + xnnpack_optional_tflite_deps(),
902)
903
904xnnpack_benchmark(
905 name = "global_average_pooling_bench",
906 srcs = ["bench/global-average-pooling.cc"],
907 deps = OPERATOR_BENCHMARK_DEPS,
908)
909
910xnnpack_benchmark(
911 name = "max_pooling_bench",
912 srcs = ["bench/max-pooling.cc"],
913 deps = OPERATOR_BENCHMARK_DEPS,
914)
915
916xnnpack_benchmark(
917 name = "sigmoid_bench",
918 srcs = ["bench/sigmoid.cc"],
919 deps = OPERATOR_BENCHMARK_DEPS,
920)
921
922xnnpack_benchmark(
923 name = "softargmax_bench",
924 srcs = ["bench/softargmax.cc"],
925 deps = OPERATOR_BENCHMARK_DEPS,
926)
927
Marat Dukhanc068bb62019-10-04 13:24:39 -0700928############################# End-to-end benchmarks ############################
929
930cc_library(
931 name = "mobilenet_v1",
932 srcs = ["models/mobilenet-v1.cc"],
933 hdrs = ["models/models.h"],
934 linkstatic = True,
935 deps = [
936 ":XNNPACK",
937 "@pthreadpool",
938 ],
939)
940
941cc_library(
942 name = "mobilenet_v2",
943 srcs = ["models/mobilenet-v2.cc"],
944 hdrs = ["models/models.h"],
945 linkstatic = True,
946 deps = [
947 ":XNNPACK",
948 "@pthreadpool",
949 ],
950)
951
952xnnpack_benchmark(
953 name = "end2end_bench",
954 srcs = ["bench/end2end.cc"],
955 deps = [
956 ":XNNPACK",
957 ":mobilenet_v1",
958 ":mobilenet_v2",
959 "@pthreadpool",
960 ],
961)
962
Marat Dukhan08c4a432019-10-03 09:29:21 -0700963######################### Unit tests for micro-kernels #########################
964
965xnnpack_unit_test(
966 name = "f16_gemm_test",
967 srcs = [
968 "test/f16-gemm.cc",
969 "test/gemm-microkernel-tester.h",
970 "src/xnnpack/AlignedAllocator.h",
971 ] + WEIGHTS_PACK_HDRS + MICROKERNEL_TEST_HDRS,
972 deps = MICROKERNEL_TEST_DEPS,
973)
974
975xnnpack_unit_test(
976 name = "f32_argmaxpool_test",
977 srcs = [
978 "test/f32-argmaxpool.cc",
979 "test/argmaxpool-microkernel-tester.h",
980 "src/xnnpack/AlignedAllocator.h",
981 ] + MICROKERNEL_TEST_HDRS,
982 deps = MICROKERNEL_TEST_DEPS,
983)
984
985xnnpack_unit_test(
986 name = "f32_avgpool_test",
987 srcs = [
988 "test/f32-avgpool.cc",
989 "test/avgpool-microkernel-tester.h",
990 "src/xnnpack/AlignedAllocator.h",
991 ] + MICROKERNEL_TEST_HDRS,
992 deps = MICROKERNEL_TEST_DEPS,
993)
994
995xnnpack_unit_test(
996 name = "f32_clamp_test",
997 srcs = [
998 "test/f32-clamp.cc",
999 "test/clamp-microkernel-tester.h",
1000 ] + MICROKERNEL_TEST_HDRS,
1001 deps = MICROKERNEL_TEST_DEPS,
1002)
1003
1004xnnpack_unit_test(
1005 name = "f32_igemm_test",
1006 srcs = [
1007 "test/f32-igemm.cc",
1008 "test/gemm-microkernel-tester.h",
1009 "src/xnnpack/AlignedAllocator.h",
1010 ] + WEIGHTS_PACK_HDRS + MICROKERNEL_TEST_HDRS,
1011 deps = MICROKERNEL_TEST_DEPS,
1012)
1013
1014xnnpack_unit_test(
1015 name = "f32_conv_hwc_test",
1016 srcs = [
1017 "test/f32-conv-hwc.cc",
1018 "test/conv-hwc-microkernel-tester.h",
1019 "src/xnnpack/AlignedAllocator.h",
1020 ] + WEIGHTS_PACK_HDRS + MICROKERNEL_TEST_HDRS,
1021 deps = MICROKERNEL_TEST_DEPS,
1022)
1023
1024xnnpack_unit_test(
1025 name = "f32_conv_hwc2spchw_test",
1026 srcs = [
1027 "test/f32-conv-hwc2spchw.cc",
1028 "test/conv-hwc2spchw-microkernel-tester.h",
1029 "src/xnnpack/AlignedAllocator.h",
1030 ] + WEIGHTS_PACK_HDRS + MICROKERNEL_TEST_HDRS,
1031 deps = MICROKERNEL_TEST_DEPS,
1032)
1033
1034xnnpack_unit_test(
1035 name = "f32_dwconv_test",
1036 srcs = [
1037 "test/f32-dwconv.cc",
1038 "test/dwconv-microkernel-tester.h",
1039 "src/xnnpack/AlignedAllocator.h",
1040 ] + WEIGHTS_PACK_HDRS + MICROKERNEL_TEST_HDRS,
1041 deps = MICROKERNEL_TEST_DEPS,
1042)
1043
1044xnnpack_unit_test(
1045 name = "f32_dwconv_spchw_test",
1046 srcs = [
1047 "test/f32-dwconv-spchw.cc",
1048 "test/dwconv-spchw-microkernel-tester.h",
1049 "src/xnnpack/AlignedAllocator.h",
1050 ] + WEIGHTS_PACK_HDRS + MICROKERNEL_TEST_HDRS,
1051 deps = MICROKERNEL_TEST_DEPS,
1052)
1053
1054xnnpack_unit_test(
1055 name = "f32_gavgpool_test",
1056 srcs = [
1057 "test/f32-gavgpool.cc",
1058 "test/gavgpool-microkernel-tester.h",
1059 "src/xnnpack/AlignedAllocator.h",
1060 ] + MICROKERNEL_TEST_HDRS,
1061 deps = MICROKERNEL_TEST_DEPS,
1062)
1063
1064xnnpack_unit_test(
1065 name = "f32_gavgpool_spchw_test",
1066 srcs = [
1067 "test/f32-gavgpool-spchw.cc",
1068 "test/gavgpool-spchw-microkernel-tester.h",
1069 "src/xnnpack/AlignedAllocator.h",
1070 ] + MICROKERNEL_TEST_HDRS,
1071 deps = MICROKERNEL_TEST_DEPS,
1072)
1073
1074xnnpack_unit_test(
1075 name = "f32_gemm_test",
1076 srcs = [
1077 "test/f32-gemm.cc",
1078 "test/gemm-microkernel-tester.h",
1079 "src/xnnpack/AlignedAllocator.h",
1080 ] + WEIGHTS_PACK_HDRS + MICROKERNEL_TEST_HDRS,
1081 deps = MICROKERNEL_TEST_DEPS,
1082)
1083
1084xnnpack_unit_test(
1085 name = "f32_gemminc_test",
1086 srcs = [
1087 "test/f32-gemminc.cc",
1088 "test/gemm-microkernel-tester.h",
1089 "src/xnnpack/AlignedAllocator.h",
1090 ] + WEIGHTS_PACK_HDRS + MICROKERNEL_TEST_HDRS,
1091 deps = MICROKERNEL_TEST_DEPS,
1092)
1093
1094xnnpack_unit_test(
1095 name = "f32_hswish_test",
1096 srcs = [
1097 "test/f32-hswish.cc",
1098 "test/hswish-microkernel-tester.h",
1099 ] + MICROKERNEL_TEST_HDRS,
1100 deps = MICROKERNEL_TEST_DEPS,
1101)
1102
1103xnnpack_unit_test(
1104 name = "f32_maxpool_test",
1105 srcs = [
1106 "test/f32-maxpool.cc",
1107 "test/maxpool-microkernel-tester.h",
1108 ] + MICROKERNEL_TEST_HDRS,
1109 deps = MICROKERNEL_TEST_DEPS,
1110)
1111
1112xnnpack_unit_test(
1113 name = "f32_pavgpool_test",
1114 srcs = [
1115 "test/f32-pavgpool.cc",
1116 "test/avgpool-microkernel-tester.h",
1117 "src/xnnpack/AlignedAllocator.h",
1118 ] + MICROKERNEL_TEST_HDRS,
1119 deps = MICROKERNEL_TEST_DEPS,
1120)
1121
1122xnnpack_unit_test(
1123 name = "f32_ppmm_test",
1124 srcs = [
1125 "test/f32-ppmm.cc",
1126 "test/gemm-microkernel-tester.h",
1127 "src/xnnpack/AlignedAllocator.h",
1128 ] + WEIGHTS_PACK_HDRS + MICROKERNEL_TEST_HDRS,
1129 deps = MICROKERNEL_TEST_DEPS,
1130)
1131
1132xnnpack_unit_test(
1133 name = "f32_prelu_test",
1134 srcs = [
1135 "test/f32-prelu.cc",
1136 "test/prelu-microkernel-tester.h",
1137 "src/xnnpack/AlignedAllocator.h",
1138 ] + MICROKERNEL_TEST_HDRS,
1139 deps = MICROKERNEL_TEST_DEPS,
1140)
1141
1142xnnpack_unit_test(
1143 name = "f32_rmax_test",
1144 srcs = [
1145 "test/f32-rmax.cc",
1146 "test/rmax-microkernel-tester.h",
1147 ] + MICROKERNEL_TEST_HDRS,
1148 deps = MICROKERNEL_TEST_DEPS,
1149)
1150
1151xnnpack_unit_test(
1152 name = "f32_spmm_test",
1153 srcs = [
1154 "test/f32-spmm.cc",
1155 "test/spmm-microkernel-tester.h",
1156 "src/xnnpack/AlignedAllocator.h",
1157 ] + MICROKERNEL_TEST_HDRS,
1158 deps = MICROKERNEL_TEST_DEPS,
1159)
1160
1161xnnpack_unit_test(
1162 name = "f32_vadd_test",
1163 srcs = [
1164 "test/f32-vadd.cc",
1165 "test/vadd-microkernel-tester.h",
1166 ] + MICROKERNEL_TEST_HDRS,
1167 deps = MICROKERNEL_TEST_DEPS,
1168)
1169
1170xnnpack_unit_test(
1171 name = "f32_vsub_test",
1172 srcs = [
1173 "test/f32-vsub.cc",
1174 "test/vsub-microkernel-tester.h",
1175 ] + MICROKERNEL_TEST_HDRS,
1176 deps = MICROKERNEL_TEST_DEPS,
1177)
1178
1179xnnpack_unit_test(
1180 name = "f32_vmul_test",
1181 srcs = [
1182 "test/f32-vmul.cc",
1183 "test/vmul-microkernel-tester.h",
1184 ] + MICROKERNEL_TEST_HDRS,
1185 deps = MICROKERNEL_TEST_DEPS,
1186)
1187
1188xnnpack_unit_test(
1189 name = "f32_vmulcaddc_test",
1190 srcs = [
1191 "test/f32-vmulcaddc.cc",
1192 "test/vmulcaddc-microkernel-tester.h",
1193 "src/xnnpack/AlignedAllocator.h",
1194 ] + WEIGHTS_PACK_HDRS + MICROKERNEL_TEST_HDRS,
1195 deps = MICROKERNEL_TEST_DEPS,
1196)
1197
1198xnnpack_unit_test(
1199 name = "q8_avgpool_test",
1200 srcs = [
1201 "test/q8-avgpool.cc",
1202 "test/avgpool-microkernel-tester.h",
1203 "src/xnnpack/AlignedAllocator.h",
1204 ] + MICROKERNEL_TEST_HDRS,
1205 deps = MICROKERNEL_TEST_DEPS,
1206)
1207
1208xnnpack_unit_test(
1209 name = "q8_igemm_test",
1210 srcs = [
1211 "test/q8-igemm.cc",
1212 "test/gemm-microkernel-tester.h",
1213 "src/xnnpack/AlignedAllocator.h",
1214 ] + WEIGHTS_PACK_HDRS + MICROKERNEL_TEST_HDRS,
1215 deps = MICROKERNEL_TEST_DEPS,
1216)
1217
1218xnnpack_unit_test(
1219 name = "q8_dwconv_test",
1220 srcs = [
1221 "test/q8-dwconv.cc",
1222 "test/dwconv-microkernel-tester.h",
1223 "src/xnnpack/AlignedAllocator.h",
1224 ] + WEIGHTS_PACK_HDRS + MICROKERNEL_TEST_HDRS,
1225 deps = MICROKERNEL_TEST_DEPS,
1226)
1227
1228xnnpack_unit_test(
1229 name = "q8_gavgpool_test",
1230 srcs = [
1231 "test/q8-gavgpool.cc",
1232 "test/gavgpool-microkernel-tester.h",
1233 "src/xnnpack/AlignedAllocator.h",
1234 ] + MICROKERNEL_TEST_HDRS,
1235 deps = MICROKERNEL_TEST_DEPS,
1236)
1237
1238xnnpack_unit_test(
1239 name = "q8_gemm_test",
1240 srcs = [
1241 "test/q8-gemm.cc",
1242 "test/gemm-microkernel-tester.h",
1243 "src/xnnpack/AlignedAllocator.h",
1244 ] + WEIGHTS_PACK_HDRS + MICROKERNEL_TEST_HDRS,
1245 deps = MICROKERNEL_TEST_DEPS,
1246)
1247
1248xnnpack_unit_test(
1249 name = "q8_vadd_test",
1250 srcs = [
1251 "test/q8-vadd.cc",
1252 "test/vadd-microkernel-tester.h",
1253 ] + MICROKERNEL_TEST_HDRS,
1254 deps = MICROKERNEL_TEST_DEPS,
1255)
1256
1257xnnpack_unit_test(
1258 name = "u8_clamp_test",
1259 srcs = [
1260 "test/u8-clamp.cc",
1261 "test/clamp-microkernel-tester.h",
1262 ] + MICROKERNEL_TEST_HDRS,
1263 deps = MICROKERNEL_TEST_DEPS,
1264)
1265
1266xnnpack_unit_test(
1267 name = "u8_lut32norm_test",
1268 srcs = [
1269 "test/u8-lut32norm.cc",
1270 "test/lut-norm-microkernel-tester.h",
1271 ] + MICROKERNEL_TEST_HDRS,
1272 deps = MICROKERNEL_TEST_DEPS,
1273)
1274
1275xnnpack_unit_test(
1276 name = "u8_maxpool_test",
1277 srcs = [
1278 "test/u8-maxpool.cc",
1279 "test/maxpool-microkernel-tester.h",
1280 ] + MICROKERNEL_TEST_HDRS,
1281 deps = MICROKERNEL_TEST_DEPS,
1282)
1283
1284xnnpack_unit_test(
1285 name = "u8_rmax_test",
1286 srcs = [
1287 "test/u8-rmax.cc",
1288 "test/rmax-microkernel-tester.h",
1289 ] + MICROKERNEL_TEST_HDRS,
1290 deps = MICROKERNEL_TEST_DEPS,
1291)
1292
1293xnnpack_unit_test(
1294 name = "x32_packx_test",
1295 srcs = [
1296 "test/x32-packx.cc",
1297 "test/pack-microkernel-tester.h",
1298 "src/xnnpack/AlignedAllocator.h",
1299 ] + MICROKERNEL_TEST_HDRS,
1300 deps = MICROKERNEL_TEST_DEPS,
1301)
1302
1303xnnpack_unit_test(
1304 name = "x32_pad_test",
1305 srcs = [
1306 "test/x32-pad.cc",
1307 "test/pad-microkernel-tester.h",
1308 ] + MICROKERNEL_TEST_HDRS,
1309 deps = MICROKERNEL_TEST_DEPS,
1310)
1311
1312xnnpack_unit_test(
1313 name = "x32_unpool_test",
1314 srcs = [
1315 "test/x32-unpool.cc",
1316 "test/unpool-microkernel-tester.h",
1317 ] + MICROKERNEL_TEST_HDRS,
1318 deps = MICROKERNEL_TEST_DEPS,
1319)
1320
1321xnnpack_unit_test(
1322 name = "x32_zip_test",
1323 srcs = [
1324 "test/x32-zip.cc",
1325 "test/zip-microkernel-tester.h",
1326 ] + MICROKERNEL_TEST_HDRS,
1327 deps = MICROKERNEL_TEST_DEPS,
1328)
1329
1330xnnpack_unit_test(
1331 name = "x8_lut_test",
1332 srcs = [
1333 "test/x8-lut.cc",
1334 "test/lut-microkernel-tester.h",
1335 ] + MICROKERNEL_TEST_HDRS,
1336 deps = MICROKERNEL_TEST_DEPS,
1337)
1338
1339xnnpack_unit_test(
1340 name = "x8_zip_test",
1341 srcs = [
1342 "test/x8-zip.cc",
1343 "test/zip-microkernel-tester.h",
1344 ] + MICROKERNEL_TEST_HDRS,
1345 deps = MICROKERNEL_TEST_DEPS,
1346)
1347
1348########################### Size test for the library ##########################
1349
1350xnnpack_binary(
1351 name = "size_test",
1352 srcs = ["test/size.c"],
1353 deps = [":XNNPACK"],
1354)
1355
1356########################### Unit tests for operators ###########################
1357
1358xnnpack_unit_test(
1359 name = "add_test",
1360 srcs = [
1361 "test/add.cc",
1362 "test/add-operator-tester.h",
1363 ],
1364 deps = OPERATOR_TEST_DEPS,
1365)
1366
1367xnnpack_unit_test(
1368 name = "argmax_pooling_test",
1369 srcs = [
1370 "test/argmax-pooling.cc",
1371 "test/argmax-pooling-operator-tester.h",
1372 ] + OPERATOR_TEST_PARAMS_HDRS,
1373 deps = OPERATOR_TEST_DEPS,
1374)
1375
1376xnnpack_unit_test(
1377 name = "average_pooling_test",
1378 srcs = [
1379 "test/average-pooling.cc",
1380 "test/average-pooling-operator-tester.h",
1381 ] + OPERATOR_TEST_PARAMS_HDRS,
1382 deps = OPERATOR_TEST_DEPS,
1383)
1384
1385xnnpack_unit_test(
1386 name = "channel_pad_test",
1387 srcs = [
1388 "test/channel-pad.cc",
1389 "test/channel-pad-operator-tester.h",
1390 ] + OPERATOR_TEST_PARAMS_HDRS,
1391 deps = OPERATOR_TEST_DEPS,
1392)
1393
1394xnnpack_unit_test(
1395 name = "channel_shuffle_test",
1396 srcs = [
1397 "test/channel-shuffle.cc",
1398 "test/channel-shuffle-operator-tester.h",
1399 ],
1400 deps = OPERATOR_TEST_DEPS,
1401)
1402
1403xnnpack_unit_test(
1404 name = "clamp_test",
1405 srcs = [
1406 "test/clamp.cc",
1407 "test/clamp-operator-tester.h",
1408 ],
1409 deps = OPERATOR_TEST_DEPS,
1410)
1411
1412xnnpack_unit_test(
1413 name = "convolution_test",
1414 srcs = [
1415 "test/convolution.cc",
1416 "test/convolution-operator-tester.h",
1417 ],
1418 deps = OPERATOR_TEST_DEPS,
1419)
1420
1421xnnpack_unit_test(
1422 name = "convolution_spnchw_test",
1423 srcs = [
1424 "test/convolution-spnchw.cc",
1425 "test/convolution-spnchw-operator-tester.h",
1426 ],
1427 deps = OPERATOR_TEST_DEPS,
1428)
1429
1430xnnpack_unit_test(
1431 name = "deconvolution_test",
1432 srcs = [
1433 "test/deconvolution.cc",
1434 "test/deconvolution-operator-tester.h",
1435 ] + OPERATOR_TEST_PARAMS_HDRS,
1436 deps = OPERATOR_TEST_DEPS,
1437)
1438
1439xnnpack_unit_test(
1440 name = "fully_connected_test",
1441 srcs = [
1442 "test/fully-connected.cc",
1443 "test/fully-connected-operator-tester.h",
1444 ],
1445 deps = OPERATOR_TEST_DEPS,
1446)
1447
1448xnnpack_unit_test(
1449 name = "global_average_pooling_test",
1450 srcs = [
1451 "test/global-average-pooling.cc",
1452 "test/global-average-pooling-operator-tester.h",
1453 ] + OPERATOR_TEST_PARAMS_HDRS,
1454 deps = OPERATOR_TEST_DEPS,
1455)
1456
1457xnnpack_unit_test(
1458 name = "global_average_pooling_spnchw_test",
1459 srcs = [
1460 "test/global-average-pooling-spnchw.cc",
1461 "test/global-average-pooling-spnchw-operator-tester.h",
1462 ],
1463 deps = OPERATOR_TEST_DEPS,
1464)
1465
1466xnnpack_unit_test(
1467 name = "hardswish_test",
1468 srcs = [
1469 "test/hardswish.cc",
1470 "test/hardswish-operator-tester.h",
1471 ],
1472 deps = OPERATOR_TEST_DEPS,
1473)
1474
1475xnnpack_unit_test(
1476 name = "leaky_relu_test",
1477 srcs = [
1478 "test/leaky-relu.cc",
1479 "test/leaky-relu-operator-tester.h",
1480 ],
1481 deps = OPERATOR_TEST_DEPS,
1482)
1483
1484xnnpack_unit_test(
1485 name = "max_pooling_test",
1486 srcs = [
1487 "test/max-pooling.cc",
1488 "test/max-pooling-operator-tester.h",
1489 ] + OPERATOR_TEST_PARAMS_HDRS,
1490 deps = OPERATOR_TEST_DEPS,
1491)
1492
1493xnnpack_unit_test(
1494 name = "prelu_test",
1495 srcs = [
1496 "test/prelu.cc",
1497 "test/prelu-operator-tester.h",
1498 ] + OPERATOR_TEST_PARAMS_HDRS,
1499 deps = OPERATOR_TEST_DEPS,
1500)
1501
1502xnnpack_unit_test(
1503 name = "sigmoid_test",
1504 srcs = [
1505 "test/sigmoid.cc",
1506 "test/sigmoid-operator-tester.h",
1507 ],
1508 deps = OPERATOR_TEST_DEPS,
1509)
1510
1511xnnpack_unit_test(
1512 name = "softargmax_test",
1513 srcs = [
1514 "test/softargmax.cc",
1515 "test/softargmax-operator-tester.h",
1516 ],
1517 deps = OPERATOR_TEST_DEPS,
1518)
1519
1520xnnpack_unit_test(
1521 name = "unpooling_test",
1522 srcs = [
1523 "test/unpooling.cc",
1524 "test/unpooling-operator-tester.h",
1525 ],
1526 deps = OPERATOR_TEST_DEPS,
1527)
1528
1529############################# Build configurations #############################
1530
1531config_setting(
1532 name = "linux_k8",
1533 values = {
1534 "cpu": "k8",
1535 },
1536)
1537
1538config_setting(
Marat Dukhan4e45e662019-10-03 15:40:24 -07001539 name = "linux_aarch64",
1540 values = {
1541 "cpu": "aarch64",
1542 },
1543)
1544
1545config_setting(
Marat Dukhan08c4a432019-10-03 09:29:21 -07001546 name = "android",
1547 values = {"crosstool_top": "//external:android/crosstool"},
1548)
1549
1550config_setting(
1551 name = "android_armv7",
1552 values = {
1553 "crosstool_top": "//external:android/crosstool",
1554 "cpu": "armeabi-v7a",
1555 },
1556)
1557
1558config_setting(
1559 name = "android_arm64",
1560 values = {
1561 "crosstool_top": "//external:android/crosstool",
1562 "cpu": "arm64-v8a",
1563 },
1564)
1565
1566config_setting(
1567 name = "android_x86",
1568 values = {
1569 "crosstool_top": "//external:android/crosstool",
1570 "cpu": "x86",
1571 },
1572)
1573
1574config_setting(
1575 name = "android_x86_64",
1576 values = {
1577 "crosstool_top": "//external:android/crosstool",
1578 "cpu": "x86_64",
1579 },
1580)
1581
1582config_setting(
Marat Dukhan885ca242019-10-07 09:17:32 -07001583 name = "macos_x86_64",
1584 values = {
1585 "apple_platform_type": "macos",
1586 "cpu": "darwin",
1587 },
1588)
1589
1590config_setting(
Marat Dukhan08c4a432019-10-03 09:29:21 -07001591 name = "emscripten",
Marat Dukhan1a729ec2019-10-07 09:31:44 -07001592 values = {"crosstool_top": "//toolchain:emscripten"},
Marat Dukhan08c4a432019-10-03 09:29:21 -07001593)
1594
1595config_setting(
1596 name = "emscripten_wasm",
1597 values = {
Marat Dukhan1a729ec2019-10-07 09:31:44 -07001598 "crosstool_top": "//toolchain:emscripten",
Marat Dukhan08c4a432019-10-03 09:29:21 -07001599 "cpu": "wasm",
1600 },
1601)
1602
1603config_setting(
1604 name = "emscripten_wasmsimd",
1605 values = {
Marat Dukhan1a729ec2019-10-07 09:31:44 -07001606 "crosstool_top": "//toolchain:emscripten",
Marat Dukhan08c4a432019-10-03 09:29:21 -07001607 "cpu": "wasm",
1608 "features": "wasmsimd",
1609 },
1610)
1611
1612config_setting(
1613 name = "emscripten_asmjs",
1614 values = {
Marat Dukhan1a729ec2019-10-07 09:31:44 -07001615 "crosstool_top": "//toolchain:emscripten",
Marat Dukhan08c4a432019-10-03 09:29:21 -07001616 "cpu": "asmjs",
1617 },
1618)
1619
Marat Dukhan174706e2019-10-09 16:33:53 -07001620# Builds with -c dbg
Marat Dukhan08c4a432019-10-03 09:29:21 -07001621config_setting(
1622 name = "debug_build",
1623 values = {
1624 "compilation_mode": "dbg",
1625 },
Marat Dukhan08c4a432019-10-03 09:29:21 -07001626)
1627
Marat Dukhan174706e2019-10-09 16:33:53 -07001628# Builds with -c opt
Marat Dukhan08c4a432019-10-03 09:29:21 -07001629config_setting(
1630 name = "optimized_build",
1631 values = {
1632 "compilation_mode": "opt",
1633 },
Marat Dukhan08c4a432019-10-03 09:29:21 -07001634)
1635
1636# Enables usage of assembly kernels.
1637config_setting(
1638 name = "xnn_enable_assembly_explicit_true",
1639 define_values = {"xnn_enable_assembly": "true"},
1640)
1641
1642# Disables usage of assembly kernels.
1643config_setting(
1644 name = "xnn_enable_assembly_explicit_false",
1645 define_values = {"xnn_enable_assembly": "false"},
1646)