11load ("@fbsource//tools/build_defs:platform_defs.bzl" , "CXX" )
22load ("@fbsource//xplat/executorch/build:runtime_wrapper.bzl" , "runtime" )
33
4+ def define_operator (name : str , deps : list [str ] | None = None ) -> None :
5+ op_name = "op_{}" .format (name )
6+
7+ # Deps used by all operators.
8+ common_deps = [
9+ "//executorch/kernels/portable/cpu/util:all_deps" ,
10+ "//executorch/kernels/portable/cpu/pattern:all_deps" ,
11+ "//executorch/runtime/kernel:kernel_includes" ,
12+ "//executorch/kernels/portable/cpu:scalar_utils" ,
13+ "fbsource//third-party/nnlib-FusionG3/xa_nnlib:libxa_nnlib_common" ,
14+ "fbsource//third-party/nnlib-FusionG3/xa_nnlib:libxa_nnlib" ,
15+ ]
16+ if deps == None :
17+ deps = []
18+
19+ runtime .cxx_library (
20+ name = op_name ,
21+ srcs = [op_name + ".cpp" ],
22+ platforms = CXX ,
23+ visibility = [
24+ "//executorch/backends/cadence/..." ,
25+ "@EXECUTORCH_CLIENTS" ,
26+ ],
27+ deps = deps + common_deps ,
28+ exported_deps = [
29+ ":operators_header" ,
30+ ],
31+ )
32+
33+ OPERATORS = [
34+ "add" ,
35+ "cat" ,
36+ "dequantize" ,
37+ "mul" ,
38+ "native_layer_norm" ,
39+ "quantize" ,
40+ "softmax" ,
41+ ]
42+
443def define_common_targets ():
544 """Defines targets that should be shared between fbcode and xplat.
645
@@ -11,28 +50,16 @@ def define_common_targets():
1150 # Define build targets for all operators registered in the tables above.
1251
1352 runtime .cxx_library (
14- name = "cadence_g3_ops" ,
15- srcs = glob ([
16- "*.cpp" ,
17- ]),
18- exported_headers = glob ([
19- "*.h" ,
20- ]),
21- platforms = CXX ,
22- deps = [
23- "//executorch/kernels/portable/cpu/util:all_deps" ,
24- "//executorch/kernels/portable/cpu/pattern:all_deps" ,
25- "//executorch/runtime/kernel:kernel_includes" ,
26- "//executorch/kernels/portable/cpu:scalar_utils" ,
27- "fbsource//third-party/nnlib-FusionG3/xa_nnlib:libxa_nnlib_common" ,
28- "fbsource//third-party/nnlib-FusionG3/xa_nnlib:libxa_nnlib" ,
29- ],
53+ name = "operators_header" ,
54+ exported_headers = ["operators.h" ],
3055 visibility = [
3156 "//executorch/backends/cadence/..." ,
32- "@EXECUTORCH_CLIENTS" ,
3357 ],
3458 exported_deps = [
35- "fbsource//third-party/nnlib-FusionG3/xa_nnlib:libxa_nnlib_common " ,
36- "fbsource//third-party/nnlib-FusionG3/xa_nnlib:libxa_nnlib " ,
59+ "//executorch/runtime/core/exec_aten:lib " ,
60+ "//executorch/runtime/kernel:kernel_runtime_context " ,
3761 ],
3862 )
63+
64+ for op in OPERATORS :
65+ define_operator (op )
0 commit comments