|
1 | 1 | load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime", "is_arvr_mode") |
2 | 2 |
|
3 | | -def get_preprocessor_flags(is_fbcode): |
4 | | - flags = ["-DSTANDALONE_TORCH_HEADER"] |
5 | | - if runtime.is_oss: |
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) |
32 | | - |
33 | | -def get_sleef_deps(): |
| 3 | +def get_sleef_preprocessor_flags(): |
34 | 4 | if runtime.is_oss: |
35 | 5 | 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 | | - }) |
| 6 | + return ["-DAT_BUILD_ARM_VEC256_WITH_SLEEF"] |
| 7 | + |
45 | 8 |
|
46 | 9 | def define_common_targets(): |
47 | 10 | """Defines targets that should be shared between fbcode and xplat. |
@@ -91,30 +54,42 @@ def define_common_targets(): |
91 | 54 | name = "aten_headers_for_executorch", |
92 | 55 | srcs = [], |
93 | 56 | 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. |
99 | 57 | exported_deps = select({ |
100 | 58 | "DEFAULT": [], |
101 | 59 | "ovr_config//cpu:arm64": [ |
102 | 60 | "fbsource//third-party/sleef:sleef", |
103 | 61 | ] 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. |
104 | 64 | }), |
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? |
111 | 65 | fbcode_exported_deps = ([ |
112 | 66 | "//caffe2:aten-headers-cpu", |
113 | 67 | "//caffe2:generated-config-header", |
114 | 68 | "//caffe2/c10:c10_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"]), |
| 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"]), |
120 | 95 | ) |
0 commit comments