Skip to content

Commit 40736e2

Browse files
authored
Move optimized target definitions to op_registration.bzl (#10986)
Pull Request resolved: #10877 So we can use them in codegen.bzl later (can't pull in definitions from targets.bzl files). ghstack-source-id: 284862879 Differential Revision: [D74741846](https://our.internmc.facebook.com/intern/diff/D74741846/)
1 parent 7d9b15f commit 40736e2

File tree

2 files changed

+131
-125
lines changed

2 files changed

+131
-125
lines changed

kernels/optimized/cpu/targets.bzl

Lines changed: 3 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -1,127 +1,5 @@
11
load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")
2-
load("@fbsource//xplat/executorch/kernels/optimized:op_registration_util.bzl", "define_op_target", "op_target")
3-
4-
_OPTIMIZED_ATEN_OPS = (
5-
op_target(
6-
name = "op_add",
7-
deps = [
8-
":binary_ops",
9-
":add_sub_impl",
10-
"//executorch/kernels/portable/cpu:scalar_utils",
11-
"//executorch/kernels/portable/cpu/util:broadcast_util",
12-
],
13-
),
14-
op_target(
15-
name = "op_bmm",
16-
deps = [
17-
"//executorch/kernels/optimized:libblas",
18-
"//executorch/kernels/portable/cpu/util:matmul_ops_util",
19-
],
20-
),
21-
op_target(
22-
name = "op_div",
23-
deps = [
24-
":binary_ops",
25-
"//executorch/kernels/portable/cpu:scalar_utils",
26-
"//executorch/kernels/portable/cpu/util:broadcast_util",
27-
],
28-
),
29-
op_target(
30-
name = "op_elu",
31-
deps = [
32-
"//executorch/extension/threadpool:threadpool",
33-
"//executorch/kernels/portable/cpu:scalar_utils",
34-
"//executorch/runtime/core/portable_type/c10/c10:aten_headers_for_executorch",
35-
],
36-
),
37-
op_target(name = "op_exp"),
38-
op_target(
39-
name = "op_fft_c2r",
40-
compiler_flags = [] if runtime.is_oss else [
41-
"-Wno-global-constructors",
42-
"-Wno-shadow",
43-
],
44-
deps = [":fft_utils"],
45-
),
46-
op_target(
47-
name = "op_fft_r2c",
48-
compiler_flags = [] if runtime.is_oss else [
49-
"-Wno-global-constructors",
50-
"-Wno-shadow",
51-
],
52-
deps = [":fft_utils"],
53-
),
54-
op_target(name = "op_sigmoid"),
55-
op_target(
56-
name = "op_gelu",
57-
deps = [
58-
"//executorch/kernels/portable/cpu/util:activation_ops_util",
59-
"//executorch/runtime/core/portable_type/c10/c10:aten_headers_for_executorch",
60-
],
61-
),
62-
op_target(
63-
name = "op_le",
64-
deps = [
65-
"//executorch/kernels/portable/cpu:scalar_utils",
66-
"//executorch/kernels/portable/cpu/util:broadcast_util",
67-
],
68-
),
69-
op_target(
70-
name = "op_linear",
71-
deps = [
72-
"//executorch/kernels/optimized:libblas",
73-
"//executorch/kernels/portable/cpu/util:matmul_ops_util",
74-
],
75-
),
76-
op_target(
77-
name = "op_log_softmax",
78-
deps = [
79-
"//executorch/kernels/portable/cpu/util:activation_ops_util",
80-
"//executorch/runtime/core/portable_type/c10/c10:aten_headers_for_executorch",
81-
],
82-
),
83-
op_target(
84-
name = "op_mm",
85-
deps = [
86-
"//executorch/kernels/optimized:libblas",
87-
"//executorch/kernels/portable/cpu/util:matmul_ops_util",
88-
],
89-
),
90-
op_target(
91-
name = "op_mul",
92-
deps = [
93-
":binary_ops",
94-
"//executorch/kernels/portable/cpu:scalar_utils",
95-
"//executorch/kernels/portable/cpu/util:broadcast_util",
96-
"//executorch/runtime/core/exec_aten/util:tensor_util",
97-
],
98-
),
99-
op_target(
100-
name = "op_native_layer_norm",
101-
deps = [
102-
":moments_utils",
103-
"//executorch/kernels/portable/cpu/util:normalization_ops_util",
104-
],
105-
),
106-
op_target(name = "op_neg"),
107-
op_target(
108-
name = "op_sub",
109-
deps = [
110-
":binary_ops",
111-
":add_sub_impl",
112-
"//executorch/kernels/portable/cpu:scalar_utils",
113-
"//executorch/kernels/portable/cpu/util:broadcast_util",
114-
],
115-
),
116-
op_target(
117-
name = "op_where",
118-
deps = [
119-
"//executorch/extension/threadpool:threadpool",
120-
"//executorch/kernels/portable/cpu/util:elementwise_util",
121-
],
122-
),
123-
)
124-
2+
load("@fbsource//xplat/executorch/kernels/optimized:op_registration_util.bzl", "OPTIMIZED_ATEN_OPS", "define_op_target", "op_target")
1253

1264
def get_sleef_preprocessor_flags():
1275
if runtime.is_oss:
@@ -137,10 +15,10 @@ def define_common_targets():
13715
"""
13816

13917
# Define build targets for all operators registered in the tables above.
140-
for op in _OPTIMIZED_ATEN_OPS:
18+
for op in OPTIMIZED_ATEN_OPS:
14119
define_op_target(**op)
14220

143-
aten_op_targets = [":{}".format(op["name"]) for op in _OPTIMIZED_ATEN_OPS]
21+
aten_op_targets = [":{}".format(op["name"]) for op in OPTIMIZED_ATEN_OPS]
14422
all_op_targets = aten_op_targets
14523

14624
runtime.cxx_library(

shim_et/xplat/executorch/kernels/optimized/op_registration_util.bzl

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# Copyright (c) Meta Platforms, Inc. and affiliates.
2+
#
3+
# This source code is licensed under both the MIT license found in the
4+
# LICENSE-MIT file in the root directory of this source tree and the Apache
5+
# License, Version 2.0 found in the LICENSE-APACHE file in the root directory
6+
# of this source tree.
7+
18
load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")
29
load("@fbsource//xplat/executorch/build:selects.bzl", "selects")
310
load(
@@ -137,3 +144,124 @@ def define_op_target(name, compiler_flags, deps):
137144
compiler_flags = compiler_flags,
138145
deps = deps,
139146
)
147+
148+
OPTIMIZED_ATEN_OPS = (
149+
op_target(
150+
name = "op_add",
151+
deps = [
152+
":binary_ops",
153+
":add_sub_impl",
154+
"//executorch/kernels/portable/cpu:scalar_utils",
155+
"//executorch/kernels/portable/cpu/util:broadcast_util",
156+
],
157+
),
158+
op_target(
159+
name = "op_bmm",
160+
deps = [
161+
"//executorch/kernels/optimized:libblas",
162+
"//executorch/kernels/portable/cpu/util:matmul_ops_util",
163+
],
164+
),
165+
op_target(
166+
name = "op_div",
167+
deps = [
168+
":binary_ops",
169+
"//executorch/kernels/portable/cpu:scalar_utils",
170+
"//executorch/kernels/portable/cpu/util:broadcast_util",
171+
],
172+
),
173+
op_target(
174+
name = "op_elu",
175+
deps = [
176+
"//executorch/extension/threadpool:threadpool",
177+
"//executorch/kernels/portable/cpu:scalar_utils",
178+
"//executorch/runtime/core/portable_type/c10/c10:aten_headers_for_executorch",
179+
],
180+
),
181+
op_target(name = "op_exp"),
182+
op_target(
183+
name = "op_fft_c2r",
184+
compiler_flags = [] if runtime.is_oss else [
185+
"-Wno-global-constructors",
186+
"-Wno-shadow",
187+
],
188+
deps = [":fft_utils"],
189+
),
190+
op_target(
191+
name = "op_fft_r2c",
192+
compiler_flags = [] if runtime.is_oss else [
193+
"-Wno-global-constructors",
194+
"-Wno-shadow",
195+
],
196+
deps = [":fft_utils"],
197+
),
198+
op_target(name = "op_sigmoid"),
199+
op_target(
200+
name = "op_gelu",
201+
deps = [
202+
"//executorch/kernels/portable/cpu/util:activation_ops_util",
203+
"//executorch/runtime/core/portable_type/c10/c10:aten_headers_for_executorch",
204+
],
205+
),
206+
op_target(
207+
name = "op_le",
208+
deps = [
209+
"//executorch/kernels/portable/cpu:scalar_utils",
210+
"//executorch/kernels/portable/cpu/util:broadcast_util",
211+
],
212+
),
213+
op_target(
214+
name = "op_linear",
215+
deps = [
216+
"//executorch/kernels/optimized:libblas",
217+
"//executorch/kernels/portable/cpu/util:matmul_ops_util",
218+
],
219+
),
220+
op_target(
221+
name = "op_log_softmax",
222+
deps = [
223+
"//executorch/kernels/portable/cpu/util:activation_ops_util",
224+
"//executorch/runtime/core/portable_type/c10/c10:aten_headers_for_executorch",
225+
],
226+
),
227+
op_target(
228+
name = "op_mm",
229+
deps = [
230+
"//executorch/kernels/optimized:libblas",
231+
"//executorch/kernels/portable/cpu/util:matmul_ops_util",
232+
],
233+
),
234+
op_target(
235+
name = "op_mul",
236+
deps = [
237+
":binary_ops",
238+
"//executorch/kernels/portable/cpu:scalar_utils",
239+
"//executorch/kernels/portable/cpu/util:broadcast_util",
240+
"//executorch/runtime/core/exec_aten/util:tensor_util",
241+
],
242+
),
243+
op_target(
244+
name = "op_native_layer_norm",
245+
deps = [
246+
":moments_utils",
247+
"//executorch/kernels/portable/cpu/util:normalization_ops_util",
248+
],
249+
),
250+
op_target(name = "op_neg"),
251+
op_target(
252+
name = "op_sub",
253+
deps = [
254+
":binary_ops",
255+
":add_sub_impl",
256+
"//executorch/kernels/portable/cpu:scalar_utils",
257+
"//executorch/kernels/portable/cpu/util:broadcast_util",
258+
],
259+
),
260+
op_target(
261+
name = "op_where",
262+
deps = [
263+
"//executorch/extension/threadpool:threadpool",
264+
"//executorch/kernels/portable/cpu/util:elementwise_util",
265+
],
266+
),
267+
)

0 commit comments

Comments
 (0)