blob: fd297a448bfd3d695eec5276e1cc7869ab438513 [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 = [
263 "src/f32-igemm/4x12-neonfma-ld64.c",
264 "src/f32-igemm/4x2-neonfma-ld64.c",
265 "src/f32-igemm/4x4-neonfma-ld64.c",
266 "src/f32-igemm/4x8-neonfma-ld128.c",
267 "src/f32-igemm/4x8-neonfma-ld64.c",
268 "src/f32-igemm/6x8-neonfma-ld64.c",
269 "src/f32-dwconv/up4x9-neonfma.c",
270 "src/f32-dwconv/up8x9-neonfma.c",
271 "src/f32-gemm/1x8-neonfma-ld64.c",
272 "src/f32-gemm/4x12-neonfma-ld64.c",
273 "src/f32-gemm/4x2-neonfma-ld64.c",
274 "src/f32-gemm/4x8-neonfma-ld128.c",
275 "src/f32-gemm/4x8-neonfma-ld64.c",
276 "src/f32-gemm/5x8-neonfma-ld64.c",
277 "src/f32-gemm/6x8-neonfma-ld64.c",
278 "src/f32-gemminc/1x8-neonfma-ld64.c",
279 "src/f32-gemminc/4x12-neonfma-ld64.c",
280 "src/f32-gemminc/4x8-neonfma-ld128.c",
281 "src/f32-gemminc/4x8-neonfma-ld64.c",
282 "src/f32-gemminc/5x8-neonfma-ld64.c",
283 "src/f32-gemminc/6x8-neonfma-ld64.c",
284 "src/f32-hswish/neonfma.c",
285 "src/f32-ppmm/4x8-neonfma.c",
286 "src/f32-ppmm/8x8-neonfma.c",
287 "src/f32-vmulcaddc/c4-neonfma-x2.c",
288]
289
290AARCH64_NEONFMA_UKERNELS = [
291 "src/f32-conv-hwc/3x3s2p1c3x4-neonfma-2x2.c",
292 "src/f32-conv-hwc/3x3s2p1c3x8-neonfma-2x2.c",
293 "src/f32-conv-hwc2spchw/3x3s2p1c3x4-neonfma-2x2.c",
294 "src/f32-dwconv-spchw/3x3p1-neonfma.c",
295 "src/f32-dwconv-spchw/5x5p2-neonfma.c",
296 "src/f32-dwconv-spchw/3x3s2p1-neonfma.c",
297 "src/f32-dwconv-spchw/5x5s2p2-neonfma.c",
298 "src/f32-spmm/12x1-neonfma.c",
299 "src/f32-spmm/12x2-neonfma.c",
300 "src/f32-spmm/12x4-neonfma.c",
301 "src/f32-spmm/16x1-neonfma-pipelined.c",
302 "src/f32-spmm/16x1-neonfma-unroll2.c",
303 "src/f32-spmm/16x1-neonfma.c",
304 "src/f32-spmm/16x2-neonfma.c",
305 "src/f32-spmm/16x4-neonfma.c",
306 "src/f32-spmm/4x1-neonfma-pipelined.c",
307 "src/f32-spmm/4x1-neonfma-unroll2.c",
308 "src/f32-spmm/4x1-neonfma.c",
309 "src/f32-spmm/4x2-neonfma.c",
310 "src/f32-spmm/4x4-neonfma.c",
311 "src/f32-spmm/8x1-neonfma-pipelined.c",
312 "src/f32-spmm/8x1-neonfma-unroll2.c",
313 "src/f32-spmm/8x1-neonfma.c",
314 "src/f32-spmm/8x2-neonfma.c",
315 "src/f32-spmm/8x4-neonfma.c",
316]
317
318AARCH64_NEONFP16ARITH_UKERNELS = [
319 "src/f16-gemm/4x8-neonfp16arith-ld64.c",
320 "src/f16-gemm/6x8-neonfp16arith-ld64.c",
321 "src/f16-gemm/8x8-neonfp16arith-ld64.c",
322]
323
324SSE_UKERNELS = [
325 "src/f32-avgpool/mp9p8q-sse.c",
326 "src/f32-avgpool/up9-sse.c",
327 "src/f32-clamp/sse.c",
328 "src/f32-igemm/1x8-sse-dup.c",
329 "src/f32-igemm/1x8-sse-load1.c",
330 "src/f32-igemm/1x8s4-sse.c",
331 "src/f32-igemm/4x2c4-sse.c",
332 "src/f32-igemm/4x8-sse-dup.c",
333 "src/f32-igemm/4x8-sse-load1.c",
334 "src/f32-igemm/4x8s4-sse.c",
335 "src/f32-dwconv/up4x25-sse.c",
336 "src/f32-dwconv/up4x4-sse.c",
337 "src/f32-dwconv/up4x9-sse.c",
338 "src/f32-gavgpool-spchw/sse-x4.c",
339 "src/f32-gavgpool/mp7p7q-sse.c",
340 "src/f32-gavgpool/up7-sse.c",
341 "src/f32-gemm/1x8-sse-dup.c",
342 "src/f32-gemm/1x8-sse-load1.c",
343 "src/f32-gemm/1x8s4-sse.c",
344 "src/f32-gemm/4x8-sse-dup.c",
345 "src/f32-gemm/4x8-sse-load1.c",
346 "src/f32-gemm/4x8s4-sse.c",
347 "src/f32-gemminc/1x8-sse-dup.c",
348 "src/f32-gemminc/1x8-sse-load1.c",
349 "src/f32-gemminc/1x8s4-sse.c",
350 "src/f32-gemminc/4x8-sse-dup.c",
351 "src/f32-gemminc/4x8-sse-load1.c",
352 "src/f32-gemminc/4x8s4-sse.c",
353 "src/f32-hswish/sse.c",
354 "src/f32-maxpool/9p8q-sse.c",
355 "src/f32-pavgpool/mp9p8q-sse.c",
356 "src/f32-pavgpool/up9-sse.c",
357 "src/f32-dwconv-spchw/3x3p1-sse.c",
358 "src/f32-dwconv-spchw/3x3s2p1-sse.c",
359 "src/f32-ppmm/4x8-sse.c",
360 "src/f32-prelu/x4-sse.c",
361 "src/f32-rmax/sse.c",
362 "src/f32-spmm/4x1-sse.c",
363 "src/f32-spmm/8x1-sse.c",
364 "src/f32-vadd/sse.c",
365 "src/f32-vmul/sse.c",
366 "src/f32-vmulcaddc/c4-sse-x2.c",
367 "src/f32-vsub/sse.c",
368 "src/x32-packx/x4-sse.c",
369]
370
371SSE2_UKERNELS = [
372 "src/f32-argmaxpool/mp9p8q-sse2.c",
373 "src/f32-argmaxpool/up4-sse2.c",
374 "src/f32-argmaxpool/up9-sse2.c",
375 "src/q8-avgpool/mp9p8q-sse2.c",
376 "src/q8-avgpool/up9-sse2.c",
377 "src/q8-igemm/4x4c2-sse2.c",
378 "src/q8-dwconv/up8x9-sse2.c",
379 "src/q8-gavgpool/mp7p7q-sse2.c",
380 "src/q8-gavgpool/up7-sse2.c",
381 "src/q8-gemm/2x4c8-sse2.c",
382 "src/q8-gemm/4x4c2-sse2.c",
383 "src/q8-vadd/sse2.c",
384 "src/u8-clamp/sse2.c",
385 "src/u8-maxpool/9p8q-sse2.c",
386 "src/u8-rmax/sse2.c",
387 "src/x32-pad/x2-sse2.c",
388 "src/x32-zip/x2-sse2.c",
389 "src/x32-zip/x3-sse2.c",
390 "src/x32-zip/x4-sse2.c",
391 "src/x32-zip/xm-sse2.c",
392 "src/x8-zip/x2-sse2.c",
393 "src/x8-zip/x3-sse2.c",
394 "src/x8-zip/x4-sse2.c",
395 "src/x8-zip/xm-sse2.c",
396]
397
398AVX_UKERNELS = [
399 "src/f32-rmax/avx.c",
400]
401
402AVX512F_UKERNELS = [
403 "src/f32-rmax/avx512f.c",
404]
405
406AARCH32_ASM_UKERNELS = [
407 "src/q8-dwconv/up8x9-aarch32-neon.S",
408]
409
410AARCH64_ASM_UKERNELS = [
411 "src/f32-dwconv/up4x9-aarch64-neonfma-cortex-a55.S",
412 "src/f32-dwconv/up4x9-aarch64-neonfma.S",
413 "src/f32-gemm/1x12-aarch64-neonfma-cortex-a53.S",
414 "src/f32-gemm/1x8-aarch64-neonfma-cortex-a57.S",
415 "src/f32-gemm/1x8-aarch64-neonfma-cortex-a75.S",
416 "src/f32-gemm/4x12-aarch64-neonfma-cortex-a53.S",
417 "src/f32-gemm/4x8-aarch64-neonfma-cortex-a57.S",
418 "src/f32-gemm/4x8-aarch64-neonfma-cortex-a75.S",
419 "src/f32-gemm/4x8-aarch64-neonfma-ld128.S",
420 "src/f32-gemm/4x8-aarch64-neonfma-ld64.S",
421 "src/f32-gemm/5x8-aarch64-neonfma-cortex-a75.S",
422 "src/f32-gemm/6x8-aarch64-neonfma-cortex-a57.S",
423 "src/f32-gemm/6x8-aarch64-neonfma-cortex-a73.S",
424 "src/f32-gemm/6x8-aarch64-neonfma-cortex-a75.S",
425 "src/f32-gemm/6x8-aarch64-neonfma-ld128.S",
426 "src/f32-gemm/6x8-aarch64-neonfma-ld64.S",
427 "src/f32-gemminc/1x12-aarch64-neonfma-cortex-a53.S",
428 "src/f32-gemminc/1x8-aarch64-neonfma-cortex-a57.S",
429 "src/f32-gemminc/1x8-aarch64-neonfma-cortex-a75.S",
430 "src/f32-gemminc/4x12-aarch64-neonfma-cortex-a53.S",
431 "src/f32-gemminc/4x8-aarch64-neonfma-cortex-a57.S",
432 "src/f32-gemminc/4x8-aarch64-neonfma-cortex-a75.S",
433 "src/f32-gemminc/4x8-aarch64-neonfma-ld128.S",
434 "src/f32-gemminc/4x8-aarch64-neonfma-ld64.S",
435 "src/f32-gemminc/5x8-aarch64-neonfma-cortex-a75.S",
436 "src/f32-gemminc/6x8-aarch64-neonfma-cortex-a57.S",
437 "src/f32-gemminc/6x8-aarch64-neonfma-cortex-a73.S",
438 "src/f32-gemminc/6x8-aarch64-neonfma-cortex-a75.S",
439 "src/f32-gemminc/6x8-aarch64-neonfma-ld128.S",
440 "src/f32-gemminc/6x8-aarch64-neonfma-ld64.S",
441 "src/f32-igemm/1x12-aarch64-neonfma-cortex-a53.S",
442 "src/f32-igemm/1x8-aarch64-neonfma-cortex-a57.S",
443 "src/f32-igemm/1x8-aarch64-neonfma-cortex-a75.S",
444 "src/f32-igemm/4x12-aarch64-neonfma-cortex-a53.S",
445 "src/f32-igemm/4x8-aarch64-neonfma-cortex-a75.S",
446 "src/f32-igemm/5x8-aarch64-neonfma-cortex-a75.S",
447 "src/f32-igemm/6x8-aarch64-neonfma-cortex-a57.S",
448 "src/f32-igemm/6x8-aarch64-neonfma-cortex-a73.S",
449 "src/f32-igemm/6x8-aarch64-neonfma-cortex-a75.S",
450]
451
452INTERNAL_MICROKERNEL_HDRS = [
453 "src/xnnpack/argmaxpool.h",
454 "src/xnnpack/avgpool.h",
455 "src/xnnpack/clamp.h",
456 "src/xnnpack/common.h",
457 "src/xnnpack/conv.h",
458 "src/xnnpack/dwconv.h",
459 "src/xnnpack/gavgpool.h",
460 "src/xnnpack/gemm.h",
461 "src/xnnpack/hswish.h",
462 "src/xnnpack/igemm.h",
463 "src/xnnpack/lut.h",
464 "src/xnnpack/math.h",
465 "src/xnnpack/maxpool.h",
466 "src/xnnpack/packx.h",
467 "src/xnnpack/pad.h",
468 "src/xnnpack/params.h",
469 "src/xnnpack/pavgpool.h",
470 "src/xnnpack/ppmm.h",
471 "src/xnnpack/prelu.h",
472 "src/xnnpack/rmax.h",
473 "src/xnnpack/scalar-utils.h",
474 "src/xnnpack/spmm.h",
475 "src/xnnpack/unpool.h",
476 "src/xnnpack/vadd.h",
477 "src/xnnpack/vmul.h",
478 "src/xnnpack/vmulcaddc.h",
479 "src/xnnpack/vsub.h",
480 "src/xnnpack/zip.h",
481]
482
483INTERNAL_HDRS = INTERNAL_MICROKERNEL_HDRS + [
484 "include/xnnpack.h",
485 "src/xnnpack/allocator.h",
486 "src/xnnpack/compute.h",
487 "src/xnnpack/im2col.h",
488 "src/xnnpack/indirection.h",
Marat Dukhan08c4a432019-10-03 09:29:21 -0700489 "src/xnnpack/operator.h",
490 "src/xnnpack/pack.h",
491 "src/xnnpack/requantization.h",
492 "src/xnnpack/requantization-stubs.h",
493]
494
495MICROKERNEL_BENCHMARK_HDRS = INTERNAL_MICROKERNEL_HDRS + [
496 "src/xnnpack/requantization.h",
497 "include/xnnpack.h",
498]
499
500MICROKERNEL_TEST_HDRS = INTERNAL_MICROKERNEL_HDRS + [
501 "src/xnnpack/isa-checks.h",
502 "src/xnnpack/requantization.h",
503 "include/xnnpack.h",
504]
505
506OPERATOR_TEST_PARAMS_HDRS = [
507 "src/xnnpack/params.h",
508 "src/xnnpack/common.h",
509]
510
511WEIGHTS_PACK_HDRS = [
512 "src/xnnpack/pack.h",
513 "src/xnnpack/operator.h",
514 "src/xnnpack/compute.h",
515]
516
Marat Dukhanc8e00eb2019-10-04 14:55:26 -0700517LOGGING_COPTS = select({
518 # No logging in optimized mode
519 ":optimized_build": ["-DXNN_LOG_LEVEL=0"],
520 # Full logging in debug mode
521 ":debug_build": ["-DXNN_LOG_LEVEL=5"],
522 # Error-only logging in default (fastbuild) mode
523 "//conditions:default": ["-DXNN_LOG_LEVEL=2"],
524})
525
526LOGGING_HDRS = [
527 "src/xnnpack/log.h",
528]
529
Marat Dukhan08c4a432019-10-03 09:29:21 -0700530xnnpack_cc_library(
531 name = "scalar_ukernels",
532 srcs = SCALAR_UKERNELS,
533 hdrs = INTERNAL_HDRS,
534 aarch32_copts = ["-marm"],
535 copts = xnnpack_std_copts(),
536 deps = [
537 "@FP16",
538 "@FXdiv",
539 ],
540)
541
542xnnpack_cc_library(
543 name = "psimd_ukernels",
544 srcs = PSIMD_UKERNELS,
545 hdrs = INTERNAL_HDRS,
546 aarch32_copts = [
547 "-marm",
548 "-mfpu=neon",
549 ],
550 copts = xnnpack_std_copts(),
551 optimized_copts = [
552 "-O3",
553 "-ffast-math",
554 ],
555 deps = [
556 "@FP16",
557 "@psimd",
558 ],
559)
560
561xnnpack_cc_library(
562 name = "neon_ukernels",
563 hdrs = INTERNAL_HDRS,
564 aarch32_copts = [
565 "-marm",
566 "-mfpu=neon",
567 ],
568 aarch32_srcs = NEON_UKERNELS,
569 aarch64_srcs = NEON_UKERNELS,
570 copts = xnnpack_std_copts(),
571 deps = ["@FP16"],
572)
573
574xnnpack_cc_library(
575 name = "neonfma_ukernels",
576 hdrs = INTERNAL_HDRS,
577 aarch32_copts = [
578 "-marm",
579 "-mfpu=neon-vfpv4",
580 ],
581 aarch32_srcs = NEONFMA_UKERNELS,
582 aarch64_srcs = NEONFMA_UKERNELS + AARCH64_NEONFMA_UKERNELS,
583 copts = xnnpack_std_copts(),
584 deps = ["@FP16"],
585)
586
587xnnpack_cc_library(
588 name = "neonfp16arith_ukernels",
589 hdrs = INTERNAL_HDRS,
590 aarch64_copts = ["-march=armv8.2-a+fp16"],
591 aarch64_srcs = AARCH64_NEONFP16ARITH_UKERNELS,
592 copts = xnnpack_std_copts(),
593 deps = ["@FP16"],
594)
595
596xnnpack_cc_library(
597 name = "sse2_ukernels",
598 hdrs = INTERNAL_HDRS,
599 copts = xnnpack_std_copts(),
600 x86_copts = ["-msse2"],
601 x86_srcs = SSE_UKERNELS + SSE2_UKERNELS,
602 deps = ["@FP16"],
603)
604
605xnnpack_cc_library(
606 name = "avx_ukernels",
607 hdrs = INTERNAL_HDRS,
608 copts = xnnpack_std_copts(),
609 x86_copts = ["-mavx"],
610 x86_srcs = AVX_UKERNELS,
611 deps = ["@FP16"],
612)
613
614xnnpack_cc_library(
615 name = "avx512f_ukernels",
616 hdrs = INTERNAL_HDRS,
617 copts = xnnpack_std_copts(),
618 x86_copts = ["-mavx512f"],
619 x86_srcs = AVX512F_UKERNELS,
620 deps = ["@FP16"],
621)
622
623xnnpack_cc_library(
624 name = "asm_ukernels",
625 hdrs = ["src/xnnpack/assembly.h"],
626 aarch32_srcs = AARCH32_ASM_UKERNELS,
627 aarch64_srcs = AARCH64_ASM_UKERNELS,
628)
629
630xnnpack_aggregate_library(
631 name = "ukernels",
632 aarch32_deps = [
633 ":psimd_ukernels",
634 ":neon_ukernels",
635 ":neonfma_ukernels",
636 ":asm_ukernels",
637 ],
638 aarch64_deps = [
639 ":psimd_ukernels",
640 ":neon_ukernels",
641 ":neonfma_ukernels",
642 ":neonfp16arith_ukernels",
643 ":asm_ukernels",
644 ],
645 generic_deps = [":scalar_ukernels"],
646 wasmsimd_deps = [
647 ":psimd_ukernels",
648 ],
649 x86_deps = [
650 ":psimd_ukernels",
651 ":sse2_ukernels",
652 ":avx_ukernels",
653 ":avx512f_ukernels",
654 ],
655)
656
657xnnpack_cc_library(
658 name = "im2col",
659 srcs = ["src/im2col.c"],
660 hdrs = [
661 "src/xnnpack/common.h",
662 "src/xnnpack/im2col.h",
663 ],
664 copts = xnnpack_std_copts(),
665)
666
667xnnpack_cc_library(
668 name = "indirection",
669 srcs = ["src/indirection.c"],
670 hdrs = INTERNAL_HDRS,
671 copts = xnnpack_std_copts(),
672 deps = [
673 "@FP16",
674 "@FXdiv",
675 "@pthreadpool",
676 ],
677)
678
679xnnpack_cc_library(
680 name = "operator_run",
681 srcs = ["src/operator-run.c"],
Marat Dukhanc8e00eb2019-10-04 14:55:26 -0700682 hdrs = INTERNAL_HDRS + LOGGING_HDRS,
683 copts = xnnpack_std_copts() + LOGGING_COPTS + [
Marat Dukhan08c4a432019-10-03 09:29:21 -0700684 # Wrappers for multi-pass microkernels use VLAs for temporary buffers.
685 "-Wno-vla",
686 ],
687 deps = [
688 "@FP16",
689 "@FXdiv",
690 "@clog",
691 "@pthreadpool",
692 ],
693)
694
695cc_library(
696 name = "enable_assembly",
697 defines = select({
698 ":xnn_enable_assembly_explicit_true": ["XNN_ENABLE_ASSEMBLY=1"],
699 ":xnn_enable_assembly_explicit_false": ["XNN_ENABLE_ASSEMBLY=0"],
700 "//conditions:default": [],
701 }),
702)
703
704cc_library(
705 name = "operators",
706 srcs = OPERATOR_SRCS + [
707 "src/init.c",
708 "src/operator-delete.c",
709 ] + select({
710 ":emscripten_wasm": ["src/wasm-stubs.c"],
711 "//conditions:default": [],
712 }),
Marat Dukhanc8e00eb2019-10-04 14:55:26 -0700713 copts = xnnpack_std_copts() + LOGGING_COPTS + [
Marat Dukhan08c4a432019-10-03 09:29:21 -0700714 "-Isrc",
715 "-Iinclude",
716 ] + select({
717 ":debug_build": [],
718 "//conditions:default": xnnpack_min_size_copts(),
719 }),
720 linkstatic = True,
Marat Dukhanc8e00eb2019-10-04 14:55:26 -0700721 textual_hdrs = INTERNAL_HDRS + LOGGING_HDRS,
Marat Dukhan08c4a432019-10-03 09:29:21 -0700722 deps = [
723 ":enable_assembly",
724 ":indirection",
725 ":ukernels",
726 "@FP16",
727 "@FXdiv",
728 "@clog",
Marat Dukhan08c4a432019-10-03 09:29:21 -0700729 "@pthreadpool",
Marat Dukhand343c222019-10-07 09:22:14 -0700730 ] + select({
731 ":emscripten": [],
732 "//conditions:default": ["@cpuinfo"],
733 }),
Marat Dukhan08c4a432019-10-03 09:29:21 -0700734)
735
736cc_library(
737 name = "XNNPACK",
738 hdrs = ["include/xnnpack.h"],
739 includes = ["include"],
740 linkstatic = True,
Marat Dukhan08c4a432019-10-03 09:29:21 -0700741 visibility = xnnpack_visibility(),
742 deps = [
743 ":operator_run",
744 ":operators",
745 "@pthreadpool",
746 ],
747)
748
749cc_library(
750 name = "bench_utils",
751 srcs = ["bench/utils.cc"],
752 hdrs = ["bench/utils.h"],
753 copts = ["-Wno-unused-result"],
754 linkstatic = True,
755 deps = ["@cpuinfo"],
756)
757
758######################### Unit tests for micro-kernels #########################
759
760xnnpack_benchmark(
761 name = "q8_gemm_bench",
762 srcs = [
763 "bench/gemm.h",
764 "bench/q8-gemm.cc",
765 "src/xnnpack/AlignedAllocator.h",
766 ] + WEIGHTS_PACK_HDRS + MICROKERNEL_BENCHMARK_HDRS,
767 copts = ["-Wno-unused-function"] + xnnpack_optional_ruy_copts() + xnnpack_optional_gemmlowp_copts(),
768 deps = MICROKERNEL_BENCHMARK_DEPS + xnnpack_optional_ruy_deps() + xnnpack_optional_gemmlowp_deps(),
769)
770
771xnnpack_benchmark(
772 name = "f16_gemm_bench",
773 srcs = [
774 "bench/f16-gemm.cc",
775 "bench/gemm.h",
776 "src/xnnpack/AlignedAllocator.h",
777 ] + WEIGHTS_PACK_HDRS + MICROKERNEL_BENCHMARK_HDRS,
778 copts = ["-Wno-unused-function"],
779 deps = MICROKERNEL_BENCHMARK_DEPS,
780)
781
782xnnpack_benchmark(
783 name = "f32_igemm_bench",
784 srcs = [
785 "bench/f32-igemm.cc",
786 "bench/conv.h",
787 "src/xnnpack/AlignedAllocator.h",
788 ] + MICROKERNEL_BENCHMARK_HDRS,
789 deps = MICROKERNEL_BENCHMARK_DEPS + [":indirection"],
790)
791
792xnnpack_benchmark(
793 name = "f32_conv_hwc_bench",
794 srcs = [
795 "bench/f32-conv-hwc.cc",
796 "bench/dconv.h",
797 "src/xnnpack/AlignedAllocator.h",
798 ] + WEIGHTS_PACK_HDRS + MICROKERNEL_BENCHMARK_HDRS,
799 copts = ["-Wno-unused-function"],
800 deps = MICROKERNEL_BENCHMARK_DEPS,
801)
802
803xnnpack_benchmark(
804 name = "f32_dwconv_bench",
805 srcs = [
806 "bench/f32-dwconv.cc",
807 "bench/dwconv.h",
808 "src/xnnpack/AlignedAllocator.h",
809 ] + MICROKERNEL_BENCHMARK_HDRS,
810 deps = MICROKERNEL_BENCHMARK_DEPS + [":indirection"],
811)
812
813xnnpack_benchmark(
814 name = "f32_dwconv_spchw_bench",
815 srcs = [
816 "bench/f32-dwconv-spchw.cc",
817 "bench/dwconv.h",
818 "src/xnnpack/AlignedAllocator.h",
819 ] + WEIGHTS_PACK_HDRS + MICROKERNEL_BENCHMARK_HDRS,
820 deps = MICROKERNEL_BENCHMARK_DEPS + [":indirection"],
821)
822
823xnnpack_benchmark(
824 name = "f32_gemm_bench",
825 srcs = [
826 "bench/f32-gemm.cc",
827 "bench/gemm.h",
828 "src/xnnpack/AlignedAllocator.h",
829 ] + WEIGHTS_PACK_HDRS + MICROKERNEL_BENCHMARK_HDRS,
830 copts = ["-Wno-unused-function"] + xnnpack_optional_ruy_copts(),
831 deps = MICROKERNEL_BENCHMARK_DEPS + xnnpack_optional_ruy_deps(),
832)
833
834xnnpack_benchmark(
835 name = "f32_rmax_bench",
836 srcs = [
837 "bench/f32-rmax.cc",
838 "src/xnnpack/AlignedAllocator.h",
839 ] + MICROKERNEL_BENCHMARK_HDRS,
840 deps = MICROKERNEL_BENCHMARK_DEPS,
841)
842
843xnnpack_benchmark(
844 name = "f32_spmm_bench",
845 srcs = [
846 "bench/f32-spmm.cc",
847 "bench/gemm.h",
848 "src/xnnpack/AlignedAllocator.h",
849 ] + MICROKERNEL_BENCHMARK_HDRS,
850 copts = ["-Wno-unused-function"],
851 deps = MICROKERNEL_BENCHMARK_DEPS,
852)
853
854xnnpack_benchmark(
855 name = "f32_im2col_gemm_bench",
856 srcs = [
857 "bench/f32-im2col-gemm.cc",
858 "bench/conv.h",
859 "src/xnnpack/AlignedAllocator.h",
860 ] + WEIGHTS_PACK_HDRS + MICROKERNEL_BENCHMARK_HDRS,
861 deps = MICROKERNEL_BENCHMARK_DEPS + [":im2col"],
862)
863
864########################### Benchmarks for operators ###########################
865
866xnnpack_benchmark(
867 name = "add_bench",
868 srcs = ["bench/add.cc"],
869 deps = OPERATOR_BENCHMARK_DEPS,
870)
871
872xnnpack_benchmark(
873 name = "average_pooling_bench",
874 srcs = ["bench/average-pooling.cc"],
875 deps = OPERATOR_BENCHMARK_DEPS,
876)
877
878xnnpack_benchmark(
879 name = "channel_shuffle_bench",
880 srcs = ["bench/channel-shuffle.cc"],
881 deps = OPERATOR_BENCHMARK_DEPS,
882)
883
884xnnpack_benchmark(
885 name = "convolution_bench",
886 srcs = ["bench/convolution.cc"],
887 copts = xnnpack_optional_tflite_copts() + xnnpack_optional_armcl_copts(),
888 deps = OPERATOR_BENCHMARK_DEPS + xnnpack_optional_tflite_deps() + xnnpack_optional_armcl_deps(),
889)
890
891xnnpack_benchmark(
892 name = "deconvolution_bench",
893 srcs = ["bench/deconvolution.cc"],
894 copts = xnnpack_optional_tflite_copts(),
895 deps = OPERATOR_BENCHMARK_DEPS + xnnpack_optional_tflite_deps(),
896)
897
898xnnpack_benchmark(
899 name = "global_average_pooling_bench",
900 srcs = ["bench/global-average-pooling.cc"],
901 deps = OPERATOR_BENCHMARK_DEPS,
902)
903
904xnnpack_benchmark(
905 name = "max_pooling_bench",
906 srcs = ["bench/max-pooling.cc"],
907 deps = OPERATOR_BENCHMARK_DEPS,
908)
909
910xnnpack_benchmark(
911 name = "sigmoid_bench",
912 srcs = ["bench/sigmoid.cc"],
913 deps = OPERATOR_BENCHMARK_DEPS,
914)
915
916xnnpack_benchmark(
917 name = "softargmax_bench",
918 srcs = ["bench/softargmax.cc"],
919 deps = OPERATOR_BENCHMARK_DEPS,
920)
921
Marat Dukhanc068bb62019-10-04 13:24:39 -0700922############################# End-to-end benchmarks ############################
923
924cc_library(
925 name = "mobilenet_v1",
926 srcs = ["models/mobilenet-v1.cc"],
927 hdrs = ["models/models.h"],
928 linkstatic = True,
929 deps = [
930 ":XNNPACK",
931 "@pthreadpool",
932 ],
933)
934
935cc_library(
936 name = "mobilenet_v2",
937 srcs = ["models/mobilenet-v2.cc"],
938 hdrs = ["models/models.h"],
939 linkstatic = True,
940 deps = [
941 ":XNNPACK",
942 "@pthreadpool",
943 ],
944)
945
946xnnpack_benchmark(
947 name = "end2end_bench",
948 srcs = ["bench/end2end.cc"],
949 deps = [
950 ":XNNPACK",
951 ":mobilenet_v1",
952 ":mobilenet_v2",
953 "@pthreadpool",
954 ],
955)
956
Marat Dukhan08c4a432019-10-03 09:29:21 -0700957######################### Unit tests for micro-kernels #########################
958
959xnnpack_unit_test(
960 name = "f16_gemm_test",
961 srcs = [
962 "test/f16-gemm.cc",
963 "test/gemm-microkernel-tester.h",
964 "src/xnnpack/AlignedAllocator.h",
965 ] + WEIGHTS_PACK_HDRS + MICROKERNEL_TEST_HDRS,
966 deps = MICROKERNEL_TEST_DEPS,
967)
968
969xnnpack_unit_test(
970 name = "f32_argmaxpool_test",
971 srcs = [
972 "test/f32-argmaxpool.cc",
973 "test/argmaxpool-microkernel-tester.h",
974 "src/xnnpack/AlignedAllocator.h",
975 ] + MICROKERNEL_TEST_HDRS,
976 deps = MICROKERNEL_TEST_DEPS,
977)
978
979xnnpack_unit_test(
980 name = "f32_avgpool_test",
981 srcs = [
982 "test/f32-avgpool.cc",
983 "test/avgpool-microkernel-tester.h",
984 "src/xnnpack/AlignedAllocator.h",
985 ] + MICROKERNEL_TEST_HDRS,
986 deps = MICROKERNEL_TEST_DEPS,
987)
988
989xnnpack_unit_test(
990 name = "f32_clamp_test",
991 srcs = [
992 "test/f32-clamp.cc",
993 "test/clamp-microkernel-tester.h",
994 ] + MICROKERNEL_TEST_HDRS,
995 deps = MICROKERNEL_TEST_DEPS,
996)
997
998xnnpack_unit_test(
999 name = "f32_igemm_test",
1000 srcs = [
1001 "test/f32-igemm.cc",
1002 "test/gemm-microkernel-tester.h",
1003 "src/xnnpack/AlignedAllocator.h",
1004 ] + WEIGHTS_PACK_HDRS + MICROKERNEL_TEST_HDRS,
1005 deps = MICROKERNEL_TEST_DEPS,
1006)
1007
1008xnnpack_unit_test(
1009 name = "f32_conv_hwc_test",
1010 srcs = [
1011 "test/f32-conv-hwc.cc",
1012 "test/conv-hwc-microkernel-tester.h",
1013 "src/xnnpack/AlignedAllocator.h",
1014 ] + WEIGHTS_PACK_HDRS + MICROKERNEL_TEST_HDRS,
1015 deps = MICROKERNEL_TEST_DEPS,
1016)
1017
1018xnnpack_unit_test(
1019 name = "f32_conv_hwc2spchw_test",
1020 srcs = [
1021 "test/f32-conv-hwc2spchw.cc",
1022 "test/conv-hwc2spchw-microkernel-tester.h",
1023 "src/xnnpack/AlignedAllocator.h",
1024 ] + WEIGHTS_PACK_HDRS + MICROKERNEL_TEST_HDRS,
1025 deps = MICROKERNEL_TEST_DEPS,
1026)
1027
1028xnnpack_unit_test(
1029 name = "f32_dwconv_test",
1030 srcs = [
1031 "test/f32-dwconv.cc",
1032 "test/dwconv-microkernel-tester.h",
1033 "src/xnnpack/AlignedAllocator.h",
1034 ] + WEIGHTS_PACK_HDRS + MICROKERNEL_TEST_HDRS,
1035 deps = MICROKERNEL_TEST_DEPS,
1036)
1037
1038xnnpack_unit_test(
1039 name = "f32_dwconv_spchw_test",
1040 srcs = [
1041 "test/f32-dwconv-spchw.cc",
1042 "test/dwconv-spchw-microkernel-tester.h",
1043 "src/xnnpack/AlignedAllocator.h",
1044 ] + WEIGHTS_PACK_HDRS + MICROKERNEL_TEST_HDRS,
1045 deps = MICROKERNEL_TEST_DEPS,
1046)
1047
1048xnnpack_unit_test(
1049 name = "f32_gavgpool_test",
1050 srcs = [
1051 "test/f32-gavgpool.cc",
1052 "test/gavgpool-microkernel-tester.h",
1053 "src/xnnpack/AlignedAllocator.h",
1054 ] + MICROKERNEL_TEST_HDRS,
1055 deps = MICROKERNEL_TEST_DEPS,
1056)
1057
1058xnnpack_unit_test(
1059 name = "f32_gavgpool_spchw_test",
1060 srcs = [
1061 "test/f32-gavgpool-spchw.cc",
1062 "test/gavgpool-spchw-microkernel-tester.h",
1063 "src/xnnpack/AlignedAllocator.h",
1064 ] + MICROKERNEL_TEST_HDRS,
1065 deps = MICROKERNEL_TEST_DEPS,
1066)
1067
1068xnnpack_unit_test(
1069 name = "f32_gemm_test",
1070 srcs = [
1071 "test/f32-gemm.cc",
1072 "test/gemm-microkernel-tester.h",
1073 "src/xnnpack/AlignedAllocator.h",
1074 ] + WEIGHTS_PACK_HDRS + MICROKERNEL_TEST_HDRS,
1075 deps = MICROKERNEL_TEST_DEPS,
1076)
1077
1078xnnpack_unit_test(
1079 name = "f32_gemminc_test",
1080 srcs = [
1081 "test/f32-gemminc.cc",
1082 "test/gemm-microkernel-tester.h",
1083 "src/xnnpack/AlignedAllocator.h",
1084 ] + WEIGHTS_PACK_HDRS + MICROKERNEL_TEST_HDRS,
1085 deps = MICROKERNEL_TEST_DEPS,
1086)
1087
1088xnnpack_unit_test(
1089 name = "f32_hswish_test",
1090 srcs = [
1091 "test/f32-hswish.cc",
1092 "test/hswish-microkernel-tester.h",
1093 ] + MICROKERNEL_TEST_HDRS,
1094 deps = MICROKERNEL_TEST_DEPS,
1095)
1096
1097xnnpack_unit_test(
1098 name = "f32_maxpool_test",
1099 srcs = [
1100 "test/f32-maxpool.cc",
1101 "test/maxpool-microkernel-tester.h",
1102 ] + MICROKERNEL_TEST_HDRS,
1103 deps = MICROKERNEL_TEST_DEPS,
1104)
1105
1106xnnpack_unit_test(
1107 name = "f32_pavgpool_test",
1108 srcs = [
1109 "test/f32-pavgpool.cc",
1110 "test/avgpool-microkernel-tester.h",
1111 "src/xnnpack/AlignedAllocator.h",
1112 ] + MICROKERNEL_TEST_HDRS,
1113 deps = MICROKERNEL_TEST_DEPS,
1114)
1115
1116xnnpack_unit_test(
1117 name = "f32_ppmm_test",
1118 srcs = [
1119 "test/f32-ppmm.cc",
1120 "test/gemm-microkernel-tester.h",
1121 "src/xnnpack/AlignedAllocator.h",
1122 ] + WEIGHTS_PACK_HDRS + MICROKERNEL_TEST_HDRS,
1123 deps = MICROKERNEL_TEST_DEPS,
1124)
1125
1126xnnpack_unit_test(
1127 name = "f32_prelu_test",
1128 srcs = [
1129 "test/f32-prelu.cc",
1130 "test/prelu-microkernel-tester.h",
1131 "src/xnnpack/AlignedAllocator.h",
1132 ] + MICROKERNEL_TEST_HDRS,
1133 deps = MICROKERNEL_TEST_DEPS,
1134)
1135
1136xnnpack_unit_test(
1137 name = "f32_rmax_test",
1138 srcs = [
1139 "test/f32-rmax.cc",
1140 "test/rmax-microkernel-tester.h",
1141 ] + MICROKERNEL_TEST_HDRS,
1142 deps = MICROKERNEL_TEST_DEPS,
1143)
1144
1145xnnpack_unit_test(
1146 name = "f32_spmm_test",
1147 srcs = [
1148 "test/f32-spmm.cc",
1149 "test/spmm-microkernel-tester.h",
1150 "src/xnnpack/AlignedAllocator.h",
1151 ] + MICROKERNEL_TEST_HDRS,
1152 deps = MICROKERNEL_TEST_DEPS,
1153)
1154
1155xnnpack_unit_test(
1156 name = "f32_vadd_test",
1157 srcs = [
1158 "test/f32-vadd.cc",
1159 "test/vadd-microkernel-tester.h",
1160 ] + MICROKERNEL_TEST_HDRS,
1161 deps = MICROKERNEL_TEST_DEPS,
1162)
1163
1164xnnpack_unit_test(
1165 name = "f32_vsub_test",
1166 srcs = [
1167 "test/f32-vsub.cc",
1168 "test/vsub-microkernel-tester.h",
1169 ] + MICROKERNEL_TEST_HDRS,
1170 deps = MICROKERNEL_TEST_DEPS,
1171)
1172
1173xnnpack_unit_test(
1174 name = "f32_vmul_test",
1175 srcs = [
1176 "test/f32-vmul.cc",
1177 "test/vmul-microkernel-tester.h",
1178 ] + MICROKERNEL_TEST_HDRS,
1179 deps = MICROKERNEL_TEST_DEPS,
1180)
1181
1182xnnpack_unit_test(
1183 name = "f32_vmulcaddc_test",
1184 srcs = [
1185 "test/f32-vmulcaddc.cc",
1186 "test/vmulcaddc-microkernel-tester.h",
1187 "src/xnnpack/AlignedAllocator.h",
1188 ] + WEIGHTS_PACK_HDRS + MICROKERNEL_TEST_HDRS,
1189 deps = MICROKERNEL_TEST_DEPS,
1190)
1191
1192xnnpack_unit_test(
1193 name = "q8_avgpool_test",
1194 srcs = [
1195 "test/q8-avgpool.cc",
1196 "test/avgpool-microkernel-tester.h",
1197 "src/xnnpack/AlignedAllocator.h",
1198 ] + MICROKERNEL_TEST_HDRS,
1199 deps = MICROKERNEL_TEST_DEPS,
1200)
1201
1202xnnpack_unit_test(
1203 name = "q8_igemm_test",
1204 srcs = [
1205 "test/q8-igemm.cc",
1206 "test/gemm-microkernel-tester.h",
1207 "src/xnnpack/AlignedAllocator.h",
1208 ] + WEIGHTS_PACK_HDRS + MICROKERNEL_TEST_HDRS,
1209 deps = MICROKERNEL_TEST_DEPS,
1210)
1211
1212xnnpack_unit_test(
1213 name = "q8_dwconv_test",
1214 srcs = [
1215 "test/q8-dwconv.cc",
1216 "test/dwconv-microkernel-tester.h",
1217 "src/xnnpack/AlignedAllocator.h",
1218 ] + WEIGHTS_PACK_HDRS + MICROKERNEL_TEST_HDRS,
1219 deps = MICROKERNEL_TEST_DEPS,
1220)
1221
1222xnnpack_unit_test(
1223 name = "q8_gavgpool_test",
1224 srcs = [
1225 "test/q8-gavgpool.cc",
1226 "test/gavgpool-microkernel-tester.h",
1227 "src/xnnpack/AlignedAllocator.h",
1228 ] + MICROKERNEL_TEST_HDRS,
1229 deps = MICROKERNEL_TEST_DEPS,
1230)
1231
1232xnnpack_unit_test(
1233 name = "q8_gemm_test",
1234 srcs = [
1235 "test/q8-gemm.cc",
1236 "test/gemm-microkernel-tester.h",
1237 "src/xnnpack/AlignedAllocator.h",
1238 ] + WEIGHTS_PACK_HDRS + MICROKERNEL_TEST_HDRS,
1239 deps = MICROKERNEL_TEST_DEPS,
1240)
1241
1242xnnpack_unit_test(
1243 name = "q8_vadd_test",
1244 srcs = [
1245 "test/q8-vadd.cc",
1246 "test/vadd-microkernel-tester.h",
1247 ] + MICROKERNEL_TEST_HDRS,
1248 deps = MICROKERNEL_TEST_DEPS,
1249)
1250
1251xnnpack_unit_test(
1252 name = "u8_clamp_test",
1253 srcs = [
1254 "test/u8-clamp.cc",
1255 "test/clamp-microkernel-tester.h",
1256 ] + MICROKERNEL_TEST_HDRS,
1257 deps = MICROKERNEL_TEST_DEPS,
1258)
1259
1260xnnpack_unit_test(
1261 name = "u8_lut32norm_test",
1262 srcs = [
1263 "test/u8-lut32norm.cc",
1264 "test/lut-norm-microkernel-tester.h",
1265 ] + MICROKERNEL_TEST_HDRS,
1266 deps = MICROKERNEL_TEST_DEPS,
1267)
1268
1269xnnpack_unit_test(
1270 name = "u8_maxpool_test",
1271 srcs = [
1272 "test/u8-maxpool.cc",
1273 "test/maxpool-microkernel-tester.h",
1274 ] + MICROKERNEL_TEST_HDRS,
1275 deps = MICROKERNEL_TEST_DEPS,
1276)
1277
1278xnnpack_unit_test(
1279 name = "u8_rmax_test",
1280 srcs = [
1281 "test/u8-rmax.cc",
1282 "test/rmax-microkernel-tester.h",
1283 ] + MICROKERNEL_TEST_HDRS,
1284 deps = MICROKERNEL_TEST_DEPS,
1285)
1286
1287xnnpack_unit_test(
1288 name = "x32_packx_test",
1289 srcs = [
1290 "test/x32-packx.cc",
1291 "test/pack-microkernel-tester.h",
1292 "src/xnnpack/AlignedAllocator.h",
1293 ] + MICROKERNEL_TEST_HDRS,
1294 deps = MICROKERNEL_TEST_DEPS,
1295)
1296
1297xnnpack_unit_test(
1298 name = "x32_pad_test",
1299 srcs = [
1300 "test/x32-pad.cc",
1301 "test/pad-microkernel-tester.h",
1302 ] + MICROKERNEL_TEST_HDRS,
1303 deps = MICROKERNEL_TEST_DEPS,
1304)
1305
1306xnnpack_unit_test(
1307 name = "x32_unpool_test",
1308 srcs = [
1309 "test/x32-unpool.cc",
1310 "test/unpool-microkernel-tester.h",
1311 ] + MICROKERNEL_TEST_HDRS,
1312 deps = MICROKERNEL_TEST_DEPS,
1313)
1314
1315xnnpack_unit_test(
1316 name = "x32_zip_test",
1317 srcs = [
1318 "test/x32-zip.cc",
1319 "test/zip-microkernel-tester.h",
1320 ] + MICROKERNEL_TEST_HDRS,
1321 deps = MICROKERNEL_TEST_DEPS,
1322)
1323
1324xnnpack_unit_test(
1325 name = "x8_lut_test",
1326 srcs = [
1327 "test/x8-lut.cc",
1328 "test/lut-microkernel-tester.h",
1329 ] + MICROKERNEL_TEST_HDRS,
1330 deps = MICROKERNEL_TEST_DEPS,
1331)
1332
1333xnnpack_unit_test(
1334 name = "x8_zip_test",
1335 srcs = [
1336 "test/x8-zip.cc",
1337 "test/zip-microkernel-tester.h",
1338 ] + MICROKERNEL_TEST_HDRS,
1339 deps = MICROKERNEL_TEST_DEPS,
1340)
1341
1342########################### Size test for the library ##########################
1343
1344xnnpack_binary(
1345 name = "size_test",
1346 srcs = ["test/size.c"],
1347 deps = [":XNNPACK"],
1348)
1349
1350########################### Unit tests for operators ###########################
1351
1352xnnpack_unit_test(
1353 name = "add_test",
1354 srcs = [
1355 "test/add.cc",
1356 "test/add-operator-tester.h",
1357 ],
1358 deps = OPERATOR_TEST_DEPS,
1359)
1360
1361xnnpack_unit_test(
1362 name = "argmax_pooling_test",
1363 srcs = [
1364 "test/argmax-pooling.cc",
1365 "test/argmax-pooling-operator-tester.h",
1366 ] + OPERATOR_TEST_PARAMS_HDRS,
1367 deps = OPERATOR_TEST_DEPS,
1368)
1369
1370xnnpack_unit_test(
1371 name = "average_pooling_test",
1372 srcs = [
1373 "test/average-pooling.cc",
1374 "test/average-pooling-operator-tester.h",
1375 ] + OPERATOR_TEST_PARAMS_HDRS,
1376 deps = OPERATOR_TEST_DEPS,
1377)
1378
1379xnnpack_unit_test(
1380 name = "channel_pad_test",
1381 srcs = [
1382 "test/channel-pad.cc",
1383 "test/channel-pad-operator-tester.h",
1384 ] + OPERATOR_TEST_PARAMS_HDRS,
1385 deps = OPERATOR_TEST_DEPS,
1386)
1387
1388xnnpack_unit_test(
1389 name = "channel_shuffle_test",
1390 srcs = [
1391 "test/channel-shuffle.cc",
1392 "test/channel-shuffle-operator-tester.h",
1393 ],
1394 deps = OPERATOR_TEST_DEPS,
1395)
1396
1397xnnpack_unit_test(
1398 name = "clamp_test",
1399 srcs = [
1400 "test/clamp.cc",
1401 "test/clamp-operator-tester.h",
1402 ],
1403 deps = OPERATOR_TEST_DEPS,
1404)
1405
1406xnnpack_unit_test(
1407 name = "convolution_test",
1408 srcs = [
1409 "test/convolution.cc",
1410 "test/convolution-operator-tester.h",
1411 ],
1412 deps = OPERATOR_TEST_DEPS,
1413)
1414
1415xnnpack_unit_test(
1416 name = "convolution_spnchw_test",
1417 srcs = [
1418 "test/convolution-spnchw.cc",
1419 "test/convolution-spnchw-operator-tester.h",
1420 ],
1421 deps = OPERATOR_TEST_DEPS,
1422)
1423
1424xnnpack_unit_test(
1425 name = "deconvolution_test",
1426 srcs = [
1427 "test/deconvolution.cc",
1428 "test/deconvolution-operator-tester.h",
1429 ] + OPERATOR_TEST_PARAMS_HDRS,
1430 deps = OPERATOR_TEST_DEPS,
1431)
1432
1433xnnpack_unit_test(
1434 name = "fully_connected_test",
1435 srcs = [
1436 "test/fully-connected.cc",
1437 "test/fully-connected-operator-tester.h",
1438 ],
1439 deps = OPERATOR_TEST_DEPS,
1440)
1441
1442xnnpack_unit_test(
1443 name = "global_average_pooling_test",
1444 srcs = [
1445 "test/global-average-pooling.cc",
1446 "test/global-average-pooling-operator-tester.h",
1447 ] + OPERATOR_TEST_PARAMS_HDRS,
1448 deps = OPERATOR_TEST_DEPS,
1449)
1450
1451xnnpack_unit_test(
1452 name = "global_average_pooling_spnchw_test",
1453 srcs = [
1454 "test/global-average-pooling-spnchw.cc",
1455 "test/global-average-pooling-spnchw-operator-tester.h",
1456 ],
1457 deps = OPERATOR_TEST_DEPS,
1458)
1459
1460xnnpack_unit_test(
1461 name = "hardswish_test",
1462 srcs = [
1463 "test/hardswish.cc",
1464 "test/hardswish-operator-tester.h",
1465 ],
1466 deps = OPERATOR_TEST_DEPS,
1467)
1468
1469xnnpack_unit_test(
1470 name = "leaky_relu_test",
1471 srcs = [
1472 "test/leaky-relu.cc",
1473 "test/leaky-relu-operator-tester.h",
1474 ],
1475 deps = OPERATOR_TEST_DEPS,
1476)
1477
1478xnnpack_unit_test(
1479 name = "max_pooling_test",
1480 srcs = [
1481 "test/max-pooling.cc",
1482 "test/max-pooling-operator-tester.h",
1483 ] + OPERATOR_TEST_PARAMS_HDRS,
1484 deps = OPERATOR_TEST_DEPS,
1485)
1486
1487xnnpack_unit_test(
1488 name = "prelu_test",
1489 srcs = [
1490 "test/prelu.cc",
1491 "test/prelu-operator-tester.h",
1492 ] + OPERATOR_TEST_PARAMS_HDRS,
1493 deps = OPERATOR_TEST_DEPS,
1494)
1495
1496xnnpack_unit_test(
1497 name = "sigmoid_test",
1498 srcs = [
1499 "test/sigmoid.cc",
1500 "test/sigmoid-operator-tester.h",
1501 ],
1502 deps = OPERATOR_TEST_DEPS,
1503)
1504
1505xnnpack_unit_test(
1506 name = "softargmax_test",
1507 srcs = [
1508 "test/softargmax.cc",
1509 "test/softargmax-operator-tester.h",
1510 ],
1511 deps = OPERATOR_TEST_DEPS,
1512)
1513
1514xnnpack_unit_test(
1515 name = "unpooling_test",
1516 srcs = [
1517 "test/unpooling.cc",
1518 "test/unpooling-operator-tester.h",
1519 ],
1520 deps = OPERATOR_TEST_DEPS,
1521)
1522
1523############################# Build configurations #############################
1524
1525config_setting(
1526 name = "linux_k8",
1527 values = {
1528 "cpu": "k8",
1529 },
1530)
1531
1532config_setting(
Marat Dukhan4e45e662019-10-03 15:40:24 -07001533 name = "linux_aarch64",
1534 values = {
1535 "cpu": "aarch64",
1536 },
1537)
1538
1539config_setting(
Marat Dukhan08c4a432019-10-03 09:29:21 -07001540 name = "android",
1541 values = {"crosstool_top": "//external:android/crosstool"},
1542)
1543
1544config_setting(
1545 name = "android_armv7",
1546 values = {
1547 "crosstool_top": "//external:android/crosstool",
1548 "cpu": "armeabi-v7a",
1549 },
1550)
1551
1552config_setting(
1553 name = "android_arm64",
1554 values = {
1555 "crosstool_top": "//external:android/crosstool",
1556 "cpu": "arm64-v8a",
1557 },
1558)
1559
1560config_setting(
1561 name = "android_x86",
1562 values = {
1563 "crosstool_top": "//external:android/crosstool",
1564 "cpu": "x86",
1565 },
1566)
1567
1568config_setting(
1569 name = "android_x86_64",
1570 values = {
1571 "crosstool_top": "//external:android/crosstool",
1572 "cpu": "x86_64",
1573 },
1574)
1575
1576config_setting(
Marat Dukhan885ca242019-10-07 09:17:32 -07001577 name = "macos_x86_64",
1578 values = {
1579 "apple_platform_type": "macos",
1580 "cpu": "darwin",
1581 },
1582)
1583
1584config_setting(
Marat Dukhan08c4a432019-10-03 09:29:21 -07001585 name = "emscripten",
Marat Dukhan9d056a42019-10-03 12:13:35 -07001586 values = {"crosstool_top": "//toolchain/emscripten"},
Marat Dukhan08c4a432019-10-03 09:29:21 -07001587)
1588
1589config_setting(
1590 name = "emscripten_wasm",
1591 values = {
Marat Dukhan9d056a42019-10-03 12:13:35 -07001592 "crosstool_top": "//toolchain/emscripten",
Marat Dukhan08c4a432019-10-03 09:29:21 -07001593 "cpu": "wasm",
1594 },
1595)
1596
1597config_setting(
1598 name = "emscripten_wasmsimd",
1599 values = {
Marat Dukhan9d056a42019-10-03 12:13:35 -07001600 "crosstool_top": "//toolchain/emscripten",
Marat Dukhan08c4a432019-10-03 09:29:21 -07001601 "cpu": "wasm",
1602 "features": "wasmsimd",
1603 },
1604)
1605
1606config_setting(
1607 name = "emscripten_asmjs",
1608 values = {
Marat Dukhan9d056a42019-10-03 12:13:35 -07001609 "crosstool_top": "//toolchain/emscripten",
Marat Dukhan08c4a432019-10-03 09:29:21 -07001610 "cpu": "asmjs",
1611 },
1612)
1613
1614# Builds with -c opt
1615config_setting(
1616 name = "debug_build",
1617 values = {
1618 "compilation_mode": "dbg",
1619 },
Marat Dukhan08c4a432019-10-03 09:29:21 -07001620)
1621
1622# Builds with -c dbg
1623config_setting(
1624 name = "optimized_build",
1625 values = {
1626 "compilation_mode": "opt",
1627 },
Marat Dukhan08c4a432019-10-03 09:29:21 -07001628)
1629
1630# Enables usage of assembly kernels.
1631config_setting(
1632 name = "xnn_enable_assembly_explicit_true",
1633 define_values = {"xnn_enable_assembly": "true"},
1634)
1635
1636# Disables usage of assembly kernels.
1637config_setting(
1638 name = "xnn_enable_assembly_explicit_false",
1639 define_values = {"xnn_enable_assembly": "false"},
1640)