1load( 2 ":xnnpack_src_defs.bzl", 3 "LOGGING_SRCS", 4 "OPERATOR_SRCS", 5 "SUBGRAPH_SRCS", 6 "TABLE_SRCS", 7 "XNNPACK_SRCS", 8 "get_xnnpack_headers", 9 "prod_srcs_for_arch_wrapper", 10) 11 12def define_xnnpack(): 13 # @lint-ignore BUCKLINT: native and fb_native are explicitly forbidden in fbcode. 14 native.cxx_library( 15 name = "interface", 16 headers = get_xnnpack_headers(), 17 header_namespace = "", 18 exported_headers = { 19 "xnnpack.h": "XNNPACK/include/xnnpack.h", 20 }, 21 compiler_flags = [ 22 "-Wno-error=missing-braces", # required since the SGX toolchain does not have this by default 23 ], 24 preferred_linkage = "static", 25 preprocessor_flags = [ 26 "-DXNN_LOG_LEVEL=0", 27 ], 28 visibility = ["PUBLIC"], 29 exported_deps = [ 30 ":pthreadpool", 31 ], 32 ) 33 34 # @lint-ignore BUCKLINT: native and fb_native are explicitly forbidden in fbcode. 35 native.cxx_library( 36 name = "operators", 37 srcs = OPERATOR_SRCS + [ 38 "XNNPACK/src/allocator.c", 39 "XNNPACK/src/cache.c", 40 "XNNPACK/src/indirection.c", 41 "XNNPACK/src/memory.c", 42 "XNNPACK/src/mutex.c", 43 "XNNPACK/src/normalization.c", 44 "XNNPACK/src/operator-utils.c", 45 "XNNPACK/src/packing.cc", 46 ], 47 headers = get_xnnpack_headers(), 48 header_namespace = "", 49 compiler_flags = [ 50 "-Wno-error=missing-braces", # required since the SGX toolchain does not have this by default 51 ], 52 preferred_linkage = "static", 53 preprocessor_flags = [ 54 "-DXNN_LOG_LEVEL=0", 55 "-DXNN_ENABLE_GEMM_M_SPECIALIZATION=0", 56 ], 57 exported_deps = [ 58 ":FP16", 59 ":FXdiv", 60 ":clog", 61 ":interface", 62 ":ukernels_f16c", 63 ":cpuinfo", 64 ], 65 ) 66 67 # @lint-ignore BUCKLINT: native and fb_native are explicitly forbidden in fbcode. 68 native.cxx_library( 69 name = "subgraph", 70 srcs = SUBGRAPH_SRCS, 71 compiler_flags = [ 72 "-Wno-error=missing-braces", # required since the SGX toolchain does not have this by default 73 ], 74 headers = get_xnnpack_headers(), 75 header_namespace = "", 76 preferred_linkage = "static", 77 preprocessor_flags = [ 78 "-DXNN_LOG_LEVEL=0", 79 "-DXNN_ENABLE_SPARSE=0", 80 "-DXNN_ENABLE_GEMM_M_SPECIALIZATION=0", 81 "-DXNN_ENABLE_MEMOPT", 82 ], 83 exported_deps = [ 84 ":FP16", 85 ":FXdiv", 86 ":clog", 87 ":interface", 88 ], 89 ) 90 91 # @lint-ignore BUCKLINT: native and fb_native are explicitly forbidden in fbcode. 92 native.cxx_library( 93 name = "tables", 94 srcs = TABLE_SRCS, 95 headers = get_xnnpack_headers(), 96 header_namespace = "", 97 compiler_flags = [ 98 "-Wno-error=missing-braces", # required since the SGX toolchain does not have this by default 99 ], 100 preferred_linkage = "static", 101 preprocessor_flags = [ 102 "-DXNN_LOG_LEVEL=0", 103 ], 104 exported_deps = [ 105 ":FP16", 106 ":FXdiv", 107 ":clog", 108 ":interface", 109 ], 110 ) 111 112 DEFAULT_DUMMY_SRC = [] 113 114 # @lint-ignore BUCKLINT: native and fb_native are explicitly forbidden in fbcode. 115 native.cxx_library( 116 name = "ukernels_scalar", 117 srcs = prod_srcs_for_arch_wrapper("scalar"), 118 headers = get_xnnpack_headers(), 119 header_namespace = "", 120 compiler_flags = [ 121 "-O3", 122 "-Wno-error=missing-braces", # required since the SGX toolchain does not have this by default 123 "-fno-fast-math", 124 "-fno-math-errno", 125 "-ffp-contract=off", 126 ], 127 preferred_linkage = "static", 128 preprocessor_flags = [ 129 "-DXNN_LOG_LEVEL=0", 130 ], 131 exported_deps = [ 132 ":FP16", 133 ":FXdiv", 134 ":interface", 135 ], 136 ) 137 138 ARMSIMD32_COMPILER_FLAGS = [ 139 "-marm", 140 "-march=armv6", 141 "-mfpu=vfp", 142 "-munaligned-access", 143 ] 144 145 # @lint-ignore BUCKLINT: native and fb_native are explicitly forbidden in fbcode. 146 native.cxx_library( 147 name = "ukernels_armsimd32", 148 srcs = select({ 149 "DEFAULT": DEFAULT_DUMMY_SRC, 150 "ovr_config//cpu:arm32": prod_srcs_for_arch_wrapper("armsimd32"), 151 }), 152 headers = get_xnnpack_headers(), 153 header_namespace = "", 154 compiler_flags = [ 155 "-Wno-error=missing-braces", # required since the SGX toolchain does not have this by default 156 "-fno-fast-math", 157 "-fno-math-errno", 158 ] + select({ 159 "DEFAULT": [], 160 "ovr_config//cpu:arm32": ARMSIMD32_COMPILER_FLAGS, 161 "ovr_config//cpu:x86_32": [], 162 "ovr_config//cpu:x86_64": [], 163 }), 164 preferred_linkage = "static", 165 preprocessor_flags = [ 166 "-DXNN_LOG_LEVEL=0", 167 ], 168 exported_deps = [ 169 ":FP16", 170 ":FXdiv", 171 ":interface", 172 ], 173 ) 174 175 FP16ARITH_COMPILER_FLAGS = [ 176 "-marm", 177 "-march=armv8.2-a+fp16", 178 # GCC emits wrong directives for assembler with -mfpu=fp-armv8 179 "-mfpu=neon-fp-armv8", 180 # For vsqrth_f16 polyfill using sqrtf 181 "-fno-math-errno", 182 # For vminh_f16/vmaxh_f16 polyfills using compare + select 183 "-ffinite-math-only", 184 ] 185 186 # @lint-ignore BUCKLINT: native and fb_native are explicitly forbidden in fbcode. 187 native.cxx_library( 188 name = "ukernels_fp16arith", 189 srcs = select({ 190 "DEFAULT": prod_srcs_for_arch_wrapper("fp16arith"), 191 "ovr_config//cpu:x86_32": DEFAULT_DUMMY_SRC, 192 "ovr_config//cpu:x86_64": DEFAULT_DUMMY_SRC, 193 }), 194 headers = get_xnnpack_headers(), 195 header_namespace = "", 196 compiler_flags = [ 197 "-Wno-error=missing-braces", # required since the SGX toolchain does not have this by default 198 "-fno-fast-math", 199 "-fno-math-errno", 200 ] + select({ 201 "DEFAULT": [], 202 "ovr_config//cpu:arm32": FP16ARITH_COMPILER_FLAGS, 203 "ovr_config//cpu:x86_32": [], 204 "ovr_config//cpu:x86_64": [], 205 }), 206 preferred_linkage = "static", 207 preprocessor_flags = [ 208 "-DXNN_LOG_LEVEL=0", 209 ], 210 exported_deps = [ 211 ":FP16", 212 ":FXdiv", 213 ":interface", 214 ], 215 ) 216 217 SSE_COMPILER_FLAGS = ["-msse"] 218 219 # @lint-ignore BUCKLINT: native and fb_native are explicitly forbidden in fbcode. 220 native.cxx_library( 221 name = "ukernels_sse", 222 srcs = select({ 223 "DEFAULT": prod_srcs_for_arch_wrapper("sse"), 224 "ovr_config//cpu:arm32": DEFAULT_DUMMY_SRC, 225 "ovr_config//cpu:arm64": DEFAULT_DUMMY_SRC, 226 }), 227 headers = get_xnnpack_headers(), 228 header_namespace = "", 229 compiler_flags = [ 230 "-O2", 231 "-Wno-error=missing-braces", # required since the SGX toolchain does not have this by default 232 ] + select({ 233 "DEFAULT": SSE_COMPILER_FLAGS, 234 "ovr_config//cpu:arm32": [], 235 "ovr_config//cpu:arm64": [], 236 }), 237 preferred_linkage = "static", 238 preprocessor_flags = [ 239 "-DXNN_LOG_LEVEL=0", 240 ], 241 exported_deps = [ 242 ":FP16", 243 ":interface", 244 ], 245 ) 246 247 SSE2_COMPILER_FLAGS = ["-msse2"] 248 249 # @lint-ignore BUCKLINT: native and fb_native are explicitly forbidden in fbcode. 250 native.cxx_library( 251 name = "ukernels_sse2", 252 srcs = select({ 253 "DEFAULT": prod_srcs_for_arch_wrapper("sse2"), 254 "ovr_config//cpu:arm32": DEFAULT_DUMMY_SRC, 255 "ovr_config//cpu:arm64": DEFAULT_DUMMY_SRC, 256 }), 257 headers = get_xnnpack_headers(), 258 header_namespace = "", 259 compiler_flags = [ 260 "-O2", 261 "-Wno-error=missing-braces", # required since the SGX toolchain does not have this by default 262 ] + select({ 263 "DEFAULT": SSE2_COMPILER_FLAGS, 264 "ovr_config//cpu:arm32": [], 265 "ovr_config//cpu:arm64": [], 266 }), 267 preferred_linkage = "static", 268 preprocessor_flags = [ 269 "-DXNN_LOG_LEVEL=0", 270 ], 271 exported_deps = [ 272 ":FP16", 273 ":interface", 274 ], 275 ) 276 277 SSE3_COMPILER_FLAGS = ["-mssse3"] 278 279 # @lint-ignore BUCKLINT: native and fb_native are explicitly forbidden in fbcode. 280 native.cxx_library( 281 name = "ukernels_ssse3", 282 srcs = select({ 283 "DEFAULT": prod_srcs_for_arch_wrapper("ssse3"), 284 "ovr_config//cpu:arm32": DEFAULT_DUMMY_SRC, 285 "ovr_config//cpu:arm64": DEFAULT_DUMMY_SRC, 286 }), 287 headers = get_xnnpack_headers(), 288 header_namespace = "", 289 compiler_flags = [ 290 "-O2", 291 "-Wno-error=missing-braces", # required since the SGX toolchain does not have this by default 292 ] + select({ 293 "DEFAULT": SSE3_COMPILER_FLAGS, 294 "ovr_config//cpu:arm32": [], 295 "ovr_config//cpu:arm64": [], 296 }), 297 preferred_linkage = "static", 298 preprocessor_flags = [ 299 "-DXNN_LOG_LEVEL=0", 300 ], 301 exported_deps = [ 302 ":FP16", 303 ":interface", 304 ], 305 ) 306 307 SSE41_COMPILER_FLAGS = ["-msse4.1"] 308 309 # @lint-ignore BUCKLINT: native and fb_native are explicitly forbidden in fbcode. 310 native.cxx_library( 311 name = "ukernels_sse41", 312 srcs = select({ 313 "DEFAULT": prod_srcs_for_arch_wrapper("sse41"), 314 "ovr_config//cpu:arm32": DEFAULT_DUMMY_SRC, 315 "ovr_config//cpu:arm64": DEFAULT_DUMMY_SRC, 316 }), 317 headers = get_xnnpack_headers(), 318 header_namespace = "", 319 compiler_flags = [ 320 "-O2", 321 "-Wno-error=missing-braces", # required since the SGX toolchain does not have this by default 322 ] + select({ 323 "DEFAULT": SSE41_COMPILER_FLAGS, 324 "ovr_config//cpu:arm32": [], 325 "ovr_config//cpu:arm64": [], 326 }), 327 preferred_linkage = "static", 328 preprocessor_flags = [ 329 "-DXNN_LOG_LEVEL=0", 330 ], 331 exported_deps = [ 332 ":FP16", 333 ":interface", 334 ], 335 ) 336 337 AVX_COMPILER_FLAGS = ["-mavx"] 338 339 # @lint-ignore BUCKLINT: native and fb_native are explicitly forbidden in fbcode. 340 native.cxx_library( 341 name = "ukernels_avx", 342 srcs = select({ 343 "DEFAULT": prod_srcs_for_arch_wrapper("avx"), 344 "ovr_config//cpu:arm32": DEFAULT_DUMMY_SRC, 345 "ovr_config//cpu:arm64": DEFAULT_DUMMY_SRC, 346 }), 347 headers = get_xnnpack_headers(), 348 header_namespace = "", 349 compiler_flags = [ 350 "-O2", 351 "-Wno-error=missing-braces", # required since the SGX toolchain does not have this by default 352 ] + select({ 353 "DEFAULT": AVX_COMPILER_FLAGS, 354 "ovr_config//cpu:arm32": [], 355 "ovr_config//cpu:arm64": [], 356 }), 357 preferred_linkage = "static", 358 preprocessor_flags = [ 359 "-DXNN_LOG_LEVEL=0", 360 ], 361 exported_deps = [ 362 ":FP16", 363 ":interface", 364 ], 365 ) 366 367 F16C_COMPILER_FLAGS = ["-mf16c"] 368 369 # @lint-ignore BUCKLINT: native and fb_native are explicitly forbidden in fbcode. 370 native.cxx_library( 371 name = "ukernels_f16c", 372 srcs = select({ 373 "DEFAULT": prod_srcs_for_arch_wrapper("f16c"), 374 "ovr_config//cpu:arm32": DEFAULT_DUMMY_SRC, 375 "ovr_config//cpu:arm64": DEFAULT_DUMMY_SRC, 376 }), 377 headers = get_xnnpack_headers(), 378 header_namespace = "", 379 compiler_flags = [ 380 "-O2", 381 "-Wno-error=missing-braces", # required since the SGX toolchain does not have this by default 382 ] + select({ 383 "DEFAULT": F16C_COMPILER_FLAGS, 384 "ovr_config//cpu:arm32": [], 385 "ovr_config//cpu:arm64": [], 386 }), 387 preferred_linkage = "static", 388 preprocessor_flags = [ 389 "-DXNN_LOG_LEVEL=0", 390 ], 391 exported_deps = [ 392 ":FP16", 393 ":interface", 394 ], 395 ) 396 397 FMA3_COMPILER_FLAGS = [ 398 "-mfma", 399 "-mf16c", 400 ] 401 402 # @lint-ignore BUCKLINT: native and fb_native are explicitly forbidden in fbcode. 403 native.cxx_library( 404 name = "ukernels_fma3", 405 srcs = select({ 406 "DEFAULT": prod_srcs_for_arch_wrapper("fma3"), 407 "ovr_config//cpu:arm32": DEFAULT_DUMMY_SRC, 408 "ovr_config//cpu:arm64": DEFAULT_DUMMY_SRC, 409 }), 410 headers = get_xnnpack_headers(), 411 header_namespace = "", 412 compiler_flags = [ 413 "-O2", 414 "-Wno-error=missing-braces", # required since the SGX toolchain does not have this by default 415 ] + select({ 416 "DEFAULT": FMA3_COMPILER_FLAGS, 417 "ovr_config//cpu:arm32": [], 418 "ovr_config//cpu:arm64": [], 419 }), 420 preferred_linkage = "static", 421 preprocessor_flags = [ 422 "-DXNN_LOG_LEVEL=0", 423 ], 424 exported_deps = [ 425 ":FP16", 426 ":interface", 427 ], 428 ) 429 430 AVX2_COMPILER_FLAGS = [ 431 "-mavx2", 432 "-mfma", 433 "-mf16c", 434 ] 435 436 # @lint-ignore BUCKLINT: native and fb_native are explicitly forbidden in fbcode. 437 native.cxx_library( 438 name = "ukernels_avx2", 439 srcs = select({ 440 "DEFAULT": prod_srcs_for_arch_wrapper("avx2"), 441 "ovr_config//cpu:arm32": DEFAULT_DUMMY_SRC, 442 "ovr_config//cpu:arm64": DEFAULT_DUMMY_SRC, 443 }), 444 headers = get_xnnpack_headers(), 445 header_namespace = "", 446 compiler_flags = [ 447 "-O2", 448 "-Wno-error=missing-braces", # required since the SGX toolchain does not have this by default 449 ] + select({ 450 "DEFAULT": AVX2_COMPILER_FLAGS, 451 "ovr_config//cpu:arm32": [], 452 "ovr_config//cpu:arm64": [], 453 }), 454 preferred_linkage = "static", 455 preprocessor_flags = [ 456 "-DXNN_LOG_LEVEL=0", 457 ], 458 exported_deps = [ 459 ":FP16", 460 ":interface", 461 ], 462 ) 463 464 AVX512F_COMPILER_FLAGS = ["-mavx512f"] 465 466 # @lint-ignore BUCKLINT: native and fb_native are explicitly forbidden in fbcode. 467 native.cxx_library( 468 name = "ukernels_avx512", 469 srcs = select({ 470 "DEFAULT": prod_srcs_for_arch_wrapper("avx512f"), 471 "ovr_config//cpu:arm32": DEFAULT_DUMMY_SRC, 472 "ovr_config//cpu:arm64": DEFAULT_DUMMY_SRC, 473 }), 474 headers = get_xnnpack_headers(), 475 header_namespace = "", 476 compiler_flags = [ 477 "-O2", 478 "-Wno-error=missing-braces", # required since the SGX toolchain does not have this by default 479 ] + select({ 480 "DEFAULT": AVX512F_COMPILER_FLAGS, 481 "ovr_config//cpu:arm32": [], 482 "ovr_config//cpu:arm64": [], 483 }), 484 preferred_linkage = "static", 485 preprocessor_flags = [ 486 "-DXNN_LOG_LEVEL=0", 487 ], 488 exported_deps = [ 489 ":FP16", 490 ":interface", 491 ], 492 ) 493 494 AVX512SKX_COMPILER_FLAGS = [ 495 "-mavx512f", 496 "-mavx512cd", 497 "-mavx512bw", 498 "-mavx512dq", 499 "-mavx512vl", 500 ] 501 502 # @lint-ignore BUCKLINT: native and fb_native are explicitly forbidden in fbcode. 503 native.cxx_library( 504 name = "ukernels_avx512skx", 505 srcs = select({ 506 "DEFAULT": prod_srcs_for_arch_wrapper("avx512skx"), 507 "ovr_config//cpu:arm32": DEFAULT_DUMMY_SRC, 508 "ovr_config//cpu:arm64": DEFAULT_DUMMY_SRC, 509 }), 510 headers = get_xnnpack_headers(), 511 header_namespace = "", 512 compiler_flags = [ 513 "-O2", 514 "-Wno-error=missing-braces", # required since the SGX toolchain does not have this by default 515 ] + select({ 516 "DEFAULT": AVX512SKX_COMPILER_FLAGS, 517 "ovr_config//cpu:arm32": [], 518 "ovr_config//cpu:arm64": [], 519 }), 520 preferred_linkage = "static", 521 preprocessor_flags = [ 522 "-DXNN_LOG_LEVEL=0", 523 ], 524 exported_deps = [ 525 ":FP16", 526 ":interface", 527 ], 528 ) 529 530 NEON_COMPILER_FLAGS = [ 531 "-march=armv7-a", 532 "-fpu=neon", 533 "-mfloat-abi=softfp", 534 ] 535 536 # @lint-ignore BUCKLINT: native and fb_native are explicitly forbidden in fbcode. 537 native.cxx_library( 538 name = "ukernels_asm", 539 srcs = select({ 540 "DEFAULT": DEFAULT_DUMMY_SRC, 541 "ovr_config//cpu:arm32": prod_srcs_for_arch_wrapper("aarch32"), 542 "ovr_config//cpu:arm64": prod_srcs_for_arch_wrapper("aarch64"), 543 }), 544 headers = get_xnnpack_headers(), 545 header_namespace = "", 546 platform_compiler_flags = [ 547 ( 548 "(aarch64|arm64)", 549 [ 550 "-march=armv8.2-a+fp16+dotprod", 551 ], 552 ), 553 ( 554 "(aarch32|arm32)", 555 [ 556 "-marm", 557 "-march=armv8.2-a+dotprod", 558 "-mfpu=neon-fp-armv8", 559 ], 560 ), 561 ], 562 compiler_flags = [ 563 "-O2", 564 ], 565 preferred_linkage = "static", 566 preprocessor_flags = [ 567 "-DXNN_LOG_LEVEL=0", 568 ], 569 exported_deps = [ 570 ":FP16", 571 ":interface", 572 ], 573 ) 574 575 # @lint-ignore BUCKLINT: native and fb_native are explicitly forbidden in fbcode. 576 native.cxx_library( 577 name = "ukernels_neon", 578 srcs = select({ 579 "DEFAULT": prod_srcs_for_arch_wrapper("neon"), 580 "ovr_config//cpu:x86_32": DEFAULT_DUMMY_SRC, 581 "ovr_config//cpu:x86_64": DEFAULT_DUMMY_SRC, 582 }), 583 headers = get_xnnpack_headers(), 584 header_namespace = "", 585 compiler_flags = [ 586 "-O2", 587 "-Wno-error=missing-braces", # required since the SGX toolchain does not have this by default 588 ] + select({ 589 "DEFAULT": [], 590 "ovr_config//cpu:arm32": NEON_COMPILER_FLAGS, 591 "ovr_config//cpu:x86_32": [], 592 "ovr_config//cpu:x86_64": [], 593 }), 594 preferred_linkage = "static", 595 preprocessor_flags = [ 596 "-DXNN_LOG_LEVEL=0", 597 ], 598 exported_deps = [ 599 ":FP16", 600 ":interface", 601 ], 602 ) 603 604 AVX512VBMI_COMPILER_FLAGS = ["-mavx512vbmi"] 605 606 # @lint-ignore BUCKLINT: native and fb_native are explicitly forbidden in fbcode. 607 native.cxx_library( 608 name = "ukernels_avx512vbmi", 609 srcs = select({ 610 "DEFAULT": prod_srcs_for_arch_wrapper("avx512vbmi"), 611 "ovr_config//cpu:arm32": DEFAULT_DUMMY_SRC, 612 "ovr_config//cpu:arm64": DEFAULT_DUMMY_SRC, 613 }), 614 headers = get_xnnpack_headers(), 615 header_namespace = "", 616 compiler_flags = [ 617 "-O2", 618 "-Wno-error=missing-braces", # required since the SGX toolchain does not have this by default 619 ] + select({ 620 "DEFAULT": AVX512VBMI_COMPILER_FLAGS, 621 "ovr_config//cpu:arm32": [], 622 "ovr_config//cpu:arm64": [], 623 }), 624 preferred_linkage = "static", 625 preprocessor_flags = [ 626 "-DXNN_LOG_LEVEL=0", 627 ], 628 exported_deps = [ 629 ":FP16", 630 ":interface", 631 ], 632 ) 633 634 NEON64_AARCH64_COMPILER_FLAGS = [] 635 636 # @lint-ignore BUCKLINT: native and fb_native are explicitly forbidden in fbcode. 637 native.cxx_library( 638 name = "ukernels_neon_aarch64", 639 srcs = select({ 640 "DEFAULT": prod_srcs_for_arch_wrapper("neon_aarch64"), 641 "ovr_config//cpu:arm32": DEFAULT_DUMMY_SRC, 642 "ovr_config//cpu:x86_32": DEFAULT_DUMMY_SRC, 643 "ovr_config//cpu:x86_64": DEFAULT_DUMMY_SRC, 644 }), 645 headers = get_xnnpack_headers(), 646 header_namespace = "", 647 compiler_flags = [ 648 "-O2", 649 "-Wno-error=missing-braces", # required since the SGX toolchain does not have this by default 650 ] + select({ 651 "DEFAULT": NEON64_AARCH64_COMPILER_FLAGS, 652 "ovr_config//cpu:arm32": [], 653 "ovr_config//cpu:x86_32": [], 654 "ovr_config//cpu:x86_64": [], 655 }), 656 preferred_linkage = "static", 657 preprocessor_flags = [ 658 "-DXNN_LOG_LEVEL=0", 659 ], 660 exported_deps = [ 661 ":FP16", 662 ":interface", 663 ], 664 ) 665 666 NEON_FP16_COMPILER_FLAGS = ["-mfpu=neon-fp16"] 667 668 # @lint-ignore BUCKLINT: native and fb_native are explicitly forbidden in fbcode. 669 native.cxx_library( 670 name = "ukernels_neon_fp16", 671 srcs = select({ 672 "DEFAULT": prod_srcs_for_arch_wrapper("neonfp16"), 673 "ovr_config//cpu:x86_32": DEFAULT_DUMMY_SRC, 674 "ovr_config//cpu:x86_64": DEFAULT_DUMMY_SRC, 675 }), 676 headers = get_xnnpack_headers(), 677 header_namespace = "", 678 compiler_flags = [ 679 "-O2", 680 "-Wno-error=missing-braces", # required since the SGX toolchain does not have this by default 681 ] + select({ 682 "DEFAULT": [], 683 "ovr_config//cpu:arm32": NEON_FP16_COMPILER_FLAGS, 684 "ovr_config//cpu:x86_32": [], 685 "ovr_config//cpu:x86_64": [], 686 }), 687 preferred_linkage = "static", 688 preprocessor_flags = [ 689 "-DXNN_LOG_LEVEL=0", 690 ], 691 exported_deps = [ 692 ":interface", 693 ":FP16", 694 ], 695 ) 696 697 NEON32_FMA_COMPILER_FLAGS = ["-mfpu=neon-vfp4"] 698 NEON64_FMA_COMPILER_FLAGS = [ 699 "-march=armv8-a", 700 ] 701 702 # @lint-ignore BUCKLINT: native and fb_native are explicitly forbidden in fbcode. 703 native.cxx_library( 704 name = "ukernels_neon_fma", 705 srcs = select({ 706 "DEFAULT": DEFAULT_DUMMY_SRC, 707 "ovr_config//cpu:arm32": prod_srcs_for_arch_wrapper("neonfma"), 708 "ovr_config//cpu:arm64": prod_srcs_for_arch_wrapper("neonfma") + prod_srcs_for_arch_wrapper("neonfma_aarch64"), 709 "ovr_config//cpu:x86_32": DEFAULT_DUMMY_SRC, 710 "ovr_config//cpu:x86_64": DEFAULT_DUMMY_SRC, 711 }), 712 headers = get_xnnpack_headers(), 713 header_namespace = "", 714 compiler_flags = [ 715 "-O2", 716 "-Wno-error=missing-braces", # required since the SGX toolchain does not have this by default 717 ] + select({ 718 "DEFAULT": [], 719 "ovr_config//cpu:arm32": NEON32_FMA_COMPILER_FLAGS, 720 "ovr_config//cpu:arm64": NEON64_FMA_COMPILER_FLAGS, 721 "ovr_config//cpu:x86_32": [], 722 "ovr_config//cpu:x86_64": [], 723 }), 724 preferred_linkage = "static", 725 preprocessor_flags = [ 726 "-DXNN_LOG_LEVEL=0", 727 ], 728 exported_deps = [ 729 ":FP16", 730 ":interface", 731 ], 732 ) 733 734 NEON64_V8_COMPILER_FLAGS = [ 735 "-march=armv8-a", 736 ] 737 738 NEON32_V8_COMPILER_FLAGS = [ 739 "-march=armv8-a", 740 "-mfpu=neon-fp-armv8", 741 "-mfloat-abi=softfp", 742 ] 743 744 # @lint-ignore BUCKLINT: native and fb_native are explicitly forbidden in fbcode. 745 native.cxx_library( 746 name = "ukernels_neon_v8", 747 srcs = select({ 748 "DEFAULT": prod_srcs_for_arch_wrapper("neonv8"), 749 "ovr_config//cpu:x86_32": DEFAULT_DUMMY_SRC, 750 "ovr_config//cpu:x86_64": DEFAULT_DUMMY_SRC, 751 }), 752 headers = get_xnnpack_headers(), 753 header_namespace = "", 754 compiler_flags = [ 755 "-O2", 756 "-Wno-error=missing-braces", # required since the SGX toolchain does not have this by default 757 ] + select({ 758 "DEFAULT": NEON64_V8_COMPILER_FLAGS, 759 "ovr_config//cpu:arm32": NEON32_V8_COMPILER_FLAGS, 760 "ovr_config//cpu:x86_32": [], 761 "ovr_config//cpu:x86_64": [], 762 }), 763 preferred_linkage = "static", 764 preprocessor_flags = [ 765 "-DXNN_LOG_LEVEL=0", 766 ], 767 exported_deps = [ 768 ":FP16", 769 ":interface", 770 ], 771 ) 772 773 NEON64_FP16ARITH_COMPILER_FLAGS = ["-march=armv8.2-a+fp16"] 774 NEON32_FP16ARITH_COMPILER_FLAGS = [ 775 "-marm", 776 "-march=armv8.2-a+fp16", 777 "-mfpu=neon-fp-armv8", 778 ] 779 780 # @lint-ignore BUCKLINT: native and fb_native are explicitly forbidden in fbcode. 781 native.cxx_library( 782 name = "ukernels_neon_fp16arith", 783 srcs = select({ 784 "DEFAULT": DEFAULT_DUMMY_SRC, 785 "ovr_config//cpu:arm32": prod_srcs_for_arch_wrapper("neonfp16arith"), 786 "ovr_config//cpu:arm64": prod_srcs_for_arch_wrapper("neonfp16arith") + prod_srcs_for_arch_wrapper("neonfp16arith_aarch64"), 787 }), 788 headers = get_xnnpack_headers(), 789 header_namespace = "", 790 compiler_flags = [ 791 "-O2", 792 "-Wno-error=missing-braces", # required since the SGX toolchain does not have this by default 793 ] + select({ 794 "DEFAULT": NEON64_FP16ARITH_COMPILER_FLAGS, 795 "ovr_config//cpu:arm32": NEON32_FP16ARITH_COMPILER_FLAGS, 796 "ovr_config//cpu:arm64": NEON64_FP16ARITH_COMPILER_FLAGS, 797 "ovr_config//cpu:x86_32": [], 798 "ovr_config//cpu:x86_64": [], 799 }), 800 preferred_linkage = "static", 801 preprocessor_flags = [ 802 "-DXNN_LOG_LEVEL=0", 803 ], 804 exported_deps = [ 805 ":FP16", 806 ":interface", 807 ], 808 ) 809 810 NEONDOTFP16ARITH_COMPILER_FLAGS = [ 811 "-marm", 812 "-march=armv8.2-a+dotprod+fp16", 813 "-mfpu=neon-fp-armv8", 814 ] 815 816 NEONDOTFP16ARITH_AARCH64_COMPILER_FLAGS = [ 817 "-march=armv8.2-a+dotprod+fp16", 818 ] 819 820 # @lint-ignore BUCKLINT: native and fb_native are explicitly forbidden in fbcode. 821 native.cxx_library( 822 name = "ukernels_neondotfp16arith", 823 srcs = select({ 824 "DEFAULT": DEFAULT_DUMMY_SRC, 825 "ovr_config//cpu:arm32": prod_srcs_for_arch_wrapper("neondotfp16arith"), 826 "ovr_config//cpu:arm64": prod_srcs_for_arch_wrapper("neondotfp16arith") + prod_srcs_for_arch_wrapper("neondotfp16arith_aarch64"), 827 }), 828 headers = get_xnnpack_headers(), 829 header_namespace = "", 830 compiler_flags = [ 831 "-O2", 832 "-Wno-error=missing-braces", # required since the SGX toolchain does not have this by default 833 ] + select({ 834 "ovr_config//cpu:arm32": NEONDOTFP16ARITH_COMPILER_FLAGS, 835 "ovr_config//cpu:arm64": NEONDOTFP16ARITH_AARCH64_COMPILER_FLAGS, 836 }), 837 preferred_linkage = "static", 838 preprocessor_flags = [ 839 "-DXNN_LOG_LEVEL=0", 840 ], 841 exported_deps = [ 842 ":FP16", 843 ":interface", 844 ], 845 ) 846 847 NEON64_DOT_COMPILER_FLAGS = ["-march=armv8.2-a+dotprod"] 848 849 NEON32_DOT_COMPILER_FLAGS = [ 850 "-march=armv8.2-a+dotprod", 851 "-mfpu=neon-fp-armv8", 852 "-mfloat-abi=softfp", 853 ] 854 855 # @lint-ignore BUCKLINT: native and fb_native are explicitly forbidden in fbcode. 856 native.cxx_library( 857 name = "ukernels_neon_dot", 858 srcs = select({ 859 "DEFAULT": DEFAULT_DUMMY_SRC, 860 "ovr_config//cpu:arm32": prod_srcs_for_arch_wrapper("neondot"), 861 "ovr_config//cpu:arm64": prod_srcs_for_arch_wrapper("neondot") + prod_srcs_for_arch_wrapper("neondot_aarch64"), 862 "ovr_config//cpu:x86_32": DEFAULT_DUMMY_SRC, 863 "ovr_config//cpu:x86_64": DEFAULT_DUMMY_SRC, 864 }), 865 headers = get_xnnpack_headers(), 866 header_namespace = "", 867 compiler_flags = [ 868 "-O2", 869 "-Wno-error=missing-braces", # required since the SGX toolchain does not have this by default 870 ] + select({ 871 "DEFAULT": [], 872 "ovr_config//cpu:arm32": NEON32_DOT_COMPILER_FLAGS, 873 "ovr_config//cpu:arm64": NEON64_DOT_COMPILER_FLAGS, 874 "ovr_config//cpu:x86_32": [], 875 "ovr_config//cpu:x86_64": [], 876 }), 877 preferred_linkage = "static", 878 preprocessor_flags = [ 879 "-DXNN_LOG_LEVEL=0", 880 ], 881 exported_deps = [ 882 ":FP16", 883 ":interface", 884 ], 885 ) 886 887 # @lint-ignore BUCKLINT: native and fb_native are explicitly forbidden in fbcode. 888 NEON32_I8MM_COMPILER_FLAGS = [ 889 "-marm", 890 "-march=armv8.2-a+i8mm+fp16", 891 "-mfpu=neon-fp-armv8", 892 ] 893 894 NEON64_I8MM_COMPILER_FLAGS = [ 895 "-march=armv8.2-a+i8mm+fp16", 896 ] 897 898 # @lint-ignore BUCKLINT: native and fb_native are explicitly forbidden in fbcode. 899 native.cxx_library( 900 name = "ukernels_neon_i8mm", 901 srcs = select({ 902 "DEFAULT": prod_srcs_for_arch_wrapper("neoni8mm"), 903 "ovr_config//cpu:x86_32": DEFAULT_DUMMY_SRC, 904 "ovr_config//cpu:x86_64": DEFAULT_DUMMY_SRC, 905 }), 906 headers = get_xnnpack_headers(), 907 header_namespace = "", 908 compiler_flags = [ 909 "-O2", 910 "-Wno-error=missing-braces", # required since the SGX toolchain does not have this by default 911 ] + select({ 912 "DEFAULT": NEON64_I8MM_COMPILER_FLAGS, 913 "ovr_config//cpu:arm32": NEON32_I8MM_COMPILER_FLAGS, 914 "ovr_config//cpu:x86_32": [], 915 "ovr_config//cpu:x86_64": [], 916 }), 917 preferred_linkage = "static", 918 preprocessor_flags = [ 919 "-DXNN_LOG_LEVEL=0", 920 ], 921 exported_deps = [ 922 ":FP16", 923 ":interface", 924 ], 925 ) 926 927 AVX512VNNI_COMPILER_FLAGS = [ 928 "-mavx512f", 929 "-mavx512cd", 930 "-mavx512bw", 931 "-mavx512dq", 932 "-mavx512vl", 933 "-mavx512vnni", 934 ] 935 936 # @lint-ignore BUCKLINT: native and fb_native are explicitly forbidden in fbcode. 937 native.cxx_library( 938 name = "ukernels_avx512vnni", 939 srcs = select({ 940 "DEFAULT": prod_srcs_for_arch_wrapper("avx512vnni"), 941 "ovr_config//cpu:arm32": DEFAULT_DUMMY_SRC, 942 "ovr_config//cpu:arm64": DEFAULT_DUMMY_SRC, 943 }), 944 headers = get_xnnpack_headers(), 945 header_namespace = "", 946 compiler_flags = [ 947 "-O2", 948 "-Wno-error=missing-braces", # required since the SGX toolchain does not have this by default 949 ] + select({ 950 "DEFAULT": AVX512VNNI_COMPILER_FLAGS, 951 "ovr_config//cpu:arm32": [], 952 "ovr_config//cpu:arm64": [], 953 }), 954 preferred_linkage = "static", 955 preprocessor_flags = [ 956 "-DXNN_LOG_LEVEL=0", 957 ], 958 exported_deps = [ 959 ":FP16", 960 ":interface", 961 ], 962 ) 963 964 AVX512VNNIGFNI_COMPILER_FLAGS = AVX512VNNI_COMPILER_FLAGS + [ 965 "-mgfni", 966 ] 967 968 # @lint-ignore BUCKLINT: native and fb_native are explicitly forbidden in fbcode. 969 native.cxx_library( 970 name = "ukernels_avx512vnnigfni", 971 srcs = select({ 972 "DEFAULT": prod_srcs_for_arch_wrapper("avx512vnnifgni"), 973 "ovr_config//cpu:arm32": DEFAULT_DUMMY_SRC, 974 "ovr_config//cpu:arm64": DEFAULT_DUMMY_SRC, 975 }), 976 headers = get_xnnpack_headers(), 977 header_namespace = "", 978 compiler_flags = [ 979 "-O2", 980 "-Wno-error=missing-braces", # required since the SGX toolchain does not have this by default 981 ] + select({ 982 "DEFAULT": AVX512VNNIGFNI_COMPILER_FLAGS, 983 "ovr_config//cpu:arm32": [], 984 "ovr_config//cpu:arm64": [], 985 }), 986 preferred_linkage = "static", 987 preprocessor_flags = [ 988 "-DXNN_LOG_LEVEL=0", 989 ], 990 exported_deps = [ 991 ":FP16", 992 ":interface", 993 ], 994 ) 995 996 AVXVNNI_COMPILER_FLAGS = [ 997 "-mavx2", 998 "-mavxvnni", 999 "-mf16c", 1000 "-mfma", 1001 ] 1002 1003 # @lint-ignore BUCKLINT: native and fb_native are explicitly forbidden in fbcode. 1004 native.cxx_library( 1005 name = "ukernels_avxvnni", 1006 srcs = select({ 1007 "DEFAULT": prod_srcs_for_arch_wrapper("avxvnni"), 1008 "ovr_config//cpu:arm32": DEFAULT_DUMMY_SRC, 1009 "ovr_config//cpu:arm64": DEFAULT_DUMMY_SRC, 1010 }), 1011 headers = get_xnnpack_headers(), 1012 header_namespace = "", 1013 compiler_flags = [ 1014 "-O2", 1015 "-Wno-error=missing-braces", # required since the SGX toolchain does not have this by default 1016 ] + select({ 1017 "DEFAULT": AVXVNNI_COMPILER_FLAGS, 1018 "ovr_config//cpu:arm32": [], 1019 "ovr_config//cpu:arm64": [], 1020 }), 1021 preferred_linkage = "static", 1022 preprocessor_flags = [ 1023 "-DXNN_LOG_LEVEL=0", 1024 ], 1025 exported_deps = [ 1026 ":FP16", 1027 ":interface", 1028 ], 1029 ) 1030 1031 COMMON_XNNPACK_DEPS = [ 1032 ":operators", 1033 ":subgraph", 1034 ":tables", 1035 ":ukernels_scalar", 1036 ] 1037 1038 X86_64_XNNPACK_DEPS = [ 1039 ":ukernels_avx", 1040 ":ukernels_avx2", 1041 ":ukernels_avx512", 1042 ":ukernels_avx512skx", 1043 ":ukernels_f16c", 1044 ":ukernels_fma3", 1045 ":ukernels_sse", 1046 ":ukernels_sse2", 1047 ":ukernels_sse41", 1048 ":ukernels_ssse3", 1049 ":ukernels_avx512vbmi", 1050 ":ukernels_avx512vnnigfni", 1051 ":ukernels_avx512vnni", 1052 ":ukernels_avxvnni", 1053 ] 1054 1055 ARM_XNNPACK_DEPS = [ 1056 ":ukernels_armsimd32", 1057 ":ukernels_fp16arith", 1058 ":ukernels_asm", 1059 ":ukernels_neon", 1060 ":ukernels_neon_aarch64", 1061 ":ukernels_neon_fp16", 1062 ":ukernels_neon_fma", 1063 ":ukernels_neon_v8", 1064 ":ukernels_neon_fp16arith", 1065 ":ukernels_neon_dot", 1066 ":ukernels_neon_i8mm", 1067 ":ukernels_neondotfp16arith", 1068 ] 1069 1070 # @lint-ignore BUCKLINT: native and fb_native are explicitly forbidden in fbcode. 1071 native.cxx_library( 1072 name = "XNNPACK", 1073 srcs = XNNPACK_SRCS + LOGGING_SRCS + [ 1074 "XNNPACK/src/init.c", 1075 "XNNPACK/src/params.c", 1076 "XNNPACK/src/configs/hardware-config.c", 1077 "XNNPACK/src/microparams-init.c", 1078 "XNNPACK/src/microkernel-utils.c", 1079 ], 1080 headers = get_xnnpack_headers(), 1081 exported_headers = { 1082 "xnnpack.h": "XNNPACK/include/xnnpack.h", 1083 }, 1084 header_namespace = "", 1085 compiler_flags = [ 1086 "-Wno-error=missing-braces", # required since the SGX toolchain does not have this by default 1087 ], 1088 preferred_linkage = "static", 1089 preprocessor_flags = [ 1090 "-DXNN_LOG_LEVEL=0", 1091 "-DXNN_ENABLE_MEMOPT", 1092 "-DXNN_ENABLE_SPARSE=0", 1093 "-DXNN_ENABLE_ASSEMBLY", 1094 "-DXNN_ENABLE_GEMM_M_SPECIALIZATION", 1095 "-DXNN_ENABLE_ARM_DOTPROD", 1096 "-DXNN_ENABLE_CPUINFO", 1097 # "-DXNN_ENABLE_DWCONV_MULTIPLASS=1", 1098 "-DXNN_ENABLE_ARM_I8MM=1", 1099 "-DXNN_ENABLE_ARM_FP16_VECTOR=1", 1100 ], 1101 visibility = ["PUBLIC"], 1102 exported_deps = COMMON_XNNPACK_DEPS + [ 1103 ":FP16", 1104 ":pthreadpool", 1105 ":interface", 1106 ":cpuinfo", 1107 ] + select({ 1108 "DEFAULT": X86_64_XNNPACK_DEPS, 1109 "ovr_config//cpu:arm32": ARM_XNNPACK_DEPS, 1110 "ovr_config//cpu:arm64": ARM_XNNPACK_DEPS, 1111 }), 1112 ) 1113