|
1 | 1 | load("@fbsource//tools/build_defs:platform_defs.bzl", "CXX") |
2 | 2 | load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime") |
3 | 3 |
|
| 4 | +# Deps used by all operators. |
| 5 | +# buildifier: keep sorted |
| 6 | +COMMON_DEPS = [ |
| 7 | + "//executorch/backends/cadence/vision/kernels:cadence_kernels", |
| 8 | + "//executorch/backends/cadence/vision/third-party:vision-nnlib", |
| 9 | + "//executorch/kernels/portable/cpu:scalar_utils", |
| 10 | + "//executorch/kernels/portable/cpu/pattern:all_deps", |
| 11 | + "//executorch/kernels/portable/cpu/pattern:bitwise_op", |
| 12 | + "//executorch/kernels/portable/cpu/pattern:comparison_op", |
| 13 | + "//executorch/kernels/portable/cpu/util:all_deps", |
| 14 | + "//executorch/kernels/portable/cpu/util:dtype_util", |
| 15 | + "//executorch/kernels/portable/cpu/util:elementwise_util", |
| 16 | + "//executorch/runtime/kernel:kernel_includes", |
| 17 | +] |
| 18 | + |
| 19 | +def define_common_targets(): |
| 20 | + """Defines targets that should be shared between fbcode and xplat. |
4 | 21 |
|
5 | | -def define_operator(name: str, deps: list[str] | None = None) -> None: |
6 | | - op_name = "op_{}".format(name) |
7 | | - |
8 | | - # Deps used by all operators. |
9 | | - common_deps = [ |
10 | | - "//executorch/kernels/portable/cpu/util:all_deps", |
11 | | - "//executorch/kernels/portable/cpu/pattern:all_deps", |
12 | | - "//executorch/runtime/kernel:kernel_includes", |
13 | | - "//executorch/kernels/portable/cpu:scalar_utils", |
14 | | - "//executorch/backends/cadence/vision/kernels:cadence_kernels", |
15 | | - "//executorch/kernels/portable/cpu/util:dtype_util", |
16 | | - "//executorch/kernels/portable/cpu/util:elementwise_util", |
17 | | - "//executorch/kernels/portable/cpu/pattern:bitwise_op", |
18 | | - "//executorch/backends/cadence/vision/third-party:vision-nnlib", |
19 | | - "//executorch/kernels/portable/cpu/pattern:comparison_op" |
20 | | - ] |
21 | | - if deps == None: |
22 | | - deps = [] |
23 | | - |
24 | | - # Determine which headers to export based on operator name |
25 | | - exported_headers = ["operators.h"] |
26 | | - |
27 | | - # Add quantized_ops.h header for quantized operators |
28 | | - quantized_ops = [ |
29 | | - "quantized_fully_connected_out", |
30 | | - "quantized_matmul_out", |
31 | | - "quantized_layer_norm", |
32 | | - "quantized_relu_out", |
33 | | - "quantized_conv_out", |
34 | | - "quantized_linear_out", |
35 | | - "quantize_per_tensor", |
36 | | - "dequantize_per_tensor", |
37 | | - "requantize_out" |
38 | | - ] |
39 | | - |
40 | | - if name in quantized_ops: |
41 | | - exported_headers.append("quantized_ops.h") |
| 22 | + The directory containing this targets.bzl file should also contain both |
| 23 | + TARGETS and BUCK files that call this function. |
| 24 | + """ |
42 | 25 |
|
43 | 26 | runtime.cxx_library( |
44 | | - name = op_name, |
45 | | - srcs = [op_name + ".cpp"], |
| 27 | + name = "op_add", |
| 28 | + srcs = ["op_add.cpp"], |
| 29 | + exported_headers = ["operators.h"], |
46 | 30 | platforms = CXX, |
| 31 | + deps = COMMON_DEPS, |
47 | 32 | visibility = ["PUBLIC"], |
48 | 33 | compatible_with = ["ovr_config//cpu:xtensa"], |
49 | | - deps = deps + common_deps, |
50 | | - exported_headers = exported_headers, |
51 | 34 | ) |
52 | 35 |
|
53 | | -OPERATORS = [ |
54 | | - "add", |
55 | | - "full", |
56 | | - "quantized_fully_connected_out", |
57 | | - "quantized_matmul_out", |
58 | | - "requantize_out", |
59 | | - "dequantize_per_tensor", |
60 | | - "im2row_out", |
61 | | - "quantized_layer_norm", |
62 | | - "quantized_relu_out", |
63 | | - "softmax", |
64 | | - "embedding", |
65 | | - "quantized_conv_out", |
66 | | - "quantized_linear_out", |
67 | | - "quantize_per_tensor", |
68 | | - "view_copy" |
69 | | -] |
| 36 | + runtime.cxx_library( |
| 37 | + name = "op_dequantize_per_tensor", |
| 38 | + srcs = ["op_dequantize_per_tensor.cpp"], |
| 39 | + exported_headers = ["operators.h", "quantized_ops.h"], |
| 40 | + platforms = CXX, |
| 41 | + deps = COMMON_DEPS, |
| 42 | + visibility = ["PUBLIC"], |
| 43 | + compatible_with = ["ovr_config//cpu:xtensa"], |
| 44 | + ) |
70 | 45 |
|
71 | | -def define_common_targets(): |
72 | | - """Defines targets that should be shared between fbcode and xplat. |
| 46 | + runtime.cxx_library( |
| 47 | + name = "op_embedding", |
| 48 | + srcs = ["op_embedding.cpp"], |
| 49 | + exported_headers = ["operators.h"], |
| 50 | + platforms = CXX, |
| 51 | + deps = COMMON_DEPS, |
| 52 | + visibility = ["PUBLIC"], |
| 53 | + compatible_with = ["ovr_config//cpu:xtensa"], |
| 54 | + ) |
73 | 55 |
|
74 | | - The directory containing this targets.bzl file should also contain both |
75 | | - TARGETS and BUCK files that call this function. |
76 | | - """ |
| 56 | + runtime.cxx_library( |
| 57 | + name = "op_full", |
| 58 | + srcs = ["op_full.cpp"], |
| 59 | + exported_headers = ["operators.h"], |
| 60 | + platforms = CXX, |
| 61 | + deps = COMMON_DEPS, |
| 62 | + visibility = ["PUBLIC"], |
| 63 | + compatible_with = ["ovr_config//cpu:xtensa"], |
| 64 | + ) |
| 65 | + |
| 66 | + runtime.cxx_library( |
| 67 | + name = "op_im2row_out", |
| 68 | + srcs = ["op_im2row_out.cpp"], |
| 69 | + exported_headers = ["operators.h"], |
| 70 | + platforms = CXX, |
| 71 | + deps = COMMON_DEPS, |
| 72 | + visibility = ["PUBLIC"], |
| 73 | + compatible_with = ["ovr_config//cpu:xtensa"], |
| 74 | + ) |
77 | 75 |
|
78 | | - # Define build targets for all operators registered in the tables above. |
79 | | - for op in OPERATORS: |
80 | | - define_operator(op) |
| 76 | + runtime.cxx_library( |
| 77 | + name = "op_quantize_per_tensor", |
| 78 | + srcs = ["op_quantize_per_tensor.cpp"], |
| 79 | + exported_headers = ["operators.h", "quantized_ops.h"], |
| 80 | + platforms = CXX, |
| 81 | + deps = COMMON_DEPS, |
| 82 | + visibility = ["PUBLIC"], |
| 83 | + compatible_with = ["ovr_config//cpu:xtensa"], |
| 84 | + ) |
| 85 | + |
| 86 | + runtime.cxx_library( |
| 87 | + name = "op_quantized_conv_out", |
| 88 | + srcs = ["op_quantized_conv_out.cpp"], |
| 89 | + exported_headers = ["operators.h", "quantized_ops.h"], |
| 90 | + platforms = CXX, |
| 91 | + deps = COMMON_DEPS, |
| 92 | + visibility = ["PUBLIC"], |
| 93 | + compatible_with = ["ovr_config//cpu:xtensa"], |
| 94 | + ) |
| 95 | + |
| 96 | + runtime.cxx_library( |
| 97 | + name = "op_quantized_fully_connected_out", |
| 98 | + srcs = ["op_quantized_fully_connected_out.cpp"], |
| 99 | + exported_headers = ["operators.h", "quantized_ops.h"], |
| 100 | + platforms = CXX, |
| 101 | + deps = COMMON_DEPS, |
| 102 | + visibility = ["PUBLIC"], |
| 103 | + compatible_with = ["ovr_config//cpu:xtensa"], |
| 104 | + ) |
| 105 | + |
| 106 | + runtime.cxx_library( |
| 107 | + name = "op_quantized_layer_norm", |
| 108 | + srcs = ["op_quantized_layer_norm.cpp"], |
| 109 | + exported_headers = ["operators.h", "quantized_ops.h"], |
| 110 | + platforms = CXX, |
| 111 | + deps = COMMON_DEPS, |
| 112 | + visibility = ["PUBLIC"], |
| 113 | + compatible_with = ["ovr_config//cpu:xtensa"], |
| 114 | + ) |
| 115 | + |
| 116 | + runtime.cxx_library( |
| 117 | + name = "op_quantized_linear_out", |
| 118 | + srcs = ["op_quantized_linear_out.cpp"], |
| 119 | + exported_headers = ["operators.h", "quantized_ops.h"], |
| 120 | + platforms = CXX, |
| 121 | + deps = COMMON_DEPS, |
| 122 | + visibility = ["PUBLIC"], |
| 123 | + compatible_with = ["ovr_config//cpu:xtensa"], |
| 124 | + ) |
| 125 | + |
| 126 | + runtime.cxx_library( |
| 127 | + name = "op_quantized_matmul_out", |
| 128 | + srcs = ["op_quantized_matmul_out.cpp"], |
| 129 | + exported_headers = ["operators.h", "quantized_ops.h"], |
| 130 | + platforms = CXX, |
| 131 | + deps = COMMON_DEPS, |
| 132 | + visibility = ["PUBLIC"], |
| 133 | + compatible_with = ["ovr_config//cpu:xtensa"], |
| 134 | + ) |
| 135 | + |
| 136 | + runtime.cxx_library( |
| 137 | + name = "op_quantized_relu_out", |
| 138 | + srcs = ["op_quantized_relu_out.cpp"], |
| 139 | + exported_headers = ["operators.h", "quantized_ops.h"], |
| 140 | + platforms = CXX, |
| 141 | + deps = COMMON_DEPS, |
| 142 | + visibility = ["PUBLIC"], |
| 143 | + compatible_with = ["ovr_config//cpu:xtensa"], |
| 144 | + ) |
| 145 | + |
| 146 | + runtime.cxx_library( |
| 147 | + name = "op_requantize_out", |
| 148 | + srcs = ["op_requantize_out.cpp"], |
| 149 | + exported_headers = ["operators.h", "quantized_ops.h"], |
| 150 | + platforms = CXX, |
| 151 | + deps = COMMON_DEPS, |
| 152 | + visibility = ["PUBLIC"], |
| 153 | + compatible_with = ["ovr_config//cpu:xtensa"], |
| 154 | + ) |
| 155 | + |
| 156 | + runtime.cxx_library( |
| 157 | + name = "op_softmax", |
| 158 | + srcs = ["op_softmax.cpp"], |
| 159 | + exported_headers = ["operators.h"], |
| 160 | + platforms = CXX, |
| 161 | + deps = COMMON_DEPS, |
| 162 | + visibility = ["PUBLIC"], |
| 163 | + compatible_with = ["ovr_config//cpu:xtensa"], |
| 164 | + ) |
| 165 | + |
| 166 | + runtime.cxx_library( |
| 167 | + name = "op_view_copy", |
| 168 | + srcs = ["op_view_copy.cpp"], |
| 169 | + exported_headers = ["operators.h"], |
| 170 | + platforms = CXX, |
| 171 | + deps = COMMON_DEPS, |
| 172 | + visibility = ["PUBLIC"], |
| 173 | + compatible_with = ["ovr_config//cpu:xtensa"], |
| 174 | + ) |
0 commit comments