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- "//executorch/backends/cadence/common:xt_macros" ,
14- "fbsource//third-party/nnlib-FusionG3/xa_nnlib:libxa_nnlib_common" ,
15- "fbsource//third-party/nnlib-FusionG3/xa_nnlib:libxa_nnlib" ,
16- ":operators_header" ,
17- ":xt_utils" ,
18- ]
19- if deps == None :
20- deps = []
21-
22- runtime .cxx_library (
23- name = op_name ,
24- srcs = [op_name + ".cpp" ],
25- platforms = CXX ,
26- visibility = ["PUBLIC" ],
27- compatible_with = ["ovr_config//cpu:xtensa" ],
28- deps = deps + common_deps ,
29- )
30-
31- OPERATORS = [
32- "add" ,
33- "cat" ,
34- "clamp" ,
35- "lt" ,
36- "rsqrt" ,
37- "sigmoid" ,
38- "sqrt" ,
39- "hardtanh" ,
40- "tanh" ,
41- "transpose_copy" ,
42- "where" ,
43- "dequantize" ,
44- "mul" ,
45- "native_layer_norm" ,
46- "quantize" ,
47- "softmax" ,
48- "sub" ,
49- "div" ,
50- "exp" ,
51- "mean" ,
52- "slice_copy" ,
53- "permute_copy"
4+ # Deps used by all operators.
5+ # buildifier: keep sorted
6+ COMMON_DEPS = [
7+ "//executorch/backends/cadence/common:xt_macros" ,
8+ "//executorch/kernels/portable/cpu:scalar_utils" ,
9+ "//executorch/kernels/portable/cpu/pattern:all_deps" ,
10+ "//executorch/kernels/portable/cpu/util:all_deps" ,
11+ "//executorch/runtime/kernel:kernel_includes" ,
12+ "fbsource//third-party/nnlib-FusionG3/xa_nnlib:libxa_nnlib" ,
13+ "fbsource//third-party/nnlib-FusionG3/xa_nnlib:libxa_nnlib_common" ,
5414]
5515
5616def define_common_targets ():
@@ -60,8 +20,6 @@ def define_common_targets():
6020 TARGETS and BUCK files that call this function.
6121 """
6222
63- # Define build targets for all operators registered in the tables above.
64-
6523 runtime .cxx_library (
6624 name = "operators_header" ,
6725 exported_headers = ["operators.h" ],
@@ -86,5 +44,266 @@ def define_common_targets():
8644 ],
8745 )
8846
89- for op in OPERATORS :
90- define_operator (op )
47+ runtime .cxx_library (
48+ name = "op_add" ,
49+ srcs = ["op_add.cpp" ],
50+ platforms = CXX ,
51+ deps = COMMON_DEPS + [
52+ ":operators_header" ,
53+ ":xt_utils" ,
54+ ],
55+ visibility = ["PUBLIC" ],
56+ compatible_with = ["ovr_config//cpu:xtensa" ],
57+ )
58+
59+ runtime .cxx_library (
60+ name = "op_cat" ,
61+ srcs = ["op_cat.cpp" ],
62+ platforms = CXX ,
63+ deps = COMMON_DEPS + [
64+ ":operators_header" ,
65+ ":xt_utils" ,
66+ ],
67+ visibility = ["PUBLIC" ],
68+ compatible_with = ["ovr_config//cpu:xtensa" ],
69+ )
70+
71+ runtime .cxx_library (
72+ name = "op_clamp" ,
73+ srcs = ["op_clamp.cpp" ],
74+ platforms = CXX ,
75+ deps = COMMON_DEPS + [
76+ ":operators_header" ,
77+ ":xt_utils" ,
78+ ],
79+ visibility = ["PUBLIC" ],
80+ compatible_with = ["ovr_config//cpu:xtensa" ],
81+ )
82+
83+ runtime .cxx_library (
84+ name = "op_dequantize" ,
85+ srcs = ["op_dequantize.cpp" ],
86+ platforms = CXX ,
87+ deps = COMMON_DEPS + [
88+ ":operators_header" ,
89+ ":xt_utils" ,
90+ ],
91+ visibility = ["PUBLIC" ],
92+ compatible_with = ["ovr_config//cpu:xtensa" ],
93+ )
94+
95+ runtime .cxx_library (
96+ name = "op_div" ,
97+ srcs = ["op_div.cpp" ],
98+ platforms = CXX ,
99+ deps = COMMON_DEPS + [
100+ ":operators_header" ,
101+ ":xt_utils" ,
102+ ],
103+ visibility = ["PUBLIC" ],
104+ compatible_with = ["ovr_config//cpu:xtensa" ],
105+ )
106+
107+ runtime .cxx_library (
108+ name = "op_exp" ,
109+ srcs = ["op_exp.cpp" ],
110+ platforms = CXX ,
111+ deps = COMMON_DEPS + [
112+ ":operators_header" ,
113+ ":xt_utils" ,
114+ ],
115+ visibility = ["PUBLIC" ],
116+ compatible_with = ["ovr_config//cpu:xtensa" ],
117+ )
118+
119+ runtime .cxx_library (
120+ name = "op_hardtanh" ,
121+ srcs = ["op_hardtanh.cpp" ],
122+ platforms = CXX ,
123+ deps = COMMON_DEPS + [
124+ ":operators_header" ,
125+ ":xt_utils" ,
126+ ],
127+ visibility = ["PUBLIC" ],
128+ compatible_with = ["ovr_config//cpu:xtensa" ],
129+ )
130+
131+ runtime .cxx_library (
132+ name = "op_lt" ,
133+ srcs = ["op_lt.cpp" ],
134+ platforms = CXX ,
135+ deps = COMMON_DEPS + [
136+ ":operators_header" ,
137+ ":xt_utils" ,
138+ ],
139+ visibility = ["PUBLIC" ],
140+ compatible_with = ["ovr_config//cpu:xtensa" ],
141+ )
142+
143+ runtime .cxx_library (
144+ name = "op_mean" ,
145+ srcs = ["op_mean.cpp" ],
146+ platforms = CXX ,
147+ deps = COMMON_DEPS + [
148+ ":operators_header" ,
149+ ":xt_utils" ,
150+ ],
151+ visibility = ["PUBLIC" ],
152+ compatible_with = ["ovr_config//cpu:xtensa" ],
153+ )
154+
155+ runtime .cxx_library (
156+ name = "op_mul" ,
157+ srcs = ["op_mul.cpp" ],
158+ platforms = CXX ,
159+ deps = COMMON_DEPS + [
160+ ":operators_header" ,
161+ ":xt_utils" ,
162+ ],
163+ visibility = ["PUBLIC" ],
164+ compatible_with = ["ovr_config//cpu:xtensa" ],
165+ )
166+
167+ runtime .cxx_library (
168+ name = "op_native_layer_norm" ,
169+ srcs = ["op_native_layer_norm.cpp" ],
170+ platforms = CXX ,
171+ deps = COMMON_DEPS + [
172+ ":operators_header" ,
173+ ":xt_utils" ,
174+ ],
175+ visibility = ["PUBLIC" ],
176+ compatible_with = ["ovr_config//cpu:xtensa" ],
177+ )
178+
179+ runtime .cxx_library (
180+ name = "op_permute_copy" ,
181+ srcs = ["op_permute_copy.cpp" ],
182+ platforms = CXX ,
183+ deps = COMMON_DEPS + [
184+ ":operators_header" ,
185+ ":xt_utils" ,
186+ ],
187+ visibility = ["PUBLIC" ],
188+ compatible_with = ["ovr_config//cpu:xtensa" ],
189+ )
190+
191+ runtime .cxx_library (
192+ name = "op_quantize" ,
193+ srcs = ["op_quantize.cpp" ],
194+ platforms = CXX ,
195+ deps = COMMON_DEPS + [
196+ ":operators_header" ,
197+ ":xt_utils" ,
198+ ],
199+ visibility = ["PUBLIC" ],
200+ compatible_with = ["ovr_config//cpu:xtensa" ],
201+ )
202+
203+ runtime .cxx_library (
204+ name = "op_rsqrt" ,
205+ srcs = ["op_rsqrt.cpp" ],
206+ platforms = CXX ,
207+ deps = COMMON_DEPS + [
208+ ":operators_header" ,
209+ ":xt_utils" ,
210+ ],
211+ visibility = ["PUBLIC" ],
212+ compatible_with = ["ovr_config//cpu:xtensa" ],
213+ )
214+
215+ runtime .cxx_library (
216+ name = "op_sigmoid" ,
217+ srcs = ["op_sigmoid.cpp" ],
218+ platforms = CXX ,
219+ deps = COMMON_DEPS + [
220+ ":operators_header" ,
221+ ":xt_utils" ,
222+ ],
223+ visibility = ["PUBLIC" ],
224+ compatible_with = ["ovr_config//cpu:xtensa" ],
225+ )
226+
227+ runtime .cxx_library (
228+ name = "op_slice_copy" ,
229+ srcs = ["op_slice_copy.cpp" ],
230+ platforms = CXX ,
231+ deps = COMMON_DEPS + [
232+ ":operators_header" ,
233+ ":xt_utils" ,
234+ ],
235+ visibility = ["PUBLIC" ],
236+ compatible_with = ["ovr_config//cpu:xtensa" ],
237+ )
238+
239+ runtime .cxx_library (
240+ name = "op_softmax" ,
241+ srcs = ["op_softmax.cpp" ],
242+ platforms = CXX ,
243+ deps = COMMON_DEPS + [
244+ ":operators_header" ,
245+ ":xt_utils" ,
246+ ],
247+ visibility = ["PUBLIC" ],
248+ compatible_with = ["ovr_config//cpu:xtensa" ],
249+ )
250+
251+ runtime .cxx_library (
252+ name = "op_sqrt" ,
253+ srcs = ["op_sqrt.cpp" ],
254+ platforms = CXX ,
255+ deps = COMMON_DEPS + [
256+ ":operators_header" ,
257+ ":xt_utils" ,
258+ ],
259+ visibility = ["PUBLIC" ],
260+ compatible_with = ["ovr_config//cpu:xtensa" ],
261+ )
262+
263+ runtime .cxx_library (
264+ name = "op_sub" ,
265+ srcs = ["op_sub.cpp" ],
266+ platforms = CXX ,
267+ deps = COMMON_DEPS + [
268+ ":operators_header" ,
269+ ":xt_utils" ,
270+ ],
271+ visibility = ["PUBLIC" ],
272+ compatible_with = ["ovr_config//cpu:xtensa" ],
273+ )
274+
275+ runtime .cxx_library (
276+ name = "op_tanh" ,
277+ srcs = ["op_tanh.cpp" ],
278+ platforms = CXX ,
279+ deps = COMMON_DEPS + [
280+ ":operators_header" ,
281+ ":xt_utils" ,
282+ ],
283+ visibility = ["PUBLIC" ],
284+ compatible_with = ["ovr_config//cpu:xtensa" ],
285+ )
286+
287+ runtime .cxx_library (
288+ name = "op_transpose_copy" ,
289+ srcs = ["op_transpose_copy.cpp" ],
290+ platforms = CXX ,
291+ deps = COMMON_DEPS + [
292+ ":operators_header" ,
293+ ":xt_utils" ,
294+ ],
295+ visibility = ["PUBLIC" ],
296+ compatible_with = ["ovr_config//cpu:xtensa" ],
297+ )
298+
299+ runtime .cxx_library (
300+ name = "op_where" ,
301+ srcs = ["op_where.cpp" ],
302+ platforms = CXX ,
303+ deps = COMMON_DEPS + [
304+ ":operators_header" ,
305+ ":xt_utils" ,
306+ ],
307+ visibility = ["PUBLIC" ],
308+ compatible_with = ["ovr_config//cpu:xtensa" ],
309+ )
0 commit comments