-
Notifications
You must be signed in to change notification settings - Fork 371
/
CMakeLists.txt
1974 lines (1880 loc) · 85.2 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.
#
# Copyright 2019 Google LLC
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
CMAKE_MINIMUM_REQUIRED(VERSION 3.15 FATAL_ERROR)
# Allow specifying -D<PackageName>_ROOT.
CMAKE_POLICY(SET CMP0074 NEW)
# MSVC runtime library flags are selected by an abstraction.
CMAKE_POLICY(SET CMP0091 NEW)
# ---[ Project and semantic versioning.
PROJECT(XNNPACK C CXX ASM)
# --[ Use ccache if available
FIND_PROGRAM(CCACHE_BINARY "ccache")
IF(CCACHE_BINARY)
MESSAGE(STATUS "Using ccache: ${CCACHE_BINARY}")
SET(CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_BINARY}" CACHE STRING "CXX compiler launcher" FORCE)
SET(CMAKE_C_COMPILER_LAUNCHER "${CCACHE_BINARY}" CACHE STRING "C compiler launcher" FORCE)
IF(CMAKE_C_COMPILER_ID STREQUAL "MSVC")
STRING(REPLACE "/Zi" "/Z7" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
STRING(REPLACE "/Zi" "/Z7" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
STRING(REPLACE "/Zi" "/Z7" CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}")
STRING(REPLACE "/Zi" "/Z7" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
STRING(REPLACE "/Zi" "/Z7" CMAKE_C_FLAGS_DEBUG_INIT "${CMAKE_C_FLAGS_DEBU_INITG}")
STRING(REPLACE "/Zi" "/Z7" CMAKE_CXX_FLAGS_DEBUG_INIT "${CMAKE_CXX_FLAGS_DEBUG_INIT}")
STRING(REPLACE "/Zi" "/Z7" CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "${CMAKE_C_FLAGS_RELWITHDEBINFO_INIT}")
STRING(REPLACE "/Zi" "/Z7" CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "${CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT}")
ENDIF()
ENDIF()
SET(CMAKE_C_STANDARD 99)
SET(CMAKE_C_EXTENSIONS NO)
SET(CMAKE_CXX_STANDARD 14)
SET(CMAKE_CXX_STANDARD_REQUIRED YES)
SET(CMAKE_CXX_EXTENSIONS NO)
# ---[ Options.
SET(XNNPACK_LIBRARY_TYPE "default" CACHE STRING "Type of library (shared, static, or default) to build")
SET_PROPERTY(CACHE XNNPACK_LIBRARY_TYPE PROPERTY STRINGS default static shared)
OPTION(XNNPACK_ENABLE_ASSEMBLY "Build XNNPACK with assembly micro-kernels" ON)
OPTION(XNNPACK_ENABLE_MEMOPT "Build XNNPACK with optimized memory allocation scheme" ON)
OPTION(XNNPACK_ENABLE_SPARSE "Build XNNPACK with graph rewriting for sparse inference" ON)
OPTION(XNNPACK_ENABLE_GEMM_M_SPECIALIZATION "Build XNNPACK with support for selecting microkernel with different MR" ON)
OPTION(XNNPACK_ENABLE_DWCONV_MULTIPASS "Build XNNPACK with DWCONV multipass microkernels enabled" OFF)
OPTION(XNNPACK_BUILD_LIBRARY "Build XNNPACK library" ON)
OPTION(XNNPACK_BUILD_TESTS "Build XNNPACK unit tests" ON)
OPTION(XNNPACK_BUILD_ALL_MICROKERNELS "Builds all XNNPACK Microkernels" ON)
OPTION(XNNPACK_BUILD_BENCHMARKS "Build XNNPACK benchmarks" ON)
OPTION(XNNPACK_USE_SYSTEM_LIBS "Use system-provided dependency libraries" OFF)
OPTION(USE_GNU_SOURCE "Use _GNU_SOURCE macro" OFF)
IF(XNNPACK_BUILD_BENCHMARKS OR XNNPACK_BUILD_TESTS)
SET(XNNPACK_BUILD_ALL_MICROKERNELS ON)
ENDIF()
# --- [ Determine target processor
IF(CMAKE_OSX_ARCHITECTURES)
LIST(LENGTH CMAKE_OSX_ARCHITECTURES CMAKE_OSX_ARCHITECTURES_COUNT)
IF(CMAKE_OSX_ARCHITECTURES_COUNT GREATER 1)
MESSAGE(FATAL_ERROR "Unsupported XNNPACK build with multiple OSX architectures (${CMAKE_OSX_ARCHITECTURES}). "
"Specify a single architecture in CMAKE_OSX_ARCHITECTURES and re-configure. ")
ENDIF()
IF(NOT CMAKE_OSX_ARCHITECTURES MATCHES "^(x86_64|arm64|arm64e|arm64_32)$")
MESSAGE(FATAL_ERROR "Unrecognized CMAKE_OSX_ARCHITECTURES value \"${CMAKE_OSX_ARCHITECTURES}\"")
ENDIF()
SET(XNNPACK_TARGET_PROCESSOR "${CMAKE_OSX_ARCHITECTURES}")
ADD_COMPILE_OPTIONS("-Wno-shorten-64-to-32")
ELSEIF(CMAKE_GENERATOR MATCHES "^Visual Studio " AND CMAKE_GENERATOR_PLATFORM)
IF(CMAKE_GENERATOR_PLATFORM STREQUAL "Win32")
SET(XNNPACK_TARGET_PROCESSOR "x86")
ELSEIF(CMAKE_GENERATOR_PLATFORM STREQUAL "x64")
SET(XNNPACK_TARGET_PROCESSOR "x86_64")
ELSEIF(CMAKE_GENERATOR_PLATFORM STREQUAL "ARM64")
SET(XNNPACK_TARGET_PROCESSOR "arm64")
ELSEIF(CMAKE_GENERATOR_PLATFORM STREQUAL "ARM64EC")
SET(XNNPACK_TARGET_PROCESSOR "arm64")
ELSE()
MESSAGE(FATAL_ERROR "Unsupported Visual Studio architecture \"${CMAKE_GENERATOR_PLATFORM}\"")
ENDIF()
ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^i[3-7]86$")
SET(XNNPACK_TARGET_PROCESSOR "x86")
ELSEIF(CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64")
SET(XNNPACK_TARGET_PROCESSOR "x86_64")
ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^armv[5-8]")
SET(XNNPACK_TARGET_PROCESSOR "arm")
ELSEIF(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
SET(XNNPACK_TARGET_PROCESSOR "arm64")
ELSEIF(CMAKE_SYSTEM_PROCESSOR STREQUAL "ppc64le")
SET(XNNPACK_TARGET_PROCESSOR "ppc64")
ELSEIF(NOT XNNPACK_TARGET_PROCESSOR MATCHES "^(x86(_64)?|arm64|riscv(32|64|128)|Hexagon|ppc64)$")
SET(XNNPACK_TARGET_PROCESSOR "${CMAKE_SYSTEM_PROCESSOR}")
ELSE()
MESSAGE(FATAL_ERROR "Unrecognized CMAKE_SYSTEM_PROCESSOR value \"${CMAKE_SYSTEM_PROCESSOR}\"")
ENDIF()
MESSAGE(STATUS "Building for XNNPACK_TARGET_PROCESSOR: ${XNNPACK_TARGET_PROCESSOR}")
# --- [ Processor-specific options
OPTION(XNNPACK_ENABLE_ARM_FP16_SCALAR "Build XNNPACK with ARM FP16 (FP16 data processing) scalar micro-kernels" ON)
OPTION(XNNPACK_ENABLE_ARM_FP16_VECTOR "Build XNNPACK with ARM FP16 (FP16 data processing) vector micro-kernels" ON)
OPTION(XNNPACK_ENABLE_ARM_BF16 "Build XNNPACK with ARM BF16 (BFLOAT16) micro-kernels" ON)
OPTION(XNNPACK_ENABLE_ARM_DOTPROD "Build XNNPACK with ARM DotProd (integer dot product) micro-kernels" ON)
OPTION(XNNPACK_ENABLE_ARM_I8MM "Build XNNPACK with ARM I8MM (8-bit integer matrix multiply accumulate) micro-kernels" ON)
OPTION(XNNPACK_ENABLE_ARM_SME "Build XNNPACK with ARM SME micro-kernels" ON)
OPTION(XNNPACK_ENABLE_ARM_SME2 "Build XNNPACK with ARM SME2 micro-kernels" ON)
IF(NOT XNNPACK_TARGET_PROCESSOR MATCHES "arm(64)?")
SET(XNNPACK_ENABLE_ARM_FP16_SCALAR OFF)
SET(XNNPACK_ENABLE_ARM_FP16_VECTOR OFF)
SET(XNNPACK_ENABLE_ARM_BF16 OFF)
SET(XNNPACK_ENABLE_ARM_DOTPROD OFF)
ENDIF()
IF(NOT XNNPACK_TARGET_PROCESSOR STREQUAL "arm64")
SET(XNNPACK_ENABLE_ARM_I8MM OFF)
SET(XNNPACK_ENABLE_ARM_SME OFF)
SET(XNNPACK_ENABLE_ARM_SME2 OFF)
ELSEIF(CMAKE_C_COMPILER_ID STREQUAL "Clang" AND CMAKE_C_COMPILER_VERSION VERSION_LESS "11")
SET(XNNPACK_ENABLE_ARM_I8MM OFF)
SET(XNNPACK_ENABLE_ARM_SME OFF)
SET(XNNPACK_ENABLE_ARM_SME2 OFF)
ELSEIF(CMAKE_C_COMPILER_ID STREQUAL "Clang" AND CMAKE_C_COMPILER_VERSION VERSION_LESS "18")
SET(XNNPACK_ENABLE_ARM_SME OFF)
SET(XNNPACK_ENABLE_ARM_SME2 OFF)
ENDIF()
OPTION(XNNPACK_ENABLE_RISCV_VECTOR "Build XNNPACK with RISC-V Vector micro-kernels" ON)
OPTION(XNNPACK_ENABLE_VSX "Build XNNPACK with VSX Vector micro-kernels for Power" ON)
OPTION(XNNPACK_ENABLE_AVXVNNI "Build XNNPACK with AVX-VNNI micro-kernels" ON)
IF(CMAKE_C_COMPILER_ID STREQUAL "GNU")
IF(CMAKE_C_COMPILER_VERSION VERSION_LESS "11")
SET(XNNPACK_ENABLE_AVXVNNI OFF)
ENDIF()
ELSEIF(CMAKE_C_COMPILER_ID STREQUAL "Clang")
IF(CMAKE_C_COMPILER_VERSION VERSION_LESS "15")
SET(XNNPACK_ENABLE_AVXVNNI OFF)
ENDIF()
ENDIF()
OPTION(XNNPACK_ENABLE_AVXVNNIINT8 "Build XNNPACK with AVX-VNNI-INT8 micro-kernels" ON)
IF(CMAKE_SYSTEM_NAME MATCHES "^(Android|Darwin|iOS)$")
SET(XNNPACK_ENABLE_AVXVNNIINT8 OFF)
ENDIF()
IF(CMAKE_C_COMPILER_ID STREQUAL "GNU")
IF(CMAKE_C_COMPILER_VERSION VERSION_LESS "17")
SET(XNNPACK_ENABLE_AVXVNNIINT8 OFF)
ENDIF()
ELSEIF(CMAKE_C_COMPILER_ID STREQUAL "Clang")
IF(CMAKE_C_COMPILER_VERSION VERSION_LESS "17")
SET(XNNPACK_ENABLE_AVXVNNIINT8 OFF)
ENDIF()
ENDIF()
OPTION(XNNPACK_ENABLE_AVX256SKX "Build XNNPACK with AVX256SKX micro-kernels" ON)
IF(CMAKE_C_COMPILER_ID STREQUAL "GNU")
IF(CMAKE_C_COMPILER_VERSION VERSION_LESS "11")
SET(XNNPACK_ENABLE_AVX256SKX OFF)
ENDIF()
ELSEIF(CMAKE_C_COMPILER_ID STREQUAL "Clang")
IF(CMAKE_C_COMPILER_VERSION VERSION_LESS "15")
SET(XNNPACK_ENABLE_AVX256SKX OFF)
ENDIF()
ENDIF()
OPTION(XNNPACK_ENABLE_AVX256VNNI "Build XNNPACK with AVX256VNNI micro-kernels" ON)
IF(CMAKE_C_COMPILER_ID STREQUAL "GNU")
IF(CMAKE_C_COMPILER_VERSION VERSION_LESS "11")
SET(XNNPACK_ENABLE_AVX256VNNI OFF)
ENDIF()
ELSEIF(CMAKE_C_COMPILER_ID STREQUAL "Clang")
IF(CMAKE_C_COMPILER_VERSION VERSION_LESS "15")
SET(XNNPACK_ENABLE_AVX256VNNI OFF)
ENDIF()
ENDIF()
OPTION(XNNPACK_ENABLE_AVX256VNNIGFNI "Build XNNPACK with AVX256VNNIGFNI micro-kernels" ON)
IF(CMAKE_C_COMPILER_ID STREQUAL "GNU")
IF(CMAKE_C_COMPILER_VERSION VERSION_LESS "11")
SET(XNNPACK_ENABLE_AVX256VNNIGFNI OFF)
ENDIF()
ELSEIF(CMAKE_C_COMPILER_ID STREQUAL "Clang")
IF(CMAKE_C_COMPILER_VERSION VERSION_LESS "15")
SET(XNNPACK_ENABLE_AVX256VNNIGFNI OFF)
ENDIF()
ENDIF()
OPTION(XNNPACK_ENABLE_AVX512F "Build XNNPACK with AVX512F micro-kernels" ON)
IF(CMAKE_C_COMPILER_ID STREQUAL "GNU")
IF(CMAKE_C_COMPILER_VERSION VERSION_LESS "8")
SET(XNNPACK_ENABLE_AVX512F OFF)
ENDIF()
ELSEIF(CMAKE_C_COMPILER_ID STREQUAL "Clang")
IF(CMAKE_C_COMPILER_VERSION VERSION_LESS "6")
SET(XNNPACK_ENABLE_AVX512F OFF)
ENDIF()
ENDIF()
OPTION(XNNPACK_ENABLE_AVX512SKX "Build XNNPACK with AVX512SKX micro-kernels" ON)
IF(CMAKE_C_COMPILER_ID STREQUAL "GNU")
IF(CMAKE_C_COMPILER_VERSION VERSION_LESS "8")
SET(XNNPACK_ENABLE_AVX512SKX OFF)
ENDIF()
ELSEIF(CMAKE_C_COMPILER_ID STREQUAL "Clang")
IF(CMAKE_C_COMPILER_VERSION VERSION_LESS "6")
SET(XNNPACK_ENABLE_AVX512SKX OFF)
ENDIF()
ENDIF()
OPTION(XNNPACK_ENABLE_AVX512VBMI "Build XNNPACK with AVX512VBMI micro-kernels" ON)
IF(CMAKE_C_COMPILER_ID STREQUAL "GNU")
IF(CMAKE_C_COMPILER_VERSION VERSION_LESS "8")
SET(XNNPACK_ENABLE_AVX512VBMI OFF)
ENDIF()
ELSEIF(CMAKE_C_COMPILER_ID STREQUAL "Clang")
IF(CMAKE_C_COMPILER_VERSION VERSION_LESS "6")
SET(XNNPACK_ENABLE_AVX512VBMI OFF)
ENDIF()
ENDIF()
OPTION(XNNPACK_ENABLE_AVX512VNNI "Build XNNPACK with AVX512VNNI micro-kernels" ON)
IF(CMAKE_C_COMPILER_ID STREQUAL "GNU")
IF(CMAKE_C_COMPILER_VERSION VERSION_LESS "8")
SET(XNNPACK_ENABLE_AVX512VNNI OFF)
ENDIF()
ELSEIF(CMAKE_C_COMPILER_ID STREQUAL "Clang")
IF(CMAKE_C_COMPILER_VERSION VERSION_LESS "6")
SET(XNNPACK_ENABLE_AVX512VNNI OFF)
ENDIF()
ENDIF()
OPTION(XNNPACK_ENABLE_AVX512VNNIGFNI "Build XNNPACK with AVX512VNNIGFNI micro-kernels" ON)
IF(CMAKE_C_COMPILER_ID STREQUAL "GNU")
IF(CMAKE_C_COMPILER_VERSION VERSION_LESS "8")
SET(XNNPACK_ENABLE_AVX512VNNIGFNI OFF)
ENDIF()
ELSEIF(CMAKE_C_COMPILER_ID STREQUAL "Clang")
IF(CMAKE_C_COMPILER_VERSION VERSION_LESS "6")
SET(XNNPACK_ENABLE_AVX512VNNIGFNI OFF)
ENDIF()
ENDIF()
OPTION(XNNPACK_ENABLE_AVX512AMX "Build XNNPACK with AVX512-AMX micro-kernels" ON)
IF(CMAKE_C_COMPILER_ID STREQUAL "GNU")
IF(CMAKE_C_COMPILER_VERSION VERSION_LESS "13")
SET(XNNPACK_ENABLE_AVX512AMX OFF)
ENDIF()
ELSEIF(CMAKE_C_COMPILER_ID STREQUAL "Clang")
IF(CMAKE_C_COMPILER_VERSION VERSION_LESS "15")
SET(XNNPACK_ENABLE_AVX512AMX OFF)
ENDIF()
ELSEIF(CMAKE_C_COMPILER_ID STREQUAL "MSVC")
SET(XNNPACK_ENABLE_AVX512AMX OFF)
ENDIF()
IF(XNNPACK_TARGET_PROCESSOR STREQUAL "x86")
SET(XNNPACK_ENABLE_AVX512AMX OFF)
ENDIF()
OPTION(XNNPACK_ENABLE_AVX512FP16 "Build XNNPACK with AVX512-FP16 micro-kernels" ON)
IF(CMAKE_C_COMPILER_ID STREQUAL "GNU")
IF(CMAKE_C_COMPILER_VERSION VERSION_LESS "13")
SET(XNNPACK_ENABLE_AVX512FP16 OFF)
ENDIF()
ELSEIF(CMAKE_C_COMPILER_ID STREQUAL "Clang")
IF(CMAKE_C_COMPILER_VERSION VERSION_LESS "15")
SET(XNNPACK_ENABLE_AVX512FP16 OFF)
ENDIF()
ENDIF()
OPTION(XNNPACK_ENABLE_HVX "Build XNNPACK with Hexagon HVX micro-kernels" ON)
OPTION(XNNPACK_ENABLE_KLEIDIAI "Use KleidiAI GEMM microkernels for Arm" ON)
IF(XNNPACK_TARGET_PROCESSOR STREQUAL "arm64" AND XNNPACK_ENABLE_ARM_I8MM AND NOT CMAKE_C_COMPILER_ID STREQUAL "MSVC")
IF (XNNPACK_ENABLE_KLEIDIAI)
MESSAGE(STATUS "Enabling KleidiAI for Arm64")
ENDIF()
ELSE()
SET(XNNPACK_ENABLE_KLEIDIAI OFF)
ENDIF()
# ---[ CMake options
INCLUDE(GNUInstallDirs)
IF(XNNPACK_BUILD_TESTS)
ENABLE_TESTING()
ENDIF()
ADD_COMPILE_DEFINITIONS("XNN_ENABLE_ARM_FP16_VECTOR=$<BOOL:${XNNPACK_ENABLE_ARM_FP16_VECTOR}>")
ADD_COMPILE_DEFINITIONS("XNN_ENABLE_ARM_FP16_SCALAR=$<BOOL:${XNNPACK_ENABLE_ARM_FP16_SCALAR}>")
ADD_COMPILE_DEFINITIONS("XNN_ENABLE_ARM_BF16=$<BOOL:${XNNPACK_ENABLE_ARM_BF16}>")
ADD_COMPILE_DEFINITIONS("XNN_ENABLE_ARM_DOTPROD=$<BOOL:${XNNPACK_ENABLE_ARM_DOTPROD}>")
ADD_COMPILE_DEFINITIONS("XNN_ENABLE_ARM_I8MM=$<BOOL:${XNNPACK_ENABLE_ARM_I8MM}>")
ADD_COMPILE_DEFINITIONS("XNN_ENABLE_ARM_SME=$<BOOL:${XNNPACK_ENABLE_ARM_SME}>")
ADD_COMPILE_DEFINITIONS("XNN_ENABLE_ARM_SME2=$<BOOL:${XNNPACK_ENABLE_ARM_SME2}>")
ADD_COMPILE_DEFINITIONS("XNN_ENABLE_RISCV_VECTOR=$<BOOL:${XNNPACK_ENABLE_RISCV_VECTOR}>")
ADD_COMPILE_DEFINITIONS("XNN_ENABLE_AVXVNNI=$<BOOL:${XNNPACK_ENABLE_AVXVNNI}>")
ADD_COMPILE_DEFINITIONS("XNN_ENABLE_AVXVNNIINT8=$<BOOL:${XNNPACK_ENABLE_AVXVNNIINT8}>")
ADD_COMPILE_DEFINITIONS("XNN_ENABLE_AVX256SKX=$<BOOL:${XNNPACK_ENABLE_AVX256SKX}>")
ADD_COMPILE_DEFINITIONS("XNN_ENABLE_AVX256VNNI=$<BOOL:${XNNPACK_ENABLE_AVX256VNNI}>")
ADD_COMPILE_DEFINITIONS("XNN_ENABLE_AVX256VNNIGFNI=$<BOOL:${XNNPACK_ENABLE_AVX256VNNIGFNI}>")
ADD_COMPILE_DEFINITIONS("XNN_ENABLE_AVX512F=$<BOOL:${XNNPACK_ENABLE_AVX512F}>")
ADD_COMPILE_DEFINITIONS("XNN_ENABLE_AVX512SKX=$<BOOL:${XNNPACK_ENABLE_AVX512SKX}>")
ADD_COMPILE_DEFINITIONS("XNN_ENABLE_AVX512VBMI=$<BOOL:${XNNPACK_ENABLE_AVX512VBMI}>")
ADD_COMPILE_DEFINITIONS("XNN_ENABLE_AVX512VNNI=$<BOOL:${XNNPACK_ENABLE_AVX512VNNI}>")
ADD_COMPILE_DEFINITIONS("XNN_ENABLE_AVX512VNNIGFNI=$<BOOL:${XNNPACK_ENABLE_AVX512VNNIGFNI}>")
ADD_COMPILE_DEFINITIONS("XNN_ENABLE_AVX512AMX=$<BOOL:${XNNPACK_ENABLE_AVX512AMX}>")
ADD_COMPILE_DEFINITIONS("XNN_ENABLE_AVX512FP16=$<BOOL:${XNNPACK_ENABLE_AVX512FP16}>")
ADD_COMPILE_DEFINITIONS("XNN_ENABLE_VSX=$<BOOL:${XNNPACK_ENABLE_VSX}>")
ADD_COMPILE_DEFINITIONS("XNN_ENABLE_ASSEMBLY=$<BOOL:${XNNPACK_ENABLE_ASSEMBLY}>")
ADD_COMPILE_DEFINITIONS("XNN_ENABLE_MEMOPT=$<BOOL:${XNNPACK_ENABLE_MEMOPT}>")
ADD_COMPILE_DEFINITIONS("XNN_ENABLE_SPARSE=$<BOOL:${XNNPACK_ENABLE_SPARSE}>")
ADD_COMPILE_DEFINITIONS("XNN_ENABLE_GEMM_M_SPECIALIZATION=$<BOOL:${XNNPACK_ENABLE_GEMM_M_SPECIALIZATION}>")
ADD_COMPILE_DEFINITIONS("XNN_ENABLE_DWCONV_MULTIPASS=$<BOOL:${XNNPACK_ENABLE_DWCONV_MULTIPASS}>")
ADD_COMPILE_DEFINITIONS("XNN_ENABLE_HVX=$<BOOL:${XNNPACK_ENABLE_HVX}>")
ADD_COMPILE_DEFINITIONS("XNN_ENABLE_KLEIDIAI=$<BOOL:${XNNPACK_ENABLE_KLEIDIAI}>")
IF(XNNPACK_TARGET_PROCESSOR MATCHES "Hexagon")
ADD_COMPILE_DEFINITIONS("XNN_ENABLE_CPUINFO=0")
ELSE()
ADD_COMPILE_DEFINITIONS("XNN_ENABLE_CPUINFO=1")
ENDIF()
IF(USE_GNU_SOURCE)
ADD_COMPILE_DEFINITIONS(_GNU_SOURCE)
ENDIF()
IF(CMAKE_C_COMPILER_ID STREQUAL "MSVC")
# Disable "unary minus operator applied to unsigned type, result still unsigned" warning
ADD_COMPILE_OPTIONS("/wd4146")
# Test files have many sections, increase the limit. See
# https://learn.microsoft.com/en-us/cpp/build/reference/bigobj-increase-number-of-sections-in-dot-obj-file.
ADD_COMPILE_OPTIONS("/bigobj")
ENDIF()
IF(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# Disable "note: parameter passing for argument of type ... changed/will change in ..."
ADD_COMPILE_OPTIONS("-Wno-psabi")
ENDIF()
# ---[ Build flags
IF(NOT CMAKE_SYSTEM_NAME)
MESSAGE(FATAL_ERROR "CMAKE_SYSTEM_NAME not defined")
ELSEIF(NOT CMAKE_SYSTEM_NAME MATCHES "^(Android|Darwin|iOS|Linux|Windows|CYGWIN|MSYS|QURT)$")
MESSAGE(FATAL_ERROR "Unrecognized CMAKE_SYSTEM_NAME value \"${CMAKE_SYSTEM_NAME}\"")
ENDIF()
IF(CMAKE_SYSTEM_NAME MATCHES "Windows")
# Disable min/max macros as they break std::min/max and std::numeric_limits<T>min/max.
ADD_COMPILE_DEFINITIONS("NOMINMAX")
ENDIF()
# ---[ Download deps
IF(NOT XNNPACK_USE_SYSTEM_LIBS)
IF(NOT DEFINED CPUINFO_SOURCE_DIR)
MESSAGE(STATUS "Downloading cpuinfo to ${CMAKE_BINARY_DIR}/cpuinfo-source (define CPUINFO_SOURCE_DIR to avoid it)")
CONFIGURE_FILE(cmake/DownloadCpuinfo.cmake "${CMAKE_BINARY_DIR}/cpuinfo-download/CMakeLists.txt")
EXECUTE_PROCESS(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" .
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/cpuinfo-download")
EXECUTE_PROCESS(COMMAND "${CMAKE_COMMAND}" --build .
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/cpuinfo-download")
SET(CPUINFO_SOURCE_DIR "${CMAKE_BINARY_DIR}/cpuinfo-source" CACHE STRING "cpuinfo source directory")
ENDIF()
IF(NOT DEFINED FXDIV_SOURCE_DIR)
MESSAGE(STATUS "Downloading FXdiv to ${CMAKE_BINARY_DIR}/FXdiv-source (define FXDIV_SOURCE_DIR to avoid it)")
CONFIGURE_FILE(cmake/DownloadFXdiv.cmake "${CMAKE_BINARY_DIR}/FXdiv-download/CMakeLists.txt")
EXECUTE_PROCESS(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" .
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/FXdiv-download")
EXECUTE_PROCESS(COMMAND "${CMAKE_COMMAND}" --build .
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/FXdiv-download")
SET(FXDIV_SOURCE_DIR "${CMAKE_BINARY_DIR}/FXdiv-source" CACHE STRING "FXdiv source directory")
ENDIF()
IF(NOT DEFINED PTHREADPOOL_SOURCE_DIR)
MESSAGE(STATUS "Downloading pthreadpool to ${CMAKE_BINARY_DIR}/pthreadpool-source (define PTHREADPOOL_SOURCE_DIR to avoid it)")
CONFIGURE_FILE(cmake/DownloadPThreadPool.cmake "${CMAKE_BINARY_DIR}/pthreadpool-download/CMakeLists.txt")
EXECUTE_PROCESS(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" .
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/pthreadpool-download")
EXECUTE_PROCESS(COMMAND "${CMAKE_COMMAND}" --build .
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/pthreadpool-download")
SET(PTHREADPOOL_SOURCE_DIR "${CMAKE_BINARY_DIR}/pthreadpool-source" CACHE STRING "pthreadpool source directory")
ENDIF()
IF(XNNPACK_BUILD_TESTS AND NOT DEFINED GOOGLETEST_SOURCE_DIR)
MESSAGE(STATUS "Downloading Google Test to ${CMAKE_BINARY_DIR}/googletest-source (define GOOGLETEST_SOURCE_DIR to avoid it)")
CONFIGURE_FILE(cmake/DownloadGoogleTest.cmake "${CMAKE_BINARY_DIR}/googletest-download/CMakeLists.txt")
EXECUTE_PROCESS(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" .
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/googletest-download")
EXECUTE_PROCESS(COMMAND "${CMAKE_COMMAND}" --build .
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/googletest-download")
SET(GOOGLETEST_SOURCE_DIR "${CMAKE_BINARY_DIR}/googletest-source" CACHE STRING "Google Test source directory")
ENDIF()
IF(XNNPACK_BUILD_BENCHMARKS AND NOT DEFINED GOOGLEBENCHMARK_SOURCE_DIR)
MESSAGE(STATUS "Downloading Google Benchmark to ${CMAKE_BINARY_DIR}/googlebenchmark-source (define GOOGLEBENCHMARK_SOURCE_DIR to avoid it)")
CONFIGURE_FILE(cmake/DownloadGoogleBenchmark.cmake "${CMAKE_BINARY_DIR}/googlebenchmark-download/CMakeLists.txt")
EXECUTE_PROCESS(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" .
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/googlebenchmark-download")
EXECUTE_PROCESS(COMMAND "${CMAKE_COMMAND}" --build .
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/googlebenchmark-download")
SET(GOOGLEBENCHMARK_SOURCE_DIR "${CMAKE_BINARY_DIR}/googlebenchmark-source" CACHE STRING "Google Benchmark source directory")
ENDIF()
IF(XNNPACK_ENABLE_KLEIDIAI AND NOT DEFINED KLEIDIAI_SOURCE_DIR)
MESSAGE(STATUS "Downloading KleidiAI to ${CMAKE_BINARY_DIR}/kleidiai-source (define KLEIDIAI_SOURCE_DIR to avoid it)")
CONFIGURE_FILE(cmake/DownloadKleidiAI.cmake "${CMAKE_BINARY_DIR}/kleidiai-download/CMakeLists.txt")
EXECUTE_PROCESS(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" .
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/kleidiai-download")
EXECUTE_PROCESS(COMMAND "${CMAKE_COMMAND}" --build .
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/kleidiai-download")
SET(KLEIDIAI_SOURCE_DIR "${CMAKE_BINARY_DIR}/kleidiai-source" CACHE STRING "kleidiai source directory")
ENDIF()
ENDIF()
# ---[ XNNPACK library
IF (NOT DEFINED Python_EXECUTABLE)
find_package(Python COMPONENTS Interpreter)
IF(NOT Python_FOUND)
SET(PYTHON_EXECUTABLE "python3")
ENDIF()
ENDIF()
# Generate and load the micorkernels.cmake files.
MESSAGE(STATUS "Generating microkernels.cmake")
EXECUTE_PROCESS(
COMMAND "${Python_EXECUTABLE}" "${PROJECT_SOURCE_DIR}/tools/update-microkernels.py" --output "${PROJECT_BINARY_DIR}"
RESULT_VARIABLE UPDATE_MICROKERNELS_RESULT
)
IF(NOT UPDATE_MICROKERNELS_RESULT EQUAL 0)
MESSAGE(FATAL_ERROR "Failed to generate \"microkernels.cmake\".")
ENDIF()
INCLUDE("${PROJECT_BINARY_DIR}/cmake/gen/microkernels.cmake")
SET(OPERATOR_SRCS
src/operator-delete.c
src/operators/argmax-pooling-nhwc.c
src/operators/average-pooling-nhwc.c
src/operators/batch-matrix-multiply-nc.c
src/operators/binary-elementwise-nd.c
src/operators/channel-shuffle-nc.c
src/operators/constant-pad-nd.c
src/operators/convolution-nchw.c
src/operators/convolution-nhwc.c
src/operators/deconvolution-nhwc.c
src/operators/dynamic-fully-connected-nc.c
src/operators/fully-connected-nc.c
src/operators/max-pooling-nhwc.c
src/operators/pack-lh.c
src/operators/reduce-nd.c
src/operators/resize-bilinear-nchw.c
src/operators/resize-bilinear-nhwc.c
src/operators/rope-nthc.c
src/operators/scaled-dot-product-attention-nhtc.c
src/operators/slice-nd.c
src/operators/softmax-nc.c
src/operators/transpose-nd.c
src/operators/unary-elementwise-nc.c
src/operators/unpooling-nhwc.c)
SET(REFERENCE_SRCS
src/reference/unary-elementwise.cc
src/reference/binary-elementwise.cc)
SET(SUBGRAPH_SRCS
src/memory-planner.c
src/runtime.c
src/subgraph.c
src/subgraph/argmax-pooling-2d.c
src/subgraph/average-pooling-2d.c
src/subgraph/batch-matrix-multiply.c
src/subgraph/binary.c
src/subgraph/concatenate.c
src/subgraph/convolution-2d.c
src/subgraph/copy.c
src/subgraph/deconvolution-2d.c
src/subgraph/deprecated.c
src/subgraph/depth-to-space-2d.c
src/subgraph/depthwise-convolution-2d.c
src/subgraph/even-split.c
src/subgraph/fully-connected-sparse.c
src/subgraph/fully-connected.c
src/subgraph/max-pooling-2d.c
src/subgraph/pack-lh.c
src/subgraph/reshape-helpers.c
src/subgraph/scaled-dot-product-attention.c
src/subgraph/softmax.c
src/subgraph/space-to-depth-2d.c
src/subgraph/static-constant-pad.c
src/subgraph/static-reduce.c
src/subgraph/static-resize-bilinear-2d.c
src/subgraph/static-slice.c
src/subgraph/static-transpose.c
src/subgraph/unpooling-2d.c
src/subgraph/unary.c
src/subgraph/validation.c
src/tensor.c)
SET(LOGGING_SRCS
src/enums/allocation-type.c
src/enums/datatype-strings.c
src/enums/microkernel-type.c
src/enums/node-type.c
src/enums/operator-type.c
src/log.c)
SET(XNNPACK_SRCS
src/configs/argmaxpool-config.c
src/configs/avgpool-config.c
src/configs/binary-elementwise-config.c
src/configs/cmul-config.c
src/configs/conv-hwc2chw-config.c
src/configs/dwconv-config.c
src/configs/dwconv2d-chw-config.c
src/configs/experiments-config.c
src/configs/gemm-config.c
src/configs/ibilinear-chw-config.c
src/configs/ibilinear-config.c
src/configs/lut32norm-config.c
src/configs/maxpool-config.c
src/configs/pavgpool-config.c
src/configs/pack-lh-config.c
src/configs/raddstoreexpminusmax-config.c
src/configs/reduce-config.c
src/configs/rmax-config.c
src/configs/spmm-config.c
src/configs/transpose-config.c
src/configs/unary-elementwise-config.c
src/configs/unpool-config.c
src/configs/vmulcaddc-config.c
src/configs/xx-fill-config.c
src/configs/xx-pad-config.c
src/configs/x8-lut-config.c
src/configs/zip-config.c
src/init.c
src/params.c
"${PROJECT_BINARY_DIR}/build_identifier.c")
SET(TABLE_SRCS
src/tables/exp2-k-over-64.c
src/tables/exp2-k-over-2048.c
src/tables/exp2minus-k-over-4.c
src/tables/exp2minus-k-over-8.c
src/tables/exp2minus-k-over-16.c
src/tables/exp2minus-k-over-32.c
src/tables/exp2minus-k-over-64.c
src/tables/exp2minus-k-over-2048.c
src/tables/vlog.c)
SET(PROD_MICROKERNEL_SRCS ${PROD_SCALAR_MICROKERNEL_SRCS})
SET(NON_PROD_MICROKERNEL_SRCS ${NON_PROD_SCALAR_MICROKERNEL_SRCS})
IF(XNNPACK_TARGET_PROCESSOR STREQUAL "arm")
LIST(APPEND PROD_MICROKERNEL_SRCS ${PROD_ARMSIMD32_MICROKERNEL_SRCS})
LIST(APPEND PROD_MICROKERNEL_SRCS ${PROD_NEON_MICROKERNEL_SRCS})
LIST(APPEND PROD_MICROKERNEL_SRCS ${PROD_NEONFP16_MICROKERNEL_SRCS})
LIST(APPEND PROD_MICROKERNEL_SRCS ${PROD_NEONFMA_MICROKERNEL_SRCS})
LIST(APPEND PROD_MICROKERNEL_SRCS ${PROD_NEONV8_MICROKERNEL_SRCS})
IF(XNNPACK_ENABLE_ARM_FP16_SCALAR)
LIST(APPEND PROD_MICROKERNEL_SRCS ${PROD_FP16ARITH_MICROKERNEL_SRCS})
ENDIF()
IF(XNNPACK_ENABLE_ARM_FP16_VECTOR)
LIST(APPEND PROD_MICROKERNEL_SRCS ${PROD_NEONFP16ARITH_MICROKERNEL_SRCS})
ENDIF()
IF(XNNPACK_ENABLE_ARM_DOTPROD)
LIST(APPEND PROD_MICROKERNEL_SRCS ${PROD_NEONDOT_MICROKERNEL_SRCS})
ENDIF()
IF(XNNPACK_ENABLE_ARM_DOTPROD AND XNNPACK_ENABLE_ARM_FP16_VECTOR)
LIST(APPEND PROD_MICROKERNEL_SRCS ${PROD_NEONDOTFP16ARITH_MICROKERNEL_SRCS})
ENDIF()
LIST(APPEND NON_PROD_MICROKERNEL_SRCS ${NON_PROD_ARMSIMD32_MICROKERNEL_SRCS})
LIST(APPEND NON_PROD_MICROKERNEL_SRCS ${NON_PROD_NEON_MICROKERNEL_SRCS})
LIST(APPEND NON_PROD_MICROKERNEL_SRCS ${NON_PROD_NEONFP16_MICROKERNEL_SRCS})
LIST(APPEND NON_PROD_MICROKERNEL_SRCS ${NON_PROD_NEONFMA_MICROKERNEL_SRCS})
LIST(APPEND NON_PROD_MICROKERNEL_SRCS ${NON_PROD_NEONV8_MICROKERNEL_SRCS})
IF(XNNPACK_ENABLE_ARM_FP16_SCALAR)
LIST(APPEND NON_PROD_MICROKERNEL_SRCS ${NON_PROD_FP16ARITH_MICROKERNEL_SRCS})
ENDIF()
IF(XNNPACK_ENABLE_ARM_FP16_VECTOR AND XNNPACK_ENABLE_ARM_DOTPROD)
LIST(APPEND NON_PROD_MICROKERNEL_SRCS ${NON_PROD_NEONDOTFP16ARITH_MICROKERNEL_SRCS})
ENDIF()
IF(XNNPACK_ENABLE_ARM_FP16_VECTOR)
LIST(APPEND NON_PROD_MICROKERNEL_SRCS ${NON_PROD_NEONFP16ARITH_MICROKERNEL_SRCS})
ENDIF()
IF(XNNPACK_ENABLE_ARM_BF16)
LIST(APPEND NON_PROD_MICROKERNEL_SRCS ${NON_PROD_NEONBF16_MICROKERNEL_SRCS})
ENDIF()
IF(XNNPACK_ENABLE_ARM_DOTPROD)
LIST(APPEND NON_PROD_MICROKERNEL_SRCS ${NON_PROD_NEONDOT_MICROKERNEL_SRCS})
ENDIF()
IF(XNNPACK_ENABLE_ASSEMBLY)
LIST(APPEND PROD_MICROKERNEL_SRCS ${PROD_AARCH32_ASM_MICROKERNEL_SRCS})
LIST(APPEND NON_PROD_MICROKERNEL_SRCS ${NON_PROD_AARCH32_ASM_MICROKERNEL_SRCS})
ENDIF()
ENDIF()
IF(XNNPACK_TARGET_PROCESSOR MATCHES "^arm64")
LIST(APPEND PROD_MICROKERNEL_SRCS ${PROD_NEON_MICROKERNEL_SRCS})
LIST(APPEND PROD_MICROKERNEL_SRCS ${PROD_NEONFP16_MICROKERNEL_SRCS})
LIST(APPEND PROD_MICROKERNEL_SRCS ${PROD_NEONFMA_MICROKERNEL_SRCS})
LIST(APPEND PROD_MICROKERNEL_SRCS ${PROD_NEONV8_MICROKERNEL_SRCS})
LIST(APPEND PROD_MICROKERNEL_SRCS ${PROD_NEON_AARCH64_MICROKERNEL_SRCS})
LIST(APPEND PROD_MICROKERNEL_SRCS ${PROD_NEONFMA_AARCH64_MICROKERNEL_SRCS})
IF(XNNPACK_ENABLE_ARM_FP16_SCALAR)
LIST(APPEND PROD_MICROKERNEL_SRCS ${PROD_FP16ARITH_MICROKERNEL_SRCS})
ENDIF()
IF(XNNPACK_ENABLE_ARM_FP16_VECTOR)
LIST(APPEND PROD_MICROKERNEL_SRCS ${PROD_NEONFP16ARITH_MICROKERNEL_SRCS})
LIST(APPEND PROD_MICROKERNEL_SRCS ${PROD_NEONFP16ARITH_AARCH64_MICROKERNEL_SRCS})
ENDIF()
IF(XNNPACK_ENABLE_ARM_DOTPROD)
LIST(APPEND PROD_MICROKERNEL_SRCS ${PROD_NEONDOT_MICROKERNEL_SRCS})
LIST(APPEND PROD_MICROKERNEL_SRCS ${PROD_NEONDOT_AARCH64_MICROKERNEL_SRCS})
ENDIF()
IF(XNNPACK_ENABLE_ARM_DOTPROD AND XNNPACK_ENABLE_ARM_FP16_VECTOR)
LIST(APPEND PROD_MICROKERNEL_SRCS ${PROD_NEONDOTFP16ARITH_MICROKERNEL_SRCS})
ENDIF()
IF(XNNPACK_ENABLE_ARM_I8MM)
LIST(APPEND PROD_MICROKERNEL_SRCS ${PROD_NEONI8MM_MICROKERNEL_SRCS})
ENDIF()
IF(XNNPACK_ENABLE_ARM_SME)
LIST(APPEND PROD_MICROKERNEL_SRCS ${PROD_NEONSME_MICROKERNEL_SRCS})
ENDIF()
IF(XNNPACK_ENABLE_ARM_SME2)
LIST(APPEND PROD_MICROKERNEL_SRCS ${PROD_NEONSME2_MICROKERNEL_SRCS})
ENDIF()
LIST(APPEND NON_PROD_MICROKERNEL_SRCS ${NON_PROD_NEON_MICROKERNEL_SRCS})
LIST(APPEND NON_PROD_MICROKERNEL_SRCS ${NON_PROD_NEONFP16_MICROKERNEL_SRCS})
LIST(APPEND NON_PROD_MICROKERNEL_SRCS ${NON_PROD_NEONFMA_MICROKERNEL_SRCS})
LIST(APPEND NON_PROD_MICROKERNEL_SRCS ${NON_PROD_NEONV8_MICROKERNEL_SRCS})
LIST(APPEND NON_PROD_MICROKERNEL_SRCS ${NON_PROD_NEON_AARCH64_MICROKERNEL_SRCS})
LIST(APPEND NON_PROD_MICROKERNEL_SRCS ${NON_PROD_NEONFMA_AARCH64_MICROKERNEL_SRCS})
IF(XNNPACK_ENABLE_ARM_FP16_SCALAR)
LIST(APPEND NON_PROD_MICROKERNEL_SRCS ${NON_PROD_FP16ARITH_MICROKERNEL_SRCS})
ENDIF()
IF(XNNPACK_ENABLE_ARM_FP16_VECTOR AND XNNPACK_ENABLE_ARM_DOTPROD)
LIST(APPEND NON_PROD_MICROKERNEL_SRCS ${NON_PROD_NEONDOTFP16ARITH_MICROKERNEL_SRCS})
ENDIF()
IF(XNNPACK_ENABLE_ARM_FP16_VECTOR)
LIST(APPEND NON_PROD_MICROKERNEL_SRCS ${NON_PROD_NEONFP16ARITH_MICROKERNEL_SRCS})
LIST(APPEND NON_PROD_MICROKERNEL_SRCS ${NON_PROD_NEONFP16ARITH_AARCH64_MICROKERNEL_SRCS})
ENDIF()
IF(XNNPACK_ENABLE_ARM_BF16)
LIST(APPEND NON_PROD_MICROKERNEL_SRCS ${NON_PROD_NEONBF16_MICROKERNEL_SRCS})
ENDIF()
IF(XNNPACK_ENABLE_ARM_DOTPROD)
LIST(APPEND NON_PROD_MICROKERNEL_SRCS ${NON_PROD_NEONDOT_MICROKERNEL_SRCS})
LIST(APPEND NON_PROD_MICROKERNEL_SRCS ${NON_PROD_NEONDOT_AARCH64_MICROKERNEL_SRCS})
ENDIF()
IF(XNNPACK_ENABLE_ARM_I8MM)
LIST(APPEND NON_PROD_MICROKERNEL_SRCS ${NON_PROD_NEONI8MM_MICROKERNEL_SRCS})
ENDIF()
IF(XNNPACK_ENABLE_ARM_SME)
LIST(APPEND NON_PROD_MICROKERNEL_SRCS ${NON_PROD_NEONSME_MICROKERNEL_SRCS})
ENDIF()
IF(XNNPACK_ENABLE_ARM_SME2)
LIST(APPEND NON_PROD_MICROKERNEL_SRCS ${NON_PROD_NEONSME2_MICROKERNEL_SRCS})
ENDIF()
IF(XNNPACK_ENABLE_ASSEMBLY)
LIST(APPEND PROD_MICROKERNEL_SRCS ${PROD_AARCH64_ASM_MICROKERNEL_SRCS})
LIST(APPEND NON_PROD_MICROKERNEL_SRCS ${NON_PROD_AARCH64_ASM_MICROKERNEL_SRCS})
ENDIF()
ENDIF()
IF(XNNPACK_TARGET_PROCESSOR MATCHES "^x86(_64)?$")
LIST(APPEND PROD_MICROKERNEL_SRCS ${PROD_SSE_MICROKERNEL_SRCS})
LIST(APPEND PROD_MICROKERNEL_SRCS ${PROD_SSE2_MICROKERNEL_SRCS})
LIST(APPEND PROD_MICROKERNEL_SRCS ${PROD_SSSE3_MICROKERNEL_SRCS})
LIST(APPEND PROD_MICROKERNEL_SRCS ${PROD_SSE41_MICROKERNEL_SRCS})
LIST(APPEND PROD_MICROKERNEL_SRCS ${PROD_AVX_MICROKERNEL_SRCS})
LIST(APPEND PROD_MICROKERNEL_SRCS ${PROD_F16C_MICROKERNEL_SRCS})
LIST(APPEND PROD_MICROKERNEL_SRCS ${PROD_FMA3_MICROKERNEL_SRCS})
LIST(APPEND PROD_MICROKERNEL_SRCS ${PROD_AVX2_MICROKERNEL_SRCS})
IF(XNNPACK_ENABLE_AVX512AMX)
LIST(APPEND PROD_MICROKERNEL_SRCS ${PROD_AVX512AMX_MICROKERNEL_SRCS})
ENDIF()
IF(XNNPACK_ENABLE_AVX512FP16)
LIST(APPEND PROD_MICROKERNEL_SRCS ${PROD_AVX512FP16_MICROKERNEL_SRCS})
ENDIF()
IF(XNNPACK_ENABLE_AVXVNNI)
LIST(APPEND PROD_MICROKERNEL_SRCS ${PROD_AVXVNNI_MICROKERNEL_SRCS})
ENDIF()
IF(XNNPACK_ENABLE_AVXVNNIINT8)
LIST(APPEND PROD_MICROKERNEL_SRCS ${PROD_AVXVNNIINT8_MICROKERNEL_SRCS})
ENDIF()
IF(XNNPACK_ENABLE_AVX256SKX)
LIST(APPEND PROD_MICROKERNEL_SRCS ${PROD_AVX256SKX_MICROKERNEL_SRCS})
ENDIF()
IF(XNNPACK_ENABLE_AVX256VNNI)
LIST(APPEND PROD_MICROKERNEL_SRCS ${PROD_AVX256VNNI_MICROKERNEL_SRCS})
ENDIF()
IF(XNNPACK_ENABLE_AVX256VNNIGFNI)
LIST(APPEND PROD_MICROKERNEL_SRCS ${PROD_AVX256VNNIGFNI_MICROKERNEL_SRCS})
ENDIF()
IF(XNNPACK_ENABLE_AVX512F)
LIST(APPEND PROD_MICROKERNEL_SRCS ${PROD_AVX512F_MICROKERNEL_SRCS})
ENDIF()
IF(XNNPACK_ENABLE_AVX512SKX)
LIST(APPEND PROD_MICROKERNEL_SRCS ${PROD_AVX512SKX_MICROKERNEL_SRCS})
ENDIF()
IF(XNNPACK_ENABLE_AVX512VBMI)
LIST(APPEND PROD_MICROKERNEL_SRCS ${PROD_AVX512VBMI_MICROKERNEL_SRCS})
ENDIF()
IF(XNNPACK_ENABLE_AVX512VNNI)
LIST(APPEND PROD_MICROKERNEL_SRCS ${PROD_AVX512VNNI_MICROKERNEL_SRCS})
ENDIF()
IF(XNNPACK_ENABLE_AVX512VNNIGFNI)
LIST(APPEND PROD_MICROKERNEL_SRCS ${PROD_AVX512VNNIGFNI_MICROKERNEL_SRCS})
ENDIF()
IF(XNNPACK_ENABLE_AVX512VNNIGFNI)
LIST(APPEND PROD_MICROKERNEL_SRCS ${PROD_AVX512VNNIGFNI_MICROKERNEL_SRCS})
ENDIF()
LIST(APPEND NON_PROD_MICROKERNEL_SRCS ${NON_PROD_SSE_MICROKERNEL_SRCS})
LIST(APPEND NON_PROD_MICROKERNEL_SRCS ${NON_PROD_SSE2_MICROKERNEL_SRCS})
LIST(APPEND NON_PROD_MICROKERNEL_SRCS ${NON_PROD_SSSE3_MICROKERNEL_SRCS})
LIST(APPEND NON_PROD_MICROKERNEL_SRCS ${NON_PROD_SSE41_MICROKERNEL_SRCS})
LIST(APPEND NON_PROD_MICROKERNEL_SRCS ${NON_PROD_AVX_MICROKERNEL_SRCS})
LIST(APPEND NON_PROD_MICROKERNEL_SRCS ${NON_PROD_F16C_MICROKERNEL_SRCS})
LIST(APPEND NON_PROD_MICROKERNEL_SRCS ${NON_PROD_FMA3_MICROKERNEL_SRCS})
LIST(APPEND NON_PROD_MICROKERNEL_SRCS ${NON_PROD_AVX2_MICROKERNEL_SRCS})
IF(XNNPACK_ENABLE_AVX512AMX)
LIST(APPEND NON_PROD_MICROKERNEL_SRCS ${NON_PROD_AVX512AMX_MICROKERNEL_SRCS})
ENDIF()
IF(XNNPACK_ENABLE_AVX512FP16)
LIST(APPEND NON_PROD_MICROKERNEL_SRCS ${NON_PROD_AVX512FP16_MICROKERNEL_SRCS})
ENDIF()
IF(XNNPACK_ENABLE_AVXVNNI)
LIST(APPEND NON_PROD_MICROKERNEL_SRCS ${NON_PROD_AVXVNNI_MICROKERNEL_SRCS})
ENDIF()
IF(XNNPACK_ENABLE_AVXVNNIINT8)
LIST(APPEND NON_PROD_MICROKERNEL_SRCS ${NON_PROD_AVXVNNIINT8_MICROKERNEL_SRCS})
ENDIF()
IF(XNNPACK_ENABLE_AVX256SKX)
LIST(APPEND NON_PROD_MICROKERNEL_SRCS ${NON_PROD_AVX256SKX_MICROKERNEL_SRCS})
ENDIF()
IF(XNNPACK_ENABLE_AVX256VNNI)
LIST(APPEND NON_PROD_MICROKERNEL_SRCS ${NON_PROD_AVX256VNNI_MICROKERNEL_SRCS})
ENDIF()
IF(XNNPACK_ENABLE_AVX256VNNIGFNI)
LIST(APPEND NON_PROD_MICROKERNEL_SRCS ${NON_PROD_AVX256VNNIGFNI_MICROKERNEL_SRCS})
ENDIF()
IF(XNNPACK_ENABLE_AVX512F)
LIST(APPEND NON_PROD_MICROKERNEL_SRCS ${NON_PROD_AVX512F_MICROKERNEL_SRCS})
ENDIF()
IF(XNNPACK_ENABLE_AVX512SKX)
LIST(APPEND NON_PROD_MICROKERNEL_SRCS ${NON_PROD_AVX512SKX_MICROKERNEL_SRCS})
ENDIF()
IF(XNNPACK_ENABLE_AVX512VBMI)
LIST(APPEND NON_PROD_MICROKERNEL_SRCS ${NON_PROD_AVX512VBMI_MICROKERNEL_SRCS})
ENDIF()
IF(XNNPACK_ENABLE_AVX512VNNI)
LIST(APPEND NON_PROD_MICROKERNEL_SRCS ${NON_PROD_AVX512VNNI_MICROKERNEL_SRCS})
ENDIF()
IF(XNNPACK_ENABLE_AVX512VNNIGFNI)
LIST(APPEND NON_PROD_MICROKERNEL_SRCS ${NON_PROD_AVX512VNNIGFNI_MICROKERNEL_SRCS})
ENDIF()
ENDIF()
IF(XNNPACK_TARGET_PROCESSOR MATCHES "Hexagon")
LIST(APPEND NON_PROD_MICROKERNEL_SRCS ${NON_PROD_HEXAGON_MICROKERNEL_SRCS})
IF(XNNPACK_ENABLE_HVX)
LIST(APPEND NON_PROD_MICROKERNEL_SRCS ${NON_PROD_HVX_MICROKERNEL_SRCS})
ENDIF()
ENDIF()
IF(XNNPACK_TARGET_PROCESSOR MATCHES "^ppc64")
IF(XNNPACK_ENABLE_VSX)
LIST(APPEND NON_PROD_MICROKERNEL_SRCS ${NON_PROD_PPC64_MICROKERNEL_SRCS})
ENDIF()
ENDIF()
IF(XNNPACK_TARGET_PROCESSOR MATCHES "^riscv")
LIST(APPEND PROD_MICROKERNEL_SRCS)
IF(XNNPACK_ENABLE_RISCV_VECTOR)
LIST(APPEND NON_PROD_MICROKERNEL_SRCS ${NON_PROD_RVV_MICROKERNEL_SRCS})
LIST(APPEND PROD_MICROKERNEL_SRCS ${PROD_RVV_MICROKERNEL_SRCS})
ENDIF()
IF(XNNPACK_ENABLE_RISCV_FP16_VECTOR)
LIST(APPEND NON_PROD_MICROKERNEL_SRCS ${NON_PROD_RVVFP16ARITH_MICROKERNEL_SRCS})
LIST(APPEND PROD_MICROKERNEL_SRCS ${PROD_RVVFP16ARITH_MICROKERNEL_SRCS})
ENDIF()
ENDIF()
SET(ALL_MICROKERNEL_SRCS ${PROD_MICROKERNEL_SRCS} ${NON_PROD_MICROKERNEL_SRCS})
LIST(SORT PROD_MICROKERNEL_SRCS)
STRING(REPLACE ";" "\n" PROD_MICROKERNEL_SRCS_WITH_NEWLINES "${PROD_MICROKERNEL_SRCS}")
FILE(GENERATE OUTPUT "${PROJECT_BINARY_DIR}/prod_microkernel_srcs.txt" CONTENT "${PROD_MICROKERNEL_SRCS_WITH_NEWLINES}")
ADD_CUSTOM_COMMAND(
OUTPUT "${PROJECT_BINARY_DIR}/build_identifier.c"
COMMAND "${Python_EXECUTABLE}" "scripts/generate-build-identifier.py" --output "${PROJECT_BINARY_DIR}/build_identifier.c" --input_file_list "${PROJECT_BINARY_DIR}/prod_microkernel_srcs.txt"
DEPENDS "${PROJECT_BINARY_DIR}/prod_microkernel_srcs.txt"
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
)
# Create a dummy library that contains shared dependencies and definitions for
# all other XNNPACK targets.
ADD_LIBRARY(xnnpack-base INTERFACE)
ADD_LIBRARY(microkernels-prod STATIC ${PROD_MICROKERNEL_SRCS} ${TABLE_SRCS})
IF(XNNPACK_BUILD_ALL_MICROKERNELS)
ADD_LIBRARY(microkernels-all STATIC ${NON_PROD_MICROKERNEL_SRCS})
TARGET_LINK_LIBRARIES(microkernels-all PUBLIC microkernels-prod)
ENDIF()
ADD_LIBRARY(hardware-config OBJECT src/configs/hardware-config.c)
ADD_LIBRARY(indirection OBJECT src/indirection.c)
ADD_LIBRARY(logging OBJECT ${LOGGING_SRCS})
ADD_LIBRARY(microparams-init OBJECT src/microparams-init.c)
ADD_LIBRARY(normalization OBJECT src/normalization.c)
ADD_LIBRARY(packing OBJECT src/reference/packing.cc)
TARGET_LINK_LIBRARIES(hardware-config PRIVATE xnnpack-base logging)
TARGET_LINK_LIBRARIES(indirection PRIVATE xnnpack-base)
TARGET_LINK_LIBRARIES(logging PRIVATE xnnpack-base)
IF(XNNPACK_BUILD_ALL_MICROKERNELS)
TARGET_LINK_LIBRARIES(microkernels-all PRIVATE xnnpack-base)
ENDIF()
TARGET_LINK_LIBRARIES(microkernels-prod PRIVATE xnnpack-base)
TARGET_LINK_LIBRARIES(microparams-init PRIVATE xnnpack-base)
TARGET_LINK_LIBRARIES(normalization PRIVATE xnnpack-base)
TARGET_LINK_LIBRARIES(packing PRIVATE xnnpack-base logging)
IF(XNNPACK_BUILD_LIBRARY)
ADD_LIBRARY(allocator OBJECT src/allocator.c)
ADD_LIBRARY(cache OBJECT src/cache.c)
ADD_LIBRARY(datatype OBJECT src/datatype.c)
ADD_LIBRARY(memory OBJECT src/memory.c)
ADD_LIBRARY(microkernel-utils OBJECT src/microkernel-utils.c)
ADD_LIBRARY(mutex OBJECT src/mutex.c)
ADD_LIBRARY(operators OBJECT ${OPERATOR_SRCS})
ADD_LIBRARY(operator-run OBJECT src/operator-run.c)
ADD_LIBRARY(operator-utils OBJECT src/operator-utils.c)
ADD_LIBRARY(reference-ukernels OBJECT ${REFERENCE_SRCS})
ADD_LIBRARY(subgraph OBJECT ${SUBGRAPH_SRCS})
# Need C_EXTENSIONS to get constants for mmap (MAP_ANONYMOUS).
SET_TARGET_PROPERTIES(memory PROPERTIES C_EXTENSIONS YES)
IF(XNNPACK_LIBRARY_TYPE STREQUAL "default")
ADD_LIBRARY(XNNPACK ${XNNPACK_SRCS})
ELSEIF(XNNPACK_LIBRARY_TYPE STREQUAL "shared")
ADD_LIBRARY(XNNPACK SHARED ${XNNPACK_SRCS})
ELSEIF(XNNPACK_LIBRARY_TYPE STREQUAL "static")
ADD_LIBRARY(XNNPACK STATIC ${XNNPACK_SRCS})
ELSE()
MESSAGE(FATAL_ERROR "Unsupported XNNPACK library type \"${XNNPACK_LIBRARY_TYPE}\". Must be \"static\", \"shared\", or \"default\"")
ENDIF()
TARGET_LINK_LIBRARIES(allocator PRIVATE xnnpack-base logging)
TARGET_LINK_LIBRARIES(cache PRIVATE xnnpack-base logging)
TARGET_LINK_LIBRARIES(datatype PRIVATE xnnpack-base)
TARGET_LINK_LIBRARIES(memory PRIVATE xnnpack-base logging)
TARGET_LINK_LIBRARIES(microkernel-utils PRIVATE xnnpack-base logging)
TARGET_LINK_LIBRARIES(mutex PRIVATE xnnpack-base logging)
TARGET_LINK_LIBRARIES(operators PRIVATE xnnpack-base allocator indirection logging microkernel-utils normalization operator-utils packing reference-ukernels datatype)
TARGET_LINK_LIBRARIES(operator-run PRIVATE xnnpack-base logging)
TARGET_LINK_LIBRARIES(operator-utils PRIVATE xnnpack-base logging)
TARGET_LINK_LIBRARIES(reference-ukernels PRIVATE xnnpack-base)
TARGET_LINK_LIBRARIES(subgraph PRIVATE xnnpack-base allocator logging memory mutex operators operator-run datatype)
TARGET_LINK_LIBRARIES(XNNPACK PRIVATE xnnpack-base allocator cache hardware-config indirection memory microkernel-utils microparams-init mutex normalization operators operator-run operator-utils packing microkernels-prod subgraph datatype reference-ukernels)
TARGET_LINK_LIBRARIES(XNNPACK PUBLIC pthreadpool logging)
SET_TARGET_PROPERTIES(XNNPACK PROPERTIES C_EXTENSIONS YES)
ENDIF()
IF(NOT MSVC)
SET_PROPERTY(SOURCE ${ALL_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " -fno-math-errno ")
ENDIF()
IF(XNNPACK_TARGET_PROCESSOR STREQUAL "arm")
SET_PROPERTY(SOURCE ${ALL_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " -marm ")
SET_PROPERTY(SOURCE ${ALL_ARMSIMD32_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " -march=armv6 -mfpu=vfp -munaligned-access ")
SET_PROPERTY(SOURCE ${ALL_NEON_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " -march=armv7-a -mfpu=neon ")
SET_PROPERTY(SOURCE ${ALL_NEONFP16_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " -march=armv7-a -mfpu=neon-fp16 ")
# GCC requires -mfp16-format=ieee to define __fp16 type, but Clang doesn't support this option at all.
IF(CMAKE_C_COMPILER_ID STREQUAL "GNU")
SET_PROPERTY(SOURCE ${ALL_NEONFP16_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " -mfp16-format=ieee ")
SET_PROPERTY(SOURCE ${ALL_FP16ARITH_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " -mfp16-format=ieee ")
SET_PROPERTY(SOURCE ${ALL_NEONDOTFP16ARITH_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " -mfp16-format=ieee ")
SET_PROPERTY(SOURCE ${ALL_NEONFP16ARITH_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " -mfp16-format=ieee ")
ENDIF()
SET_PROPERTY(SOURCE ${ALL_NEONFMA_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " -march=armv7-a -mfpu=neon-vfpv4 ")
SET_PROPERTY(SOURCE ${ALL_NEONV8_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " -march=armv8-a -mfpu=neon-fp-armv8 ")
# -mfpu=fp-armv8 should suffice for FP16ARITH microkernels, if not for GCC emitting wrong directives for assembler
# -fno-math-errno for the vsqrth_f16 polyfill using sqrtf
# -ffinite-math-only for the vminnmh_f16/vmaxnmh_f16 polyfills using compare + select
SET_PROPERTY(SOURCE ${ALL_FP16ARITH_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " -march=armv8.2-a+fp16 -mfpu=neon-fp-armv8 -fno-math-errno -ffinite-math-only ")
SET_PROPERTY(SOURCE ${ALL_NEONDOTFP16ARITH_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " -march=armv8.2-a+dotprod+fp16 -mfpu=neon-fp-armv8 -fno-math-errno -ffinite-math-only ")
SET_PROPERTY(SOURCE ${ALL_NEONFP16ARITH_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " -march=armv8.2-a+fp16 -mfpu=neon-fp-armv8 ")
SET_PROPERTY(SOURCE ${ALL_NEONBF16_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " -march=armv8.2-a+bf16 -mfpu=neon-fp-armv8 ")
SET_PROPERTY(SOURCE ${ALL_NEONDOT_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " -march=armv8.2-a+dotprod -mfpu=neon-fp-armv8 ")
SET_PROPERTY(SOURCE ${ALL_AARCH32_ASM_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " -march=armv8.2-a+dotprod+fp16 -mfpu=neon-fp-armv8 ")
# Workground the neon detection bug in ARM v8
# Related links:
# https://github.com/android/ndk/issues/910
# https://reviews.llvm.org/D58477
IF(ANDROID_NDK_MAJOR AND ANDROID_NDK_MAJOR LESS 21)
SET_PROPERTY(SOURCE ${ALL_NEONV8_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " -mfloat-abi=softfp ")
SET_PROPERTY(SOURCE ${ALL_FP16ARITH_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " -mfloat-abi=softfp ")
SET_PROPERTY(SOURCE ${ALL_NEONDOTFP16ARITH_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " -mfloat-abi=softfp ")
SET_PROPERTY(SOURCE ${ALL_NEONFP16ARITH_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " -mfloat-abi=softfp ")
SET_PROPERTY(SOURCE ${ALL_NEONBF16_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " -mfloat-abi=softfp ")
SET_PROPERTY(SOURCE ${ALL_NEONDOT_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " -mfloat-abi=softfp ")
SET_PROPERTY(SOURCE ${ALL_AARCH32_ASM_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " -mfloat-abi=softfp ")
ENDIF()
ENDIF()
IF(XNNPACK_TARGET_PROCESSOR MATCHES "^arm64" AND NOT MSVC)
SET_PROPERTY(SOURCE ${ALL_FP16ARITH_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " -march=armv8.2-a+fp16 ")
SET_PROPERTY(SOURCE ${ALL_NEONFP16ARITH_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " -march=armv8.2-a+fp16 ")
SET_PROPERTY(SOURCE ${ALL_NEONDOTFP16ARITH_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " -march=armv8.2-a+dotprod+fp16 ")
SET_PROPERTY(SOURCE ${ALL_NEONFP16ARITH_AARCH64_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " -march=armv8.2-a+fp16 ")
SET_PROPERTY(SOURCE ${ALL_NEONBF16_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " -march=armv8.2-a+bf16 ")
SET_PROPERTY(SOURCE ${ALL_NEONDOT_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " -march=armv8.2-a+dotprod ")
SET_PROPERTY(SOURCE ${ALL_NEONDOT_AARCH64_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " -march=armv8.2-a+dotprod ")
SET_PROPERTY(SOURCE ${ALL_NEONI8MM_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " -march=armv8.2-a+i8mm+fp16 ")
SET_PROPERTY(SOURCE ${ALL_NEONSME_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " -march=armv8.2-a+sve+sve2 ")
SET_PROPERTY(SOURCE ${ALL_NEONSME2_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " -march=armv8.2-a+sve+sve2 ")
SET_PROPERTY(SOURCE ${ALL_AARCH64_ASM_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " -march=armv8.2-a+fp16+dotprod ")
ENDIF()
IF(XNNPACK_TARGET_PROCESSOR MATCHES "^ppc64")
IF(XNNPACK_ENABLE_VSX)
SET_PROPERTY(SOURCE ${ALL_PPC_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " -mvsx ")
ENDIF()
ENDIF()
IF(XNNPACK_TARGET_PROCESSOR MATCHES "^riscv")
IF(XNNPACK_ENABLE_RISCV_VECTOR)
SET_PROPERTY(SOURCE ${ALL_RVV_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " -march=rv64gcv -mabi=lp64d ")
ENDIF()
SET_PROPERTY(SOURCE ${ALL_RVVFP16ARITH_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " -march=rv64gc_zvfh -mabi=lp64d ")
ENDIF()
IF(XNNPACK_TARGET_PROCESSOR MATCHES "^x86(_64)?$")
IF(MSVC)
IF(XNNPACK_TARGET_PROCESSOR STREQUAL "x86" OR CMAKE_SIZEOF_VOID_P EQUAL 4)
SET_PROPERTY(SOURCE ${ALL_SSE_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " /arch:SSE ")
SET_PROPERTY(SOURCE ${ALL_SSE2_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " /arch:SSE2 ")
SET_PROPERTY(SOURCE ${ALL_SSSE3_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " /arch:SSE2 ")
SET_PROPERTY(SOURCE ${ALL_SSE41_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " /arch:SSE2 ")
ENDIF()
SET_PROPERTY(SOURCE ${ALL_AVX_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " /arch:AVX ")
SET_PROPERTY(SOURCE ${ALL_F16C_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " /arch:AVX ")
SET_PROPERTY(SOURCE ${ALL_FMA3_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " /arch:AVX ")
SET_PROPERTY(SOURCE ${ALL_AVX2_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " /arch:AVX2 ")
SET_PROPERTY(SOURCE ${ALL_AVX512F_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " /arch:AVX512 ")
SET_PROPERTY(SOURCE ${ALL_AVX512SKX_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " /arch:AVX512 ")
SET_PROPERTY(SOURCE ${ALL_AVX512VBMI_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " /arch:AVX512 ")
SET_PROPERTY(SOURCE ${ALL_AVX512VNNI_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " /arch:AVX512 ")
SET_PROPERTY(SOURCE ${ALL_AVXVNNI_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " /arch:AVX2 ")
SET_PROPERTY(SOURCE ${ALL_AVXVNNIINT8_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " /arch:AVX2 ")
SET_PROPERTY(SOURCE ${ALL_AVX256SKX_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " /arch:AVX512 ")
SET_PROPERTY(SOURCE ${ALL_AVX256VNNI_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " /arch:AVX512 ")
SET_PROPERTY(SOURCE ${ALL_AVX256VNNIGFNI_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " /arch:AVX512 ")
IF(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
SET_PROPERTY(SOURCE ${ALL_SSE_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " -clang:-msse -clang:-mno-sse2 ")
SET_PROPERTY(SOURCE ${ALL_SSE2_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " -clang:-msse2 -clang:-mno-sse3 ")
SET_PROPERTY(SOURCE ${ALL_SSSE3_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " -clang:-mssse3 -clang:-mno-sse4.1 ")
SET_PROPERTY(SOURCE ${ALL_SSE41_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " -clang:-msse4.1 -clang:-mno-sse4.2 ")
SET_PROPERTY(SOURCE ${ALL_AVX_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " -clang:-mavx -clang:-mno-avx2 -clang:-mno-fma -clang:-mno-f16c ")
SET_PROPERTY(SOURCE ${ALL_F16C_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " -clang:-mf16c -clang:-mno-avx2 -clang:-mno-fma ")
SET_PROPERTY(SOURCE ${ALL_FMA3_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " -clang:-mf16c -clang:-mfma -clang:-mno-avx2 ")
SET_PROPERTY(SOURCE ${ALL_AVX2_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " -clang:-mf16c -clang:-mfma -clang:-mavx2 ")
SET_PROPERTY(SOURCE ${ALL_AVXVNNI_MICROKERNEL_SRCS} APPEND_STRIDE PROPERTY COMPILE_FLAGS " -clang:-mf16c -clang:-mfma -clang:-mavx2 -clang:-mavxvnni ")
SET_PROPERTY(SOURCE ${ALL_AVXVNNIINT8_MICROKERNEL_SRCS} APPEND_STRIDE PROPERTY COMPILE_FLAGS " -clang:-mf16c -clang:-mfma -clang:-mavx2 -clang:-mavxvnniint8 ")
SET_PROPERTY(SOURCE ${ALL_AVX256SKX_MICROKERNEL_SRCS} APPEND_STRIDE PROPERTY COMPILE_FLAGS " -clang:-mf16c -clang:-mfma -clang:-mavx512f -clang:-mavx512cd -clang:-mavx512bw -clang:-mavx512dq -clang:-mavx512vl ")
SET_PROPERTY(SOURCE ${ALL_AVX256VNNI_MICROKERNEL_SRCS} APPEND_STRIDE PROPERTY COMPILE_FLAGS " -clang:-mf16c -clang:-mfma -clang:-mavx512f -clang:-mavx512cd -clang:-mavx512bw -clang:-mavx512dq -clang:-mavx512vl -clang:-mavx512vnni ")
SET_PROPERTY(SOURCE ${ALL_AVX256VNNIGFNI_MICROKERNEL_SRCS} APPEND_STRIDE PROPERTY COMPILE_FLAGS " -clang:-mf16c -clang:-mfma -clang:-mavx512f -clang:-mavx512cd -clang:-mavx512bw -clang:-mavx512dq -clang:-mavx512vl -clang:-mavx512vnni -clang:-mgfni ")
SET_PROPERTY(SOURCE ${ALL_AVX512F_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " -clang:-mavx512f ")
SET_PROPERTY(SOURCE ${ALL_AVX512SKX_MICROKERNEL_SRCS} APPEND_STRIDE PROPERTY COMPILE_FLAGS " -clang:-mf16c -clang:-mfma -clang:-mavx512f -clang:-mavx512cd -clang:-mavx512bw -clang:-mavx512dq -clang:-mavx512vl ")
SET_PROPERTY(SOURCE ${ALL_AVX512VBMI_MICROKERNEL_SRCS} APPEND_STRIDE PROPERTY COMPILE_FLAGS " -clang:-mf16c -clang:-mfma -clang:-mavx512f -clang:-mavx512cd -clang:-mavx512bw -clang:-mavx512dq -clang:-mavx512vl -clang:-mavx512vbmi ")
SET_PROPERTY(SOURCE ${ALL_AVX512VNNI_MICROKERNEL_SRCS} APPEND_STRIDE PROPERTY COMPILE_FLAGS " -clang:-mf16c -clang:-mfma -clang:-mavx512f -clang:-mavx512cd -clang:-mavx512bw -clang:-mavx512dq -clang:-mavx512vl -clang:-mavx512vnni ")
SET_PROPERTY(SOURCE ${ALL_AVX512VNNIGFNI_MICROKERNEL_SRCS} APPEND_STRIDE PROPERTY COMPILE_FLAGS " -clang:-mf16c -clang:-mfma -clang:-mavx512f -clang:-mavx512cd -clang:-mavx512bw -clang:-mavx512dq -clang:-mavx512vl -clang:-mavx512vnni -clang:-mgfni ")
SET_PROPERTY(SOURCE ${ALL_AVX512FP16_MICROKERNEL_SRCS} APPEND_STRIDE PROPERTY COMPILE_FLAGS " -clang:-mf16c -clang:-mfma -clang:-mavx512f -clang:-mavx512cd -clang:-mavx512bw -clang:-mavx512dq -clang:-mavx512vl -clang:-mavx512vnni -clang:-mgfni -clang:-mavx512fp16 ")
SET_PROPERTY(SOURCE ${ALL_AVX512AMX_MICROKERNEL_SRCS} APPEND_STRIDE PROPERTY COMPILE_FLAGS " -clang:-mf16c -clang:-mfma -clang:-mavx512f -clang:-mavx512cd -clang:-mavx512bw -clang:-mavx512dq -clang:-mavx512vl -clang:-mavx512vnni -clang:-mgfni -clang:-mamx-tile -clang:-mamx-int8 ")
ENDIF()
ELSE()
SET_PROPERTY(SOURCE ${ALL_SSE_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " -msse -mno-sse2 ")
SET_PROPERTY(SOURCE ${ALL_SSE2_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " -msse2 -mno-sse3 ")
SET_PROPERTY(SOURCE ${ALL_SSSE3_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " -mssse3 -mno-sse4.1 ")
SET_PROPERTY(SOURCE ${ALL_SSE41_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " -msse4.1 -mno-sse4.2 ")
SET_PROPERTY(SOURCE ${ALL_AVX_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " -mavx -mno-avx2 -mno-fma -mno-f16c ")
SET_PROPERTY(SOURCE ${ALL_F16C_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " -mf16c -mno-avx2 -mno-fma ")
SET_PROPERTY(SOURCE ${ALL_FMA3_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " -mf16c -mfma -mno-avx2 ")
SET_PROPERTY(SOURCE ${ALL_AVX2_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " -mf16c -mfma -mavx2 ")
SET_PROPERTY(SOURCE ${ALL_AVXVNNI_MICROKERNEL_SRCS} APPEND_STRIDE PROPERTY COMPILE_FLAGS " -mf16c -mfma -mavx2 -mavxvnni ")
SET_PROPERTY(SOURCE ${ALL_AVXVNNIINT8_MICROKERNEL_SRCS} APPEND_STRIDE PROPERTY COMPILE_FLAGS " -mf16c -mfma -mavx2 -mavxvnniint8 ")
SET_PROPERTY(SOURCE ${ALL_AVX256SKX_MICROKERNEL_SRCS} APPEND_STRIDE PROPERTY COMPILE_FLAGS " -mf16c -mfma -mavx512f -mavx512cd -mavx512bw -mavx512dq -mavx512vl ")
SET_PROPERTY(SOURCE ${ALL_AVX256VNNI_MICROKERNEL_SRCS} APPEND_STRIDE PROPERTY COMPILE_FLAGS " -mf16c -mfma -mavx512f -mavx512cd -mavx512bw -mavx512dq -mavx512vl -mavx512vnni ")
SET_PROPERTY(SOURCE ${ALL_AVX256VNNIGFNI_MICROKERNEL_SRCS} APPEND_STRIDE PROPERTY COMPILE_FLAGS " -mf16c -mfma -mavx512f -mavx512cd -mavx512bw -mavx512dq -mavx512vl -mavx512vnni -mgfni ")
SET_PROPERTY(SOURCE ${ALL_AVX512F_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " -mavx512f ")
SET_PROPERTY(SOURCE ${ALL_AVX512SKX_MICROKERNEL_SRCS} APPEND_STRIDE PROPERTY COMPILE_FLAGS " -mf16c -mfma -mavx512f -mavx512cd -mavx512bw -mavx512dq -mavx512vl ")
SET_PROPERTY(SOURCE ${ALL_AVX512VBMI_MICROKERNEL_SRCS} APPEND_STRIDE PROPERTY COMPILE_FLAGS " -mf16c -mfma -mavx512f -mavx512cd -mavx512bw -mavx512dq -mavx512vl -mavx512vbmi ")
SET_PROPERTY(SOURCE ${ALL_AVX512VNNI_MICROKERNEL_SRCS} APPEND_STRIDE PROPERTY COMPILE_FLAGS " -mf16c -mfma -mavx512f -mavx512cd -mavx512bw -mavx512dq -mavx512vl -mavx512vnni ")
SET_PROPERTY(SOURCE ${ALL_AVX512VNNIGFNI_MICROKERNEL_SRCS} APPEND_STRIDE PROPERTY COMPILE_FLAGS " -mf16c -mfma -mavx512f -mavx512cd -mavx512bw -mavx512dq -mavx512vl -mavx512vnni -mgfni ")
SET_PROPERTY(SOURCE ${ALL_AVX512FP16_MICROKERNEL_SRCS} APPEND_STRIDE PROPERTY COMPILE_FLAGS " -mf16c -mfma -mavx512f -mavx512cd -mavx512bw -mavx512dq -mavx512vl -mavx512vnni -mgfni -mavx512fp16 ")
SET_PROPERTY(SOURCE ${ALL_AVX512AMX_MICROKERNEL_SRCS} APPEND_STRIDE PROPERTY COMPILE_FLAGS " -mf16c -mfma -mavx512f -mavx512cd -mavx512bw -mavx512dq -mavx512vl -mavx512vnni -mgfni -mamx-tile -mamx-int8 ")
IF(MINGW OR CMAKE_SYSTEM_NAME MATCHES "^(CYGWIN|MSYS)$")
# Work-around for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65782
SET_PROPERTY(SOURCE ${ALL_AVX512F_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " -fno-asynchronous-unwind-tables ")
SET_PROPERTY(SOURCE ${ALL_AVX512SKX_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " -fno-asynchronous-unwind-tables ")
SET_PROPERTY(SOURCE ${ALL_AVX512VBMI_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " -fno-asynchronous-unwind-tables ")
SET_PROPERTY(SOURCE ${ALL_AVX512VNNI_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " -fno-asynchronous-unwind-tables ")
SET_PROPERTY(SOURCE ${ALL_AVXVNNI_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " -fno-asynchronous-unwind-tables ")
SET_PROPERTY(SOURCE ${ALL_AVXVNNIINT8_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " -fno-asynchronous-unwind-tables ")
SET_PROPERTY(SOURCE ${ALL_AVX256SKX_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " -fno-asynchronous-unwind-tables ")
SET_PROPERTY(SOURCE ${ALL_AVX256VNNI_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " -fno-asynchronous-unwind-tables ")
SET_PROPERTY(SOURCE ${ALL_AVX256VNNIGFNI_MICROKERNEL_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " -fno-asynchronous-unwind-tables ")
ENDIF()
ENDIF()
ENDIF()
# Set `XNN_LOG_LEVEL` transitively for all targets that depend on `logging`.
TARGET_COMPILE_DEFINITIONS(logging PUBLIC "XNN_LOG_LEVEL=$<$<CONFIG:Debug>:5>$<$<NOT:$<CONFIG:Debug>>:0>")
IF(MSVC)
# Even though MSVC has __restrict, it can't be used in all the same contexts as the C99 restrict keyword
TARGET_COMPILE_DEFINITIONS(xnnpack-base INTERFACE "restrict=")
IF(XNNPACK_BUILD_ALL_MICROKERNELS)
TARGET_COMPILE_OPTIONS(microkernels-all PRIVATE "$<$<NOT:$<CONFIG:Debug>>:/O2>")
ENDIF()
TARGET_COMPILE_OPTIONS(microkernels-prod PRIVATE "$<$<NOT:$<CONFIG:Debug>>:/O2>")
TARGET_COMPILE_OPTIONS(hardware-config PRIVATE "$<$<NOT:$<CONFIG:Debug>>:/O2>")
TARGET_COMPILE_OPTIONS(indirection PRIVATE "$<$<NOT:$<CONFIG:Debug>>:/O2>")
TARGET_COMPILE_OPTIONS(microparams-init PRIVATE "$<$<NOT:$<CONFIG:Debug>>:/O2>")
TARGET_COMPILE_OPTIONS(normalization PRIVATE "$<$<NOT:$<CONFIG:Debug>>:/O1>")
TARGET_COMPILE_OPTIONS(packing PRIVATE "$<$<NOT:$<CONFIG:Debug>>:/O2>")