xref: /aosp_15_r20/external/executorch/backends/cadence/aot/TARGETS (revision 523fa7a60841cd1ecfb9cc4201f1ca8b03ed023a)
1# Copyright (c) Meta Platforms, Inc. and affiliates.
2# All rights reserved.
3#
4# This source code is licensed under the BSD-style license found in the
5# LICENSE file in the root directory of this source tree.
6
7load("@fbcode_macros//build_defs:export_files.bzl", "export_file")
8load("@fbcode_macros//build_defs:python_library.bzl", "python_library")
9load(
10    "@fbsource//tools/build_defs:default_platform_defs.bzl",
11    "CXX",
12)
13load("@fbsource//xplat/executorch/codegen:codegen.bzl", "executorch_generated_lib")
14load("@fbcode_macros//build_defs:python_unittest.bzl", "python_unittest")
15
16oncall("odai_jarvis")
17
18python_library(
19    name = "utils",
20    srcs = [
21        "utils.py",
22    ],
23    deps = [
24        "fbsource//third-party/pypi/tabulate:tabulate",
25        "//caffe2:torch",
26        "//executorch/exir:lib",
27        "//executorch/exir:memory",
28        "//executorch/exir/dialects:lib",
29        "//executorch/exir/dialects/edge:lib",
30    ],
31)
32
33python_library(
34    name = "compiler",
35    srcs = [
36        "compiler.py",
37    ],
38    deps = [
39        ":passes",
40        ":utils",
41        ":ops_registrations",
42        ":replace_ops",
43        "//caffe2:torch",
44        "//executorch/backends/cadence/aot/quantizer:fusion_pass",
45        "//executorch/backends/cadence/aot/quantizer:quantizer",
46        "//executorch/backends/transforms:decompose_sdpa",
47        "//executorch/backends/transforms:remove_clone_ops",
48        "//executorch/exir:lib",
49        "//executorch/devtools:lib",
50    ],
51)
52
53
54python_library(
55    name = "pass_utils",
56    srcs = [
57        "pass_utils.py",
58    ],
59    deps = [
60        ":utils",
61        "//caffe2:torch",
62        "//executorch/exir:pass_base",
63        "//executorch/exir/dialects:lib",
64        "//executorch/exir/passes:lib",
65        "//executorch/exir/passes:spec_prop_pass",
66    ],
67)
68
69python_library(
70    name = "passes",
71    srcs = [
72        "_passes.py",
73    ],
74    deps = [
75        ":utils",
76        ":fuse_ops",
77        ":simplify_ops",
78        ":replace_ops",
79        ":reorder_ops",
80        ":remove_ops",
81        "//caffe2:torch",
82        "//executorch/exir:pass_base",
83        "//executorch/exir/dialects:lib",
84        "//executorch/exir/passes:lib",
85        "//executorch/exir/passes:spec_prop_pass",
86    ],
87)
88
89python_library(
90    name = "ops_registrations",
91    srcs = [
92        "ops_registrations.py",
93    ],
94    deps = [
95        "fbcode//caffe2:torch",
96        "fbcode//executorch/exir:scalar_type",
97        "fbcode//executorch/backends/cadence/aot:utils",
98    ],
99)
100
101export_file(name = "functions.yaml")
102
103executorch_generated_lib(
104    name = "cadence_aot_lib",
105    custom_ops_yaml_target = "//executorch/kernels/portable:custom_ops.yaml",
106    functions_yaml_target = ":functions.yaml",
107    platforms = CXX,
108    visibility = ["PUBLIC"],
109    deps = [
110        "//executorch/backends/cadence/reference/kernels:cadence_kernels",
111        "//executorch/backends/cadence/reference/operators:cadence_cpu_ops",
112        "//executorch/kernels/portable:executorch_all_ops",
113        "//executorch/kernels/portable:operators",
114    ],
115)
116
117python_unittest(
118    name = "test_pass_filter",
119    srcs = [
120        "tests/test_pass_filter.py",
121    ],
122    typing = True,
123    deps = [
124        ":pass_utils",
125        "//executorch/exir:pass_base",
126    ],
127)
128
129python_library(
130    name = "compiler_utils",
131    srcs = [
132        "compiler_utils.py",
133    ],
134    typing = True,
135    deps = [
136        "//caffe2:torch",
137        "//executorch/exir/dialects:lib",
138    ],
139)
140
141python_library(
142    name = "graph_builder",
143    srcs = [
144        "graph_builder.py",
145    ],
146    typing = True,
147    deps = [
148        "fbcode//caffe2:torch",
149        "fbcode//executorch/exir:pass_base",
150    ],
151)
152
153python_library(
154    name = "fuse_ops",
155    srcs = [
156        "fuse_ops.py",
157    ],
158    typing = True,
159    deps = [
160        "//caffe2:torch",
161        ":compiler_utils",
162        "//executorch/backends/cadence/aot:pass_utils",
163        "//executorch/backends/cadence/aot:utils",
164        "//executorch/exir:pass_base",
165        "//executorch/exir/dialects:lib",
166        "//executorch/exir/dialects/edge:lib",
167        "//executorch/exir/passes:lib",
168        "//executorch/exir/passes:spec_prop_pass",
169    ],
170)
171
172python_library(
173    name = "simplify_ops",
174    srcs = [
175        "simplify_ops.py",
176    ],
177    typing = True,
178    deps = [
179        ":pass_utils",
180        "//executorch/backends/cadence/aot:pass_utils",
181        "//executorch/exir:pass_base",
182        "//executorch/exir/dialects:lib",
183    ],
184)
185
186python_library(
187    name = "remove_ops",
188    srcs = [
189        "remove_ops.py",
190    ],
191    typing = True,
192    deps = [
193        "//caffe2:torch",
194        "//executorch/backends/cadence/aot:pass_utils",
195        "//executorch/backends/cadence/aot:simplify_ops",
196        "//executorch/exir:pass_base",
197        "//executorch/exir/dialects:lib",
198        "//executorch/exir/dialects/edge:lib",
199        "//executorch/exir/passes:spec_prop_pass",
200        "//executorch/backends/transforms:remove_clone_ops"
201    ],
202)
203
204python_library(
205    name = "reorder_ops",
206    srcs = [
207        "reorder_ops.py",
208    ],
209    typing = True,
210    deps = [
211        "//caffe2:torch",
212        "//executorch/backends/cadence/aot:compiler_utils",
213        "//executorch/backends/cadence/aot:pass_utils",
214        "//executorch/backends/cadence/aot:utils",
215        "//executorch/exir:pass_base",
216        "//executorch/exir:tensor",
217        "//executorch/exir/dialects:lib",
218        "//executorch/exir/dialects/edge:lib",
219    ],
220)
221
222python_library(
223    name = "replace_ops",
224    srcs = [
225        "replace_ops.py",
226    ],
227    typing = True,
228    deps = [
229        ":pass_utils",
230        "//caffe2:torch",
231        "//executorch/backends/cadence/aot:compiler_utils",
232        "//executorch/backends/cadence/aot:fuse_ops",
233        "//executorch/backends/cadence/aot:pass_utils",
234        "//executorch/backends/cadence/aot:remove_ops",
235        "//executorch/backends/cadence/aot:utils",
236        "//executorch/exir:pass_base",
237        "//executorch/exir/dialects:lib",
238        "//executorch/exir/dialects/edge:lib",
239        "//executorch/exir/passes:spec_prop_pass",
240    ],
241)
242
243python_unittest(
244    name = "test_graph_builder",
245    srcs = [
246        "tests/test_graph_builder.py",
247    ],
248    typing = True,
249    deps = [
250        "//caffe2:torch",
251        "//executorch/backends/cadence/aot:graph_builder",
252        "//executorch/backends/cadence/aot:pass_utils",
253        "//executorch/exir:pass_base",
254        "//executorch/exir/dialects:lib",
255        "//later:lib",
256        ":ops_registrations"
257    ],
258)
259
260python_unittest(
261    name = "test_replace_ops_passes",
262    srcs = [
263        "tests/test_replace_ops_passes.py",
264    ],
265    supports_static_listing = False,
266    typing = True,
267    deps = [
268        "fbsource//third-party/pypi/parameterized:parameterized",
269        ":compiler",
270        ":replace_ops",
271        "//caffe2:torch",
272        "//executorch/backends/cadence/aot:compiler",
273        "//executorch/backends/cadence/aot:graph_builder",
274        "//executorch/backends/cadence/aot:pass_utils",
275        "//executorch/exir:pass_base",
276        "//executorch/exir/dialects:lib",
277        "//executorch/exir/passes:lib",
278    ],
279)
280
281python_unittest(
282    name = "test_fusion_ops_passes",
283    srcs = [
284        "tests/test_fusion_ops_passes.py",
285    ],
286    typing = True,
287    deps = [
288        ":compiler",
289        "//caffe2:torch",
290        "//executorch/backends/cadence/aot:compiler",
291        "//executorch/backends/cadence/aot:fuse_ops",
292        "//executorch/backends/cadence/aot:graph_builder",
293        "//executorch/backends/cadence/aot:ops_registrations",
294        "//executorch/backends/cadence/aot:pass_utils",
295        "//executorch/exir/dialects:lib",
296        "//executorch/exir/dialects/edge:lib",
297    ],
298)
299
300python_unittest(
301    name = "test_remove_ops_passes",
302    srcs = [
303        "tests/test_remove_ops_passes.py",
304    ],
305    supports_static_listing = False,
306    typing = True,
307    deps = [
308        "fbsource//third-party/pypi/parameterized:parameterized",
309        "fbsource//third-party/pypi/pyre-extensions:pyre-extensions",
310        ":compiler",
311        "//caffe2:torch",
312        "//executorch/backends/cadence/aot:compiler",
313        "//executorch/backends/cadence/aot:ops_registrations",
314        "//executorch/backends/cadence/aot:pass_utils",
315        "//executorch/backends/cadence/aot:remove_ops",
316        "//executorch/backends/cadence/aot/quantizer:quantizer",
317        "//executorch/exir/dialects:lib",
318    ],
319)
320
321python_unittest(
322    name = "test_simplify_ops_passes",
323    srcs = [
324        "tests/test_simplify_ops_passes.py",
325    ],
326    supports_static_listing = False,
327    typing = True,
328    deps = [
329        "fbsource//third-party/pypi/parameterized:parameterized",
330        "//caffe2:torch",
331        "//executorch/backends/cadence/aot:compiler",
332        "//executorch/backends/cadence/aot:ops_registrations",
333        "//executorch/backends/cadence/aot:pass_utils",
334        "//executorch/backends/cadence/aot:simplify_ops",
335        "//executorch/exir/dialects:lib",
336    ],
337)
338
339python_unittest(
340    name = "test_reorder_ops_passes",
341    srcs = [
342        "tests/test_reorder_ops_passes.py",
343    ],
344    typing = True,
345    deps = [
346        ":compiler",
347        ":pass_utils",
348        "//caffe2:torch",
349        "//executorch/backends/cadence/aot:compiler",
350        "//executorch/backends/cadence/aot:fuse_ops",
351        "//executorch/backends/cadence/aot:ops_registrations",
352        "//executorch/backends/cadence/aot:pass_utils",
353        "//executorch/backends/cadence/aot:reorder_ops",
354        "//executorch/exir/dialects:lib",
355    ],
356)
357