-
Notifications
You must be signed in to change notification settings - Fork 528
/
Copy pathtargets.bzl
267 lines (249 loc) · 11.3 KB
/
targets.bzl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "get_aten_mode_options", "runtime")
def define_common_targets(is_fbcode = False):
"""Defines targets that should be shared between fbcode and xplat.
The directory containing this targets.bzl file should also contain both
TARGETS and BUCK files that call this function.
"""
for aten_mode in get_aten_mode_options():
aten_suffix = ("_aten" if aten_mode else "")
runtime.cxx_library(
name = "test_backend_compiler_lib" + aten_suffix,
srcs = [
"test_backend_compiler_lib.cpp",
],
visibility = [
"//executorch/exir/backend/test/...",
"//executorch/runtime/backend/...",
"//executorch/extension/pybindings/...",
"//executorch/devtools/fb/runners/...",
"//executorch/test/...",
"//executorch/examples/...",
],
# registration of backends is done through a static global
compiler_flags = ["-Wno-global-constructors"],
preprocessor_flags = ["-DUSE_ATEN_LIB"] if aten_mode else [],
exported_deps = [
"//executorch/runtime/backend:interface" + aten_suffix,
],
# TestBackendCompilerLib.cpp needs to compile with executor as whole
# @lint-ignore BUCKLINT: Avoid `link_whole=True` (https://fburl.com/avoid-link-whole)
link_whole = True,
)
runtime.cxx_library(
name = "test_backend_with_delegate_mapping" + aten_suffix,
srcs = [
"test_backend_with_delegate_mapping.cpp",
],
visibility = [
"//executorch/exir/backend/test/...",
"//executorch/runtime/backend/...",
"//executorch/extension/pybindings/...",
"//executorch/devtools/fb/runners/...",
"//executorch/test/...",
"//executorch/examples/...",
],
# registration of backends is done through a static global
compiler_flags = ["-Wno-global-constructors"],
preprocessor_flags = ["-DUSE_ATEN_LIB"] if aten_mode else [],
exported_deps = [
"//executorch/runtime/backend:interface" + aten_suffix,
],
# TestBackendCompilerLib.cpp needs to compile with executor as whole
# @lint-ignore BUCKLINT: Avoid `link_whole=True` (https://fburl.com/avoid-link-whole)
link_whole = True,
)
runtime.cxx_test(
name = "executor_test" + aten_suffix,
srcs = [
"executor_test.cpp",
],
deps = [
"//executorch/extension/pytree:pytree",
"//executorch/kernels/portable:generated_lib" + aten_suffix,
"//executorch/runtime/core/exec_aten/testing_util:tensor_util" + aten_suffix,
"//executorch/runtime/core/exec_aten:lib" + aten_suffix,
"//executorch/runtime/core:evalue" + aten_suffix,
"//executorch/runtime/kernel:kernel_runtime_context" + aten_suffix,
"//executorch/runtime/kernel:operator_registry" + aten_suffix,
"//executorch/runtime/platform:platform",
],
)
runtime.cxx_library(
name = "managed_memory_manager",
srcs = [],
exported_headers = [
"managed_memory_manager.h",
],
visibility = [
"//executorch/runtime/executor/test/...",
"//executorch/test/...",
"@EXECUTORCH_CLIENTS",
],
deps = [
"//executorch/runtime/core:memory_allocator",
"//executorch/runtime/executor:memory_manager",
],
)
runtime.cxx_test(
name = "pte_data_map_test",
srcs = [
"pte_data_map_test.cpp",
],
deps = [
"//executorch/extension/data_loader:file_data_loader",
"//executorch/extension/testing_util:temp_file",
"//executorch/runtime/executor:pte_data_map",
"//executorch/schema:program",
],
)
# TODO(dbort): Find a way to make these run for ANDROID/APPLE in xplat. The
# android and ios test determinators don't like the reference to the model
# file in fbcode. See https://fburl.com/9esapdmd
if not runtime.is_oss and is_fbcode:
modules_env = {
# Deprecated model that still works with ExecuTorch runtime.
"DEPRECATED_ET_MODULE_LINEAR_CONSTANT_BUFFER_PATH": "$(location fbcode//executorch/test/models/deprecated:ModuleLinear-no-constant-segment.pte)",
# The tests use this var to find the program file to load. This uses
# an fbcode target path because the authoring/export tools
# intentionally don't work in xplat (since they're host-only tools).
"ET_MODULE_ADD_HALF_PATH": "$(location fbcode//executorch/test/models:exported_programs[ModuleAddHalf.pte])",
"ET_MODULE_ADD_PATH": "$(location fbcode//executorch/test/models:exported_programs[ModuleAdd.pte])",
"ET_MODULE_DYNAMIC_CAT_UNALLOCATED_IO_PATH": "$(location fbcode//executorch/test/models:exported_programs[ModuleDynamicCatUnallocatedIO.pte])",
"ET_MODULE_INDEX_PATH": "$(location fbcode//executorch/test/models:exported_programs[ModuleIndex.pte])",
"ET_MODULE_LINEAR_PATH": "$(location fbcode//executorch/test/models:exported_programs[ModuleLinear.pte])",
"ET_MODULE_MULTI_ENTRY_PATH": "$(location fbcode//executorch/test/models:exported_programs[ModuleMultipleEntry.pte])",
"ET_MODULE_SIMPLE_TRAIN_PATH": "$(location fbcode//executorch/test/models:exported_programs[ModuleSimpleTrain.pte])",
"ET_MODULE_STATEFUL_PATH": "$(location fbcode//executorch/test/models:exported_programs[ModuleStateful.pte])",
"ET_MODULE_LINEAR_PROGRAM_PATH": "$(location fbcode//executorch/test/models:exported_program_and_data[ModuleLinear.pte])",
"ET_MODULE_LINEAR_DATA_PATH": "$(location fbcode//executorch/test/models:exported_program_and_data[ModuleLinear.ptd])",
}
runtime.cxx_test(
name = "allocation_failure_stress_test",
srcs = [
"allocation_failure_stress_test.cpp",
],
deps = [
":managed_memory_manager",
"//executorch/runtime/executor:program",
"//executorch/kernels/portable:generated_lib",
"//executorch/extension/data_loader:file_data_loader",
"//executorch/extension/runner_util:inputs",
],
env = modules_env,
)
runtime.cxx_test(
name = "method_test",
srcs = [
"method_test.cpp",
],
deps = [
":managed_memory_manager",
"//executorch/runtime/executor:program",
"//executorch/extension/data_loader:file_data_loader",
"//executorch/extension/flat_tensor:flat_tensor_data_map",
"//executorch/extension/runner_util:inputs",
"//executorch/kernels/portable:generated_lib",
],
env = modules_env,
)
runtime.cxx_test(
name = "method_meta_test",
srcs = [
"method_meta_test.cpp",
],
deps = [
"//executorch/runtime/executor:program",
"//executorch/extension/data_loader:file_data_loader",
],
env = modules_env,
)
runtime.cxx_test(
name = "program_test",
srcs = [
"program_test.cpp",
],
deps = [
"//executorch/runtime/executor:program",
"//executorch/extension/data_loader:buffer_data_loader",
"//executorch/extension/data_loader:file_data_loader",
"//executorch/schema:program",
],
env = modules_env,
)
runtime.cxx_test(
name = "kernel_resolution_test",
srcs = [
"kernel_resolution_test.cpp",
],
deps = [
":managed_memory_manager",
"//executorch/runtime/executor:program",
"//executorch/runtime/kernel:operator_registry",
"//executorch/extension/data_loader:file_data_loader",
],
env = modules_env,
)
runtime.cxx_test(
name = "kernel_integration_test",
srcs = [
"kernel_integration_test.cpp",
],
deps = [
":managed_memory_manager",
"//executorch/extension/data_loader:file_data_loader",
"//executorch/extension/runner_util:inputs",
"//executorch/runtime/core:core",
"//executorch/runtime/executor:program",
"//executorch/runtime/kernel:kernel_runtime_context",
"//executorch/runtime/kernel:operator_registry",
"//executorch/runtime/platform:platform",
],
env = modules_env,
)
runtime.cxx_test(
name = "backend_integration_test",
srcs = [
"backend_integration_test.cpp",
],
deps = [
":managed_memory_manager",
"//executorch/runtime/backend:interface",
"//executorch/runtime/executor:program",
"//executorch/extension/data_loader:buffer_data_loader",
"//executorch/extension/data_loader:file_data_loader",
"//executorch/extension/runner_util:inputs",
],
env = {
# The tests use these vars to find the program files to load.
# Uses an fbcode target path because the authoring/export tools
# intentionally don't work in xplat (since they're host-only
# tools).
"ET_MODULE_ADD_MUL_NOSEGMENTS_DA1024_PATH": "$(location fbcode//executorch/test/models:exported_delegated_add_mul[ModuleAddMul-nosegments-da1024.pte])",
"ET_MODULE_ADD_MUL_NOSEGMENTS_PATH": "$(location fbcode//executorch/test/models:exported_delegated_add_mul[ModuleAddMul-nosegments.pte])",
"ET_MODULE_ADD_MUL_PATH": "$(location fbcode//executorch/test/models:exported_delegated_add_mul[ModuleAddMul.pte])",
},
)
runtime.cxx_test(
name = "memory_manager_test",
srcs = [
"memory_manager_test.cpp",
],
deps = [
"//executorch/runtime/core:memory_allocator",
"//executorch/runtime/executor:memory_manager",
],
)
runtime.cxx_test(
name = "tensor_parser_test",
srcs = [
"tensor_parser_test.cpp",
],
deps = [
":managed_memory_manager",
"//executorch/runtime/executor:program",
"//executorch/extension/data_loader:file_data_loader",
"//executorch/kernels/portable:generated_lib",
"//executorch/schema:program",
],
env = modules_env,
)