blob: cbe46b9820bc5ecbb3992fd54664e836269f632a [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
Marat Dukhancf056b22019-10-07 10:26:29 -0700704xnnpack_cc_library(
Marat Dukhan08c4a432019-10-03 09:29:21 -0700705 name = "operators",
706 srcs = OPERATOR_SRCS + [
707 "src/init.c",
708 "src/operator-delete.c",
Marat Dukhancf056b22019-10-07 10:26:29 -0700709 ],
710 hdrs = INTERNAL_HDRS + LOGGING_HDRS,
Marat Dukhanc8e00eb2019-10-04 14:55:26 -0700711 copts = xnnpack_std_copts() + LOGGING_COPTS + [
Marat Dukhan08c4a432019-10-03 09:29:21 -0700712 "-Isrc",
713 "-Iinclude",
714 ] + select({
715 ":debug_build": [],
716 "//conditions:default": xnnpack_min_size_copts(),
717 }),
Marat Dukhancf056b22019-10-07 10:26:29 -0700718 wasm_srcs = ["src/wasm-stubs.c"],
719 wasmsimd_srcs = ["src/wasm-stubs.c"],
Marat Dukhan08c4a432019-10-03 09:29:21 -0700720 deps = [
721 ":enable_assembly",
722 ":indirection",
723 ":ukernels",
724 "@FP16",
725 "@FXdiv",
726 "@clog",
Marat Dukhan08c4a432019-10-03 09:29:21 -0700727 "@pthreadpool",
Marat Dukhand343c222019-10-07 09:22:14 -0700728 ] + select({
729 ":emscripten": [],
730 "//conditions:default": ["@cpuinfo"],
731 }),
Marat Dukhan08c4a432019-10-03 09:29:21 -0700732)
733
734cc_library(
735 name = "XNNPACK",
736 hdrs = ["include/xnnpack.h"],
737 includes = ["include"],
738 linkstatic = True,
Marat Dukhan08c4a432019-10-03 09:29:21 -0700739 visibility = xnnpack_visibility(),
740 deps = [
741 ":operator_run",
742 ":operators",
743 "@pthreadpool",
744 ],
745)
746
Marat Dukhancf056b22019-10-07 10:26:29 -0700747xnnpack_cc_library(
Marat Dukhan08c4a432019-10-03 09:29:21 -0700748 name = "bench_utils",
749 srcs = ["bench/utils.cc"],
750 hdrs = ["bench/utils.h"],
751 copts = ["-Wno-unused-result"],
Marat Dukhan08c4a432019-10-03 09:29:21 -0700752 deps = ["@cpuinfo"],
753)
754
755######################### Unit tests for micro-kernels #########################
756
757xnnpack_benchmark(
758 name = "q8_gemm_bench",
759 srcs = [
760 "bench/gemm.h",
761 "bench/q8-gemm.cc",
762 "src/xnnpack/AlignedAllocator.h",
763 ] + WEIGHTS_PACK_HDRS + MICROKERNEL_BENCHMARK_HDRS,
764 copts = ["-Wno-unused-function"] + xnnpack_optional_ruy_copts() + xnnpack_optional_gemmlowp_copts(),
765 deps = MICROKERNEL_BENCHMARK_DEPS + xnnpack_optional_ruy_deps() + xnnpack_optional_gemmlowp_deps(),
766)
767
768xnnpack_benchmark(
769 name = "f16_gemm_bench",
770 srcs = [
771 "bench/f16-gemm.cc",
772 "bench/gemm.h",
773 "src/xnnpack/AlignedAllocator.h",
774 ] + WEIGHTS_PACK_HDRS + MICROKERNEL_BENCHMARK_HDRS,
775 copts = ["-Wno-unused-function"],
776 deps = MICROKERNEL_BENCHMARK_DEPS,
777)
778
779xnnpack_benchmark(
780 name = "f32_igemm_bench",
781 srcs = [
782 "bench/f32-igemm.cc",
783 "bench/conv.h",
784 "src/xnnpack/AlignedAllocator.h",
785 ] + MICROKERNEL_BENCHMARK_HDRS,
786 deps = MICROKERNEL_BENCHMARK_DEPS + [":indirection"],
787)
788
789xnnpack_benchmark(
790 name = "f32_conv_hwc_bench",
791 srcs = [
792 "bench/f32-conv-hwc.cc",
793 "bench/dconv.h",
794 "src/xnnpack/AlignedAllocator.h",
795 ] + WEIGHTS_PACK_HDRS + MICROKERNEL_BENCHMARK_HDRS,
796 copts = ["-Wno-unused-function"],
797 deps = MICROKERNEL_BENCHMARK_DEPS,
798)
799
800xnnpack_benchmark(
801 name = "f32_dwconv_bench",
802 srcs = [
803 "bench/f32-dwconv.cc",
804 "bench/dwconv.h",
805 "src/xnnpack/AlignedAllocator.h",
806 ] + MICROKERNEL_BENCHMARK_HDRS,
807 deps = MICROKERNEL_BENCHMARK_DEPS + [":indirection"],
808)
809
810xnnpack_benchmark(
811 name = "f32_dwconv_spchw_bench",
812 srcs = [
813 "bench/f32-dwconv-spchw.cc",
814 "bench/dwconv.h",
815 "src/xnnpack/AlignedAllocator.h",
816 ] + WEIGHTS_PACK_HDRS + MICROKERNEL_BENCHMARK_HDRS,
817 deps = MICROKERNEL_BENCHMARK_DEPS + [":indirection"],
818)
819
820xnnpack_benchmark(
821 name = "f32_gemm_bench",
822 srcs = [
823 "bench/f32-gemm.cc",
824 "bench/gemm.h",
825 "src/xnnpack/AlignedAllocator.h",
826 ] + WEIGHTS_PACK_HDRS + MICROKERNEL_BENCHMARK_HDRS,
827 copts = ["-Wno-unused-function"] + xnnpack_optional_ruy_copts(),
828 deps = MICROKERNEL_BENCHMARK_DEPS + xnnpack_optional_ruy_deps(),
829)
830
831xnnpack_benchmark(
832 name = "f32_rmax_bench",
833 srcs = [
834 "bench/f32-rmax.cc",
835 "src/xnnpack/AlignedAllocator.h",
836 ] + MICROKERNEL_BENCHMARK_HDRS,
837 deps = MICROKERNEL_BENCHMARK_DEPS,
838)
839
840xnnpack_benchmark(
841 name = "f32_spmm_bench",
842 srcs = [
843 "bench/f32-spmm.cc",
844 "bench/gemm.h",
845 "src/xnnpack/AlignedAllocator.h",
846 ] + MICROKERNEL_BENCHMARK_HDRS,
847 copts = ["-Wno-unused-function"],
848 deps = MICROKERNEL_BENCHMARK_DEPS,
849)
850
851xnnpack_benchmark(
852 name = "f32_im2col_gemm_bench",
853 srcs = [
854 "bench/f32-im2col-gemm.cc",
855 "bench/conv.h",
856 "src/xnnpack/AlignedAllocator.h",
857 ] + WEIGHTS_PACK_HDRS + MICROKERNEL_BENCHMARK_HDRS,
858 deps = MICROKERNEL_BENCHMARK_DEPS + [":im2col"],
859)
860
861########################### Benchmarks for operators ###########################
862
863xnnpack_benchmark(
864 name = "add_bench",
865 srcs = ["bench/add.cc"],
866 deps = OPERATOR_BENCHMARK_DEPS,
867)
868
869xnnpack_benchmark(
870 name = "average_pooling_bench",
871 srcs = ["bench/average-pooling.cc"],
872 deps = OPERATOR_BENCHMARK_DEPS,
873)
874
875xnnpack_benchmark(
876 name = "channel_shuffle_bench",
877 srcs = ["bench/channel-shuffle.cc"],
878 deps = OPERATOR_BENCHMARK_DEPS,
879)
880
881xnnpack_benchmark(
882 name = "convolution_bench",
883 srcs = ["bench/convolution.cc"],
884 copts = xnnpack_optional_tflite_copts() + xnnpack_optional_armcl_copts(),
885 deps = OPERATOR_BENCHMARK_DEPS + xnnpack_optional_tflite_deps() + xnnpack_optional_armcl_deps(),
886)
887
888xnnpack_benchmark(
889 name = "deconvolution_bench",
890 srcs = ["bench/deconvolution.cc"],
891 copts = xnnpack_optional_tflite_copts(),
892 deps = OPERATOR_BENCHMARK_DEPS + xnnpack_optional_tflite_deps(),
893)
894
895xnnpack_benchmark(
896 name = "global_average_pooling_bench",
897 srcs = ["bench/global-average-pooling.cc"],
898 deps = OPERATOR_BENCHMARK_DEPS,
899)
900
901xnnpack_benchmark(
902 name = "max_pooling_bench",
903 srcs = ["bench/max-pooling.cc"],
904 deps = OPERATOR_BENCHMARK_DEPS,
905)
906
907xnnpack_benchmark(
908 name = "sigmoid_bench",
909 srcs = ["bench/sigmoid.cc"],
910 deps = OPERATOR_BENCHMARK_DEPS,
911)
912
913xnnpack_benchmark(
914 name = "softargmax_bench",
915 srcs = ["bench/softargmax.cc"],
916 deps = OPERATOR_BENCHMARK_DEPS,
917)
918
Marat Dukhanc068bb62019-10-04 13:24:39 -0700919############################# End-to-end benchmarks ############################
920
921cc_library(
922 name = "mobilenet_v1",
923 srcs = ["models/mobilenet-v1.cc"],
924 hdrs = ["models/models.h"],
925 linkstatic = True,
926 deps = [
927 ":XNNPACK",
928 "@pthreadpool",
929 ],
930)
931
932cc_library(
933 name = "mobilenet_v2",
934 srcs = ["models/mobilenet-v2.cc"],
935 hdrs = ["models/models.h"],
936 linkstatic = True,
937 deps = [
938 ":XNNPACK",
939 "@pthreadpool",
940 ],
941)
942
943xnnpack_benchmark(
944 name = "end2end_bench",
945 srcs = ["bench/end2end.cc"],
946 deps = [
947 ":XNNPACK",
948 ":mobilenet_v1",
949 ":mobilenet_v2",
950 "@pthreadpool",
951 ],
952)
953
Marat Dukhan08c4a432019-10-03 09:29:21 -0700954######################### Unit tests for micro-kernels #########################
955
956xnnpack_unit_test(
957 name = "f16_gemm_test",
958 srcs = [
959 "test/f16-gemm.cc",
960 "test/gemm-microkernel-tester.h",
961 "src/xnnpack/AlignedAllocator.h",
962 ] + WEIGHTS_PACK_HDRS + MICROKERNEL_TEST_HDRS,
963 deps = MICROKERNEL_TEST_DEPS,
964)
965
966xnnpack_unit_test(
967 name = "f32_argmaxpool_test",
968 srcs = [
969 "test/f32-argmaxpool.cc",
970 "test/argmaxpool-microkernel-tester.h",
971 "src/xnnpack/AlignedAllocator.h",
972 ] + MICROKERNEL_TEST_HDRS,
973 deps = MICROKERNEL_TEST_DEPS,
974)
975
976xnnpack_unit_test(
977 name = "f32_avgpool_test",
978 srcs = [
979 "test/f32-avgpool.cc",
980 "test/avgpool-microkernel-tester.h",
981 "src/xnnpack/AlignedAllocator.h",
982 ] + MICROKERNEL_TEST_HDRS,
983 deps = MICROKERNEL_TEST_DEPS,
984)
985
986xnnpack_unit_test(
987 name = "f32_clamp_test",
988 srcs = [
989 "test/f32-clamp.cc",
990 "test/clamp-microkernel-tester.h",
991 ] + MICROKERNEL_TEST_HDRS,
992 deps = MICROKERNEL_TEST_DEPS,
993)
994
995xnnpack_unit_test(
996 name = "f32_igemm_test",
997 srcs = [
998 "test/f32-igemm.cc",
999 "test/gemm-microkernel-tester.h",
1000 "src/xnnpack/AlignedAllocator.h",
1001 ] + WEIGHTS_PACK_HDRS + MICROKERNEL_TEST_HDRS,
1002 deps = MICROKERNEL_TEST_DEPS,
1003)
1004
1005xnnpack_unit_test(
1006 name = "f32_conv_hwc_test",
1007 srcs = [
1008 "test/f32-conv-hwc.cc",
1009 "test/conv-hwc-microkernel-tester.h",
1010 "src/xnnpack/AlignedAllocator.h",
1011 ] + WEIGHTS_PACK_HDRS + MICROKERNEL_TEST_HDRS,
1012 deps = MICROKERNEL_TEST_DEPS,
1013)
1014
1015xnnpack_unit_test(
1016 name = "f32_conv_hwc2spchw_test",
1017 srcs = [
1018 "test/f32-conv-hwc2spchw.cc",
1019 "test/conv-hwc2spchw-microkernel-tester.h",
1020 "src/xnnpack/AlignedAllocator.h",
1021 ] + WEIGHTS_PACK_HDRS + MICROKERNEL_TEST_HDRS,
1022 deps = MICROKERNEL_TEST_DEPS,
1023)
1024
1025xnnpack_unit_test(
1026 name = "f32_dwconv_test",
1027 srcs = [
1028 "test/f32-dwconv.cc",
1029 "test/dwconv-microkernel-tester.h",
1030 "src/xnnpack/AlignedAllocator.h",
1031 ] + WEIGHTS_PACK_HDRS + MICROKERNEL_TEST_HDRS,
1032 deps = MICROKERNEL_TEST_DEPS,
1033)
1034
1035xnnpack_unit_test(
1036 name = "f32_dwconv_spchw_test",
1037 srcs = [
1038 "test/f32-dwconv-spchw.cc",
1039 "test/dwconv-spchw-microkernel-tester.h",
1040 "src/xnnpack/AlignedAllocator.h",
1041 ] + WEIGHTS_PACK_HDRS + MICROKERNEL_TEST_HDRS,
1042 deps = MICROKERNEL_TEST_DEPS,
1043)
1044
1045xnnpack_unit_test(
1046 name = "f32_gavgpool_test",
1047 srcs = [
1048 "test/f32-gavgpool.cc",
1049 "test/gavgpool-microkernel-tester.h",
1050 "src/xnnpack/AlignedAllocator.h",
1051 ] + MICROKERNEL_TEST_HDRS,
1052 deps = MICROKERNEL_TEST_DEPS,
1053)
1054
1055xnnpack_unit_test(
1056 name = "f32_gavgpool_spchw_test",
1057 srcs = [
1058 "test/f32-gavgpool-spchw.cc",
1059 "test/gavgpool-spchw-microkernel-tester.h",
1060 "src/xnnpack/AlignedAllocator.h",
1061 ] + MICROKERNEL_TEST_HDRS,
1062 deps = MICROKERNEL_TEST_DEPS,
1063)
1064
1065xnnpack_unit_test(
1066 name = "f32_gemm_test",
1067 srcs = [
1068 "test/f32-gemm.cc",
1069 "test/gemm-microkernel-tester.h",
1070 "src/xnnpack/AlignedAllocator.h",
1071 ] + WEIGHTS_PACK_HDRS + MICROKERNEL_TEST_HDRS,
1072 deps = MICROKERNEL_TEST_DEPS,
1073)
1074
1075xnnpack_unit_test(
1076 name = "f32_gemminc_test",
1077 srcs = [
1078 "test/f32-gemminc.cc",
1079 "test/gemm-microkernel-tester.h",
1080 "src/xnnpack/AlignedAllocator.h",
1081 ] + WEIGHTS_PACK_HDRS + MICROKERNEL_TEST_HDRS,
1082 deps = MICROKERNEL_TEST_DEPS,
1083)
1084
1085xnnpack_unit_test(
1086 name = "f32_hswish_test",
1087 srcs = [
1088 "test/f32-hswish.cc",
1089 "test/hswish-microkernel-tester.h",
1090 ] + MICROKERNEL_TEST_HDRS,
1091 deps = MICROKERNEL_TEST_DEPS,
1092)
1093
1094xnnpack_unit_test(
1095 name = "f32_maxpool_test",
1096 srcs = [
1097 "test/f32-maxpool.cc",
1098 "test/maxpool-microkernel-tester.h",
1099 ] + MICROKERNEL_TEST_HDRS,
1100 deps = MICROKERNEL_TEST_DEPS,
1101)
1102
1103xnnpack_unit_test(
1104 name = "f32_pavgpool_test",
1105 srcs = [
1106 "test/f32-pavgpool.cc",
1107 "test/avgpool-microkernel-tester.h",
1108 "src/xnnpack/AlignedAllocator.h",
1109 ] + MICROKERNEL_TEST_HDRS,
1110 deps = MICROKERNEL_TEST_DEPS,
1111)
1112
1113xnnpack_unit_test(
1114 name = "f32_ppmm_test",
1115 srcs = [
1116 "test/f32-ppmm.cc",
1117 "test/gemm-microkernel-tester.h",
1118 "src/xnnpack/AlignedAllocator.h",
1119 ] + WEIGHTS_PACK_HDRS + MICROKERNEL_TEST_HDRS,
1120 deps = MICROKERNEL_TEST_DEPS,
1121)
1122
1123xnnpack_unit_test(
1124 name = "f32_prelu_test",
1125 srcs = [
1126 "test/f32-prelu.cc",
1127 "test/prelu-microkernel-tester.h",
1128 "src/xnnpack/AlignedAllocator.h",
1129 ] + MICROKERNEL_TEST_HDRS,
1130 deps = MICROKERNEL_TEST_DEPS,
1131)
1132
1133xnnpack_unit_test(
1134 name = "f32_rmax_test",
1135 srcs = [
1136 "test/f32-rmax.cc",
1137 "test/rmax-microkernel-tester.h",
1138 ] + MICROKERNEL_TEST_HDRS,
1139 deps = MICROKERNEL_TEST_DEPS,
1140)
1141
1142xnnpack_unit_test(
1143 name = "f32_spmm_test",
1144 srcs = [
1145 "test/f32-spmm.cc",
1146 "test/spmm-microkernel-tester.h",
1147 "src/xnnpack/AlignedAllocator.h",
1148 ] + MICROKERNEL_TEST_HDRS,
1149 deps = MICROKERNEL_TEST_DEPS,
1150)
1151
1152xnnpack_unit_test(
1153 name = "f32_vadd_test",
1154 srcs = [
1155 "test/f32-vadd.cc",
1156 "test/vadd-microkernel-tester.h",
1157 ] + MICROKERNEL_TEST_HDRS,
1158 deps = MICROKERNEL_TEST_DEPS,
1159)
1160
1161xnnpack_unit_test(
1162 name = "f32_vsub_test",
1163 srcs = [
1164 "test/f32-vsub.cc",
1165 "test/vsub-microkernel-tester.h",
1166 ] + MICROKERNEL_TEST_HDRS,
1167 deps = MICROKERNEL_TEST_DEPS,
1168)
1169
1170xnnpack_unit_test(
1171 name = "f32_vmul_test",
1172 srcs = [
1173 "test/f32-vmul.cc",
1174 "test/vmul-microkernel-tester.h",
1175 ] + MICROKERNEL_TEST_HDRS,
1176 deps = MICROKERNEL_TEST_DEPS,
1177)
1178
1179xnnpack_unit_test(
1180 name = "f32_vmulcaddc_test",
1181 srcs = [
1182 "test/f32-vmulcaddc.cc",
1183 "test/vmulcaddc-microkernel-tester.h",
1184 "src/xnnpack/AlignedAllocator.h",
1185 ] + WEIGHTS_PACK_HDRS + MICROKERNEL_TEST_HDRS,
1186 deps = MICROKERNEL_TEST_DEPS,
1187)
1188
1189xnnpack_unit_test(
1190 name = "q8_avgpool_test",
1191 srcs = [
1192 "test/q8-avgpool.cc",
1193 "test/avgpool-microkernel-tester.h",
1194 "src/xnnpack/AlignedAllocator.h",
1195 ] + MICROKERNEL_TEST_HDRS,
1196 deps = MICROKERNEL_TEST_DEPS,
1197)
1198
1199xnnpack_unit_test(
1200 name = "q8_igemm_test",
1201 srcs = [
1202 "test/q8-igemm.cc",
1203 "test/gemm-microkernel-tester.h",
1204 "src/xnnpack/AlignedAllocator.h",
1205 ] + WEIGHTS_PACK_HDRS + MICROKERNEL_TEST_HDRS,
1206 deps = MICROKERNEL_TEST_DEPS,
1207)
1208
1209xnnpack_unit_test(
1210 name = "q8_dwconv_test",
1211 srcs = [
1212 "test/q8-dwconv.cc",
1213 "test/dwconv-microkernel-tester.h",
1214 "src/xnnpack/AlignedAllocator.h",
1215 ] + WEIGHTS_PACK_HDRS + MICROKERNEL_TEST_HDRS,
1216 deps = MICROKERNEL_TEST_DEPS,
1217)
1218
1219xnnpack_unit_test(
1220 name = "q8_gavgpool_test",
1221 srcs = [
1222 "test/q8-gavgpool.cc",
1223 "test/gavgpool-microkernel-tester.h",
1224 "src/xnnpack/AlignedAllocator.h",
1225 ] + MICROKERNEL_TEST_HDRS,
1226 deps = MICROKERNEL_TEST_DEPS,
1227)
1228
1229xnnpack_unit_test(
1230 name = "q8_gemm_test",
1231 srcs = [
1232 "test/q8-gemm.cc",
1233 "test/gemm-microkernel-tester.h",
1234 "src/xnnpack/AlignedAllocator.h",
1235 ] + WEIGHTS_PACK_HDRS + MICROKERNEL_TEST_HDRS,
1236 deps = MICROKERNEL_TEST_DEPS,
1237)
1238
1239xnnpack_unit_test(
1240 name = "q8_vadd_test",
1241 srcs = [
1242 "test/q8-vadd.cc",
1243 "test/vadd-microkernel-tester.h",
1244 ] + MICROKERNEL_TEST_HDRS,
1245 deps = MICROKERNEL_TEST_DEPS,
1246)
1247
1248xnnpack_unit_test(
1249 name = "u8_clamp_test",
1250 srcs = [
1251 "test/u8-clamp.cc",
1252 "test/clamp-microkernel-tester.h",
1253 ] + MICROKERNEL_TEST_HDRS,
1254 deps = MICROKERNEL_TEST_DEPS,
1255)
1256
1257xnnpack_unit_test(
1258 name = "u8_lut32norm_test",
1259 srcs = [
1260 "test/u8-lut32norm.cc",
1261 "test/lut-norm-microkernel-tester.h",
1262 ] + MICROKERNEL_TEST_HDRS,
1263 deps = MICROKERNEL_TEST_DEPS,
1264)
1265
1266xnnpack_unit_test(
1267 name = "u8_maxpool_test",
1268 srcs = [
1269 "test/u8-maxpool.cc",
1270 "test/maxpool-microkernel-tester.h",
1271 ] + MICROKERNEL_TEST_HDRS,
1272 deps = MICROKERNEL_TEST_DEPS,
1273)
1274
1275xnnpack_unit_test(
1276 name = "u8_rmax_test",
1277 srcs = [
1278 "test/u8-rmax.cc",
1279 "test/rmax-microkernel-tester.h",
1280 ] + MICROKERNEL_TEST_HDRS,
1281 deps = MICROKERNEL_TEST_DEPS,
1282)
1283
1284xnnpack_unit_test(
1285 name = "x32_packx_test",
1286 srcs = [
1287 "test/x32-packx.cc",
1288 "test/pack-microkernel-tester.h",
1289 "src/xnnpack/AlignedAllocator.h",
1290 ] + MICROKERNEL_TEST_HDRS,
1291 deps = MICROKERNEL_TEST_DEPS,
1292)
1293
1294xnnpack_unit_test(
1295 name = "x32_pad_test",
1296 srcs = [
1297 "test/x32-pad.cc",
1298 "test/pad-microkernel-tester.h",
1299 ] + MICROKERNEL_TEST_HDRS,
1300 deps = MICROKERNEL_TEST_DEPS,
1301)
1302
1303xnnpack_unit_test(
1304 name = "x32_unpool_test",
1305 srcs = [
1306 "test/x32-unpool.cc",
1307 "test/unpool-microkernel-tester.h",
1308 ] + MICROKERNEL_TEST_HDRS,
1309 deps = MICROKERNEL_TEST_DEPS,
1310)
1311
1312xnnpack_unit_test(
1313 name = "x32_zip_test",
1314 srcs = [
1315 "test/x32-zip.cc",
1316 "test/zip-microkernel-tester.h",
1317 ] + MICROKERNEL_TEST_HDRS,
1318 deps = MICROKERNEL_TEST_DEPS,
1319)
1320
1321xnnpack_unit_test(
1322 name = "x8_lut_test",
1323 srcs = [
1324 "test/x8-lut.cc",
1325 "test/lut-microkernel-tester.h",
1326 ] + MICROKERNEL_TEST_HDRS,
1327 deps = MICROKERNEL_TEST_DEPS,
1328)
1329
1330xnnpack_unit_test(
1331 name = "x8_zip_test",
1332 srcs = [
1333 "test/x8-zip.cc",
1334 "test/zip-microkernel-tester.h",
1335 ] + MICROKERNEL_TEST_HDRS,
1336 deps = MICROKERNEL_TEST_DEPS,
1337)
1338
1339########################### Size test for the library ##########################
1340
1341xnnpack_binary(
1342 name = "size_test",
1343 srcs = ["test/size.c"],
1344 deps = [":XNNPACK"],
1345)
1346
1347########################### Unit tests for operators ###########################
1348
1349xnnpack_unit_test(
1350 name = "add_test",
1351 srcs = [
1352 "test/add.cc",
1353 "test/add-operator-tester.h",
1354 ],
1355 deps = OPERATOR_TEST_DEPS,
1356)
1357
1358xnnpack_unit_test(
1359 name = "argmax_pooling_test",
1360 srcs = [
1361 "test/argmax-pooling.cc",
1362 "test/argmax-pooling-operator-tester.h",
1363 ] + OPERATOR_TEST_PARAMS_HDRS,
1364 deps = OPERATOR_TEST_DEPS,
1365)
1366
1367xnnpack_unit_test(
1368 name = "average_pooling_test",
1369 srcs = [
1370 "test/average-pooling.cc",
1371 "test/average-pooling-operator-tester.h",
1372 ] + OPERATOR_TEST_PARAMS_HDRS,
1373 deps = OPERATOR_TEST_DEPS,
1374)
1375
1376xnnpack_unit_test(
1377 name = "channel_pad_test",
1378 srcs = [
1379 "test/channel-pad.cc",
1380 "test/channel-pad-operator-tester.h",
1381 ] + OPERATOR_TEST_PARAMS_HDRS,
1382 deps = OPERATOR_TEST_DEPS,
1383)
1384
1385xnnpack_unit_test(
1386 name = "channel_shuffle_test",
1387 srcs = [
1388 "test/channel-shuffle.cc",
1389 "test/channel-shuffle-operator-tester.h",
1390 ],
1391 deps = OPERATOR_TEST_DEPS,
1392)
1393
1394xnnpack_unit_test(
1395 name = "clamp_test",
1396 srcs = [
1397 "test/clamp.cc",
1398 "test/clamp-operator-tester.h",
1399 ],
1400 deps = OPERATOR_TEST_DEPS,
1401)
1402
1403xnnpack_unit_test(
1404 name = "convolution_test",
1405 srcs = [
1406 "test/convolution.cc",
1407 "test/convolution-operator-tester.h",
1408 ],
1409 deps = OPERATOR_TEST_DEPS,
1410)
1411
1412xnnpack_unit_test(
1413 name = "convolution_spnchw_test",
1414 srcs = [
1415 "test/convolution-spnchw.cc",
1416 "test/convolution-spnchw-operator-tester.h",
1417 ],
1418 deps = OPERATOR_TEST_DEPS,
1419)
1420
1421xnnpack_unit_test(
1422 name = "deconvolution_test",
1423 srcs = [
1424 "test/deconvolution.cc",
1425 "test/deconvolution-operator-tester.h",
1426 ] + OPERATOR_TEST_PARAMS_HDRS,
1427 deps = OPERATOR_TEST_DEPS,
1428)
1429
1430xnnpack_unit_test(
1431 name = "fully_connected_test",
1432 srcs = [
1433 "test/fully-connected.cc",
1434 "test/fully-connected-operator-tester.h",
1435 ],
1436 deps = OPERATOR_TEST_DEPS,
1437)
1438
1439xnnpack_unit_test(
1440 name = "global_average_pooling_test",
1441 srcs = [
1442 "test/global-average-pooling.cc",
1443 "test/global-average-pooling-operator-tester.h",
1444 ] + OPERATOR_TEST_PARAMS_HDRS,
1445 deps = OPERATOR_TEST_DEPS,
1446)
1447
1448xnnpack_unit_test(
1449 name = "global_average_pooling_spnchw_test",
1450 srcs = [
1451 "test/global-average-pooling-spnchw.cc",
1452 "test/global-average-pooling-spnchw-operator-tester.h",
1453 ],
1454 deps = OPERATOR_TEST_DEPS,
1455)
1456
1457xnnpack_unit_test(
1458 name = "hardswish_test",
1459 srcs = [
1460 "test/hardswish.cc",
1461 "test/hardswish-operator-tester.h",
1462 ],
1463 deps = OPERATOR_TEST_DEPS,
1464)
1465
1466xnnpack_unit_test(
1467 name = "leaky_relu_test",
1468 srcs = [
1469 "test/leaky-relu.cc",
1470 "test/leaky-relu-operator-tester.h",
1471 ],
1472 deps = OPERATOR_TEST_DEPS,
1473)
1474
1475xnnpack_unit_test(
1476 name = "max_pooling_test",
1477 srcs = [
1478 "test/max-pooling.cc",
1479 "test/max-pooling-operator-tester.h",
1480 ] + OPERATOR_TEST_PARAMS_HDRS,
1481 deps = OPERATOR_TEST_DEPS,
1482)
1483
1484xnnpack_unit_test(
1485 name = "prelu_test",
1486 srcs = [
1487 "test/prelu.cc",
1488 "test/prelu-operator-tester.h",
1489 ] + OPERATOR_TEST_PARAMS_HDRS,
1490 deps = OPERATOR_TEST_DEPS,
1491)
1492
1493xnnpack_unit_test(
1494 name = "sigmoid_test",
1495 srcs = [
1496 "test/sigmoid.cc",
1497 "test/sigmoid-operator-tester.h",
1498 ],
1499 deps = OPERATOR_TEST_DEPS,
1500)
1501
1502xnnpack_unit_test(
1503 name = "softargmax_test",
1504 srcs = [
1505 "test/softargmax.cc",
1506 "test/softargmax-operator-tester.h",
1507 ],
1508 deps = OPERATOR_TEST_DEPS,
1509)
1510
1511xnnpack_unit_test(
1512 name = "unpooling_test",
1513 srcs = [
1514 "test/unpooling.cc",
1515 "test/unpooling-operator-tester.h",
1516 ],
1517 deps = OPERATOR_TEST_DEPS,
1518)
1519
1520############################# Build configurations #############################
1521
1522config_setting(
1523 name = "linux_k8",
1524 values = {
1525 "cpu": "k8",
1526 },
1527)
1528
1529config_setting(
Marat Dukhan4e45e662019-10-03 15:40:24 -07001530 name = "linux_aarch64",
1531 values = {
1532 "cpu": "aarch64",
1533 },
1534)
1535
1536config_setting(
Marat Dukhan08c4a432019-10-03 09:29:21 -07001537 name = "android",
1538 values = {"crosstool_top": "//external:android/crosstool"},
1539)
1540
1541config_setting(
1542 name = "android_armv7",
1543 values = {
1544 "crosstool_top": "//external:android/crosstool",
1545 "cpu": "armeabi-v7a",
1546 },
1547)
1548
1549config_setting(
1550 name = "android_arm64",
1551 values = {
1552 "crosstool_top": "//external:android/crosstool",
1553 "cpu": "arm64-v8a",
1554 },
1555)
1556
1557config_setting(
1558 name = "android_x86",
1559 values = {
1560 "crosstool_top": "//external:android/crosstool",
1561 "cpu": "x86",
1562 },
1563)
1564
1565config_setting(
1566 name = "android_x86_64",
1567 values = {
1568 "crosstool_top": "//external:android/crosstool",
1569 "cpu": "x86_64",
1570 },
1571)
1572
1573config_setting(
Marat Dukhan885ca242019-10-07 09:17:32 -07001574 name = "macos_x86_64",
1575 values = {
1576 "apple_platform_type": "macos",
1577 "cpu": "darwin",
1578 },
1579)
1580
1581config_setting(
Marat Dukhan08c4a432019-10-03 09:29:21 -07001582 name = "emscripten",
Marat Dukhan1a729ec2019-10-07 09:31:44 -07001583 values = {"crosstool_top": "//toolchain:emscripten"},
Marat Dukhan08c4a432019-10-03 09:29:21 -07001584)
1585
1586config_setting(
1587 name = "emscripten_wasm",
1588 values = {
Marat Dukhan1a729ec2019-10-07 09:31:44 -07001589 "crosstool_top": "//toolchain:emscripten",
Marat Dukhan08c4a432019-10-03 09:29:21 -07001590 "cpu": "wasm",
1591 },
1592)
1593
1594config_setting(
1595 name = "emscripten_wasmsimd",
1596 values = {
Marat Dukhan1a729ec2019-10-07 09:31:44 -07001597 "crosstool_top": "//toolchain:emscripten",
Marat Dukhan08c4a432019-10-03 09:29:21 -07001598 "cpu": "wasm",
1599 "features": "wasmsimd",
1600 },
1601)
1602
1603config_setting(
1604 name = "emscripten_asmjs",
1605 values = {
Marat Dukhan1a729ec2019-10-07 09:31:44 -07001606 "crosstool_top": "//toolchain:emscripten",
Marat Dukhan08c4a432019-10-03 09:29:21 -07001607 "cpu": "asmjs",
1608 },
1609)
1610
1611# Builds with -c opt
1612config_setting(
1613 name = "debug_build",
1614 values = {
1615 "compilation_mode": "dbg",
1616 },
Marat Dukhan08c4a432019-10-03 09:29:21 -07001617)
1618
1619# Builds with -c dbg
1620config_setting(
1621 name = "optimized_build",
1622 values = {
1623 "compilation_mode": "opt",
1624 },
Marat Dukhan08c4a432019-10-03 09:29:21 -07001625)
1626
1627# Enables usage of assembly kernels.
1628config_setting(
1629 name = "xnn_enable_assembly_explicit_true",
1630 define_values = {"xnn_enable_assembly": "true"},
1631)
1632
1633# Disables usage of assembly kernels.
1634config_setting(
1635 name = "xnn_enable_assembly_explicit_false",
1636 define_values = {"xnn_enable_assembly": "false"},
1637)