@@ -9,22 +9,66 @@ load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")
99load ("@fbsource//xplat/executorch/codegen:codegen.bzl" , "et_operator_library" , "executorch_generated_lib" )
1010load ("@fbcode_macros//build_defs:export_files.bzl" , "export_file" )
1111
12+ _ARM_EMBEDDED_PLATFORMS = ["ovr_config//cpu:arm32-embedded" , "ovr_config//cpu:arm32-embedded-fpu" ]
13+
14+ # Operators that compile without CMSIS-NN (portable scalar + optional Helium/MVE).
15+ # These can be built and tested on any platform (including x86_64 CI).
16+ _PORTABLE_OPERATORS = [
17+ "quantize_per_tensor" ,
18+ "dequantize_per_tensor" ,
19+ ]
20+
21+
1222def define_operator_target (name : str ):
23+ needs_cmsis = name not in _PORTABLE_OPERATORS
24+
25+ cmsis_deps = [
26+ "//executorch/kernels/portable/cpu:scalar_utils" ,
27+ "//executorch/kernels/portable/cpu/util:broadcast_util" ,
28+ "//executorch/kernels/portable/cpu/util:elementwise_util" ,
29+ "//executorch/kernels/portable/cpu/util:kernel_ops_util" ,
30+ "//executorch/kernels/portable/cpu/util:copy_ops_util" ,
31+ "//executorch/kernels/portable/cpu/util:padding_util" ,
32+ "fbsource//third-party/cmsis-nn:cmsis_header" ,
33+ "fbsource//third-party/cmsis-nn:cmsis_nn" ,
34+ ] if needs_cmsis else []
35+
36+ cmsis_headers = ["cortex_m_ops_common.h" ] if needs_cmsis else []
37+
38+ _compat_kwargs = {}
39+ if needs_cmsis :
40+ _compat_kwargs ["compatible_with" ] = _ARM_EMBEDDED_PLATFORMS
41+
1342 runtime .cxx_library (
1443 name = "op_{}" .format (name ),
1544 srcs = [
1645 "op_{}.cpp" .format (name ),
1746 ],
47+ headers = cmsis_headers ,
1848 platforms = CXX ,
1949 deps = [
20- "//executorch/runtime/kernel:kernel_includes"
21- ],
50+ "//executorch/runtime/kernel:kernel_includes" ,
51+ ] + cmsis_deps ,
2252 link_whole = True ,
53+ ** _compat_kwargs
2354 )
2455
2556OPERATORS = [
2657 "quantize_per_tensor" ,
2758 "dequantize_per_tensor" ,
59+ "quantized_add" ,
60+ "quantized_mul" ,
61+ "minimum" ,
62+ "maximum" ,
63+ "quantized_linear" ,
64+ "softmax" ,
65+ "transpose" ,
66+ "pad" ,
67+ "quantized_conv2d" ,
68+ "quantized_depthwise_conv2d" ,
69+ "quantized_transpose_conv2d" ,
70+ "quantized_avg_pool2d" ,
71+ "quantized_max_pool2d" ,
2872]
2973
3074def define_common_targets ():
@@ -44,6 +88,7 @@ def define_common_targets():
4488 visibility = ["PUBLIC" ],
4589 platforms = CXX ,
4690 exported_deps = all_op_targets ,
91+ compatible_with = _ARM_EMBEDDED_PLATFORMS ,
4792 )
4893
4994 export_file (name = "operators.yaml" )
@@ -58,23 +103,29 @@ def define_common_targets():
58103 name = "cortex_m_generated_lib" ,
59104 deps = [
60105 ":ops_lib" ,
106+ ],
107+ kernel_deps = [
61108 ":cortex_m_operators" ,
62109 ],
63110 functions_yaml_target = ":operators.yaml" ,
64111 platforms = CXX ,
65112 visibility = ["PUBLIC" ],
66113 define_static_targets = True ,
114+ compatible_with = _ARM_EMBEDDED_PLATFORMS ,
67115 )
68116
69117 executorch_generated_lib (
70118 name = "cortex_m_no_except_generated_lib" ,
71119 deps = [
72120 ":ops_lib" ,
121+ ],
122+ kernel_deps = [
73123 ":cortex_m_operators" ,
74124 ],
75125 functions_yaml_target = ":operators.yaml" ,
76126 platforms = CXX ,
77127 visibility = ["PUBLIC" ],
78128 define_static_targets = True ,
79129 support_exceptions = False ,
130+ compatible_with = _ARM_EMBEDDED_PLATFORMS ,
80131 )
0 commit comments