|
1 | 1 | load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime", "is_arvr_mode")
|
2 | 2 |
|
3 |
| -def get_sleef_preprocessor_flags(): |
| 3 | +def get_preprocessor_flags(is_fbcode): |
| 4 | + flags = ["-DSTANDALONE_TORCH_HEADER"] |
4 | 5 | if runtime.is_oss:
|
5 |
| - return [] |
6 |
| - return ["-DAT_BUILD_ARM_VEC256_WITH_SLEEF"] |
| 6 | + return flags |
| 7 | + arm64_flags = [ |
| 8 | + "-DCPU_CAPABILITY_DEFAULT", |
| 9 | + ] |
| 10 | + if is_fbcode: |
| 11 | + # TODO: enable Sleef in xplat? |
| 12 | + arm64_flags = arm64_flags + ["-DAT_BUILD_ARM_VEC256_WITH_SLEEF"] |
| 13 | + |
| 14 | + x86_avx2_flags = [ |
| 15 | + "-DCPU_CAPABILITY_AVX2", |
| 16 | + "-DHAVE_AVX2_CPU_DEFINITION", |
| 17 | + ] |
| 18 | + default_flags = [ |
| 19 | + "-DCPU_CAPABILITY_DEFAULT", |
| 20 | + ] |
| 21 | + fbcode_flags = select({ |
| 22 | + "ovr_config//cpu:x86_64": x86_avx2_flags, |
| 23 | + "ovr_config//cpu:arm64": arm64_flags, |
| 24 | + "DEFAULT": default_flags, |
| 25 | + }) |
| 26 | + non_fbcode_flags = select({ |
| 27 | + "ovr_config//cpu/x86:avx2": x86_avx2_flags, |
| 28 | + "ovr_config//cpu:arm64": arm64_flags, |
| 29 | + "DEFAULT": default_flags, |
| 30 | + }) |
| 31 | + return flags + ["-DET_USE_PYTORCH_HEADERS"] + (fbcode_flags if is_fbcode else non_fbcode_flags) |
7 | 32 |
|
| 33 | +def get_sleef_deps(): |
| 34 | + if runtime.is_oss: |
| 35 | + return [] |
| 36 | + return select({ |
| 37 | + "DEFAULT": [], |
| 38 | + "ovr_config//cpu:x86_64": [ |
| 39 | + "fbsource//third-party/sleef:sleef", |
| 40 | + ], |
| 41 | + "ovr_config//cpu:arm64": [ |
| 42 | + "fbsource//third-party/sleef:sleef", |
| 43 | + ], |
| 44 | + }) |
8 | 45 |
|
9 | 46 | def define_common_targets():
|
10 | 47 | """Defines targets that should be shared between fbcode and xplat.
|
@@ -54,42 +91,30 @@ def define_common_targets():
|
54 | 91 | name = "aten_headers_for_executorch",
|
55 | 92 | srcs = [],
|
56 | 93 | visibility = ["//executorch/kernels/optimized/...", "@EXECUTORCH_CLIENTS"],
|
| 94 | + # select() on ovr_config//runtime:fbcode does not work |
| 95 | + # properly in all cases. I have seen |
| 96 | + # //xplat/executorch/runtime/core/portable_type/c10/c10:aten_headers_for_executorch |
| 97 | + # pass such a select in (at least) arvr mode. Going back to |
| 98 | + # fbcode_exported_deps accordingly. |
57 | 99 | exported_deps = select({
|
58 | 100 | "DEFAULT": [],
|
59 | 101 | "ovr_config//cpu:arm64": [
|
60 | 102 | "fbsource//third-party/sleef:sleef",
|
61 | 103 | ] if not runtime.is_oss else [],
|
62 |
| - # fbsource//third-party/sleef:sleef currently fails to |
63 |
| - # link with missing symbols, hence the fbcode-specific dep below. |
64 | 104 | }),
|
| 105 | + xplat_exported_deps = [ |
| 106 | + "//xplat/caffe2:aten_header", |
| 107 | + "//xplat/caffe2/c10:c10_headers", |
| 108 | + ("//xplat/caffe2:ovrsource_aten_Config.h" |
| 109 | + if is_arvr_mode() else "//xplat/caffe2:generated_aten_config_header"), |
| 110 | + ], # + get_sleef_deps(), # TODO: enable Sleef in xplat? |
65 | 111 | fbcode_exported_deps = ([
|
66 | 112 | "//caffe2:aten-headers-cpu",
|
67 | 113 | "//caffe2:generated-config-header",
|
68 | 114 | "//caffe2/c10:c10_headers",
|
69 |
| - ] + select({ |
70 |
| - "DEFAULT": [], |
71 |
| - "ovr_config//cpu:x86_64": [ |
72 |
| - "third-party//sleef:sleef", |
73 |
| - ] |
74 |
| - })) if not runtime.is_oss else [], |
75 |
| - fbcode_exported_preprocessor_flags = [ |
76 |
| - # We don't -DCPU_CAPABILITY=AVX2 because that trips |
77 |
| - # -Wmacro-redefined, and we only care about getting |
78 |
| - # reasonable vectorization and Sleef support. |
79 |
| - "-DCPU_CAPABILITY_AVX2", |
80 |
| - "-DET_USE_PYTORCH_HEADERS", |
81 |
| - "-DHAVE_AVX2_CPU_DEFINITION", |
82 |
| - "-DSTANDALONE_TORCH_HEADER", |
83 |
| - ] + get_sleef_preprocessor_flags(), |
84 |
| - xplat_exported_deps = [ |
85 |
| - "//xplat/caffe2:aten_header", |
86 |
| - "//xplat/caffe2/c10:c10_headers", |
87 |
| - ] + ["//xplat/caffe2:ovrsource_aten_Config.h" if is_arvr_mode() else "//xplat/caffe2:generated_aten_config_header",], |
88 |
| - exported_preprocessor_flags = select({ |
89 |
| - # Intentionally punting on non-fbcode x86 sleef support |
90 |
| - # for now because of fbsource//third-party/sleef:sleef |
91 |
| - # linker failure. |
92 |
| - "ovr_config//cpu:arm64": get_sleef_preprocessor_flags(), |
93 |
| - "DEFAULT": [], |
94 |
| - }) + ["-DSTANDALONE_TORCH_HEADER"] + ([] if runtime.is_oss else ["-DET_USE_PYTORCH_HEADERS"]), |
| 115 | + ] + get_sleef_deps()) if not runtime.is_oss else [], |
| 116 | + exported_preprocessor_flags = get_preprocessor_flags(is_fbcode=False) |
| 117 | + + ([] if runtime.is_oss else ["-DET_USE_PYTORCH_HEADERS"]), |
| 118 | + fbcode_exported_preprocessor_flags = get_preprocessor_flags(is_fbcode=True) |
| 119 | + + ([] if runtime.is_oss else ["-DET_USE_PYTORCH_HEADERS"]), |
95 | 120 | )
|
0 commit comments