1+ load ("@fbcode_macros//build_defs:build_file_migration.bzl" , "fbcode_target" , "non_fbcode_target" )
2+ oncall ("executorch" )
13# Any targets that should be shared between fbcode and xplat must be defined in
24# targets.bzl. This file can contain xplat-only targets.
35
810load ("@fbsource//xplat/executorch/build:runtime_wrapper.bzl" , "runtime" )
911load ("@fbsource//xplat/executorch/runtime/core:targets.bzl" , "build_sdk" )
1012
11- oncall ("executorch" )
1213
13- runtime .cxx_library (
14+ non_fbcode_target ( _kind = runtime .cxx_library ,
1415 name = "coreml" ,
1516 srcs = [
1617 "runtime/delegate/ETCoreMLAsset.mm" ,
@@ -135,7 +136,7 @@ _PROTOS = [
135136 "WordTagger" ,
136137]
137138
138- runtime .cxx_test (
139+ non_fbcode_target ( _kind = runtime .cxx_test ,
139140 name = "coreml_backend_options_test" ,
140141 srcs = [
141142 "runtime/test/coreml_backend_options_test.cpp" ,
@@ -149,7 +150,7 @@ runtime.cxx_test(
149150)
150151
151152# Header-only library for CoreML backend options
152- runtime .cxx_library (
153+ non_fbcode_target ( _kind = runtime .cxx_library ,
153154 name = "coreml_backend_options" ,
154155 exported_headers = [
155156 "runtime/include/coreml_backend/coreml_backend_options.h" ,
@@ -161,7 +162,7 @@ runtime.cxx_library(
161162 ],
162163)
163164
164- runtime .cxx_library (
165+ non_fbcode_target ( _kind = runtime .cxx_library ,
165166 name = "proto" ,
166167 srcs = [
167168 "fbsource//third-party/pypi/coremltools:exported-cpp-protoc[{}.pb.cc]" .format (name )
@@ -181,3 +182,166 @@ runtime.cxx_library(
181182 "//third-party/protobuf:fb-protobuf-lite" ,
182183 ],
183184)
185+
186+ # !!!! fbcode/executorch/backends/apple/coreml/TARGETS was merged into this file, see https://fburl.com/workplace/xl8l9yuo for more info !!!!
187+
188+ # Any targets that should be shared between fbcode and xplat must be defined in
189+ # targets.bzl. This file can contain fbcode-only targets.
190+
191+ load ("@fbsource//xplat/executorch/build:runtime_wrapper.bzl" , "runtime" )
192+
193+
194+ # TODO: this is a placeholder to support internal fbcode build. We should add the coreml backend target properly.
195+ fbcode_target (_kind = runtime .python_library ,
196+ name = "coreml" ,
197+ visibility = ["PUBLIC" ],
198+ )
199+
200+ fbcode_target (_kind = runtime .python_library ,
201+ name = "backend" ,
202+ srcs = glob ([
203+ "compiler/*.py" ,
204+ "logging.py" ,
205+ ]),
206+ visibility = ["PUBLIC" ],
207+ deps = [
208+ "fbsource//third-party/pypi/coremltools:coremltools" ,
209+ ":executorchcoreml" ,
210+ "//executorch/exir/backend:backend_details" ,
211+ "//executorch/exir/backend:compile_spec_schema" ,
212+ ],
213+ )
214+
215+ fbcode_target (_kind = runtime .python_library ,
216+ name = "partitioner" ,
217+ srcs = glob ([
218+ "partition/*.py" ,
219+ "logging.py" ,
220+ ]),
221+ visibility = ["PUBLIC" ],
222+ deps = [
223+ "fbsource//third-party/pypi/coremltools:coremltools" ,
224+ ":backend" ,
225+ "//caffe2:torch" ,
226+ "//executorch/exir:lib" ,
227+ "//executorch/exir/backend:compile_spec_schema" ,
228+ "//executorch/exir/backend:partitioner" ,
229+ "//executorch/exir/backend:utils" ,
230+ ],
231+ )
232+
233+ fbcode_target (_kind = runtime .python_library ,
234+ name = "quantizer" ,
235+ srcs = glob ([
236+ "quantizer/*.py" ,
237+ ]),
238+ visibility = ["PUBLIC" ],
239+ )
240+
241+ fbcode_target (_kind = runtime .python_library ,
242+ name = "coreml_recipes" ,
243+ srcs = [
244+ "recipes/__init__.py" ,
245+ "recipes/coreml_recipe_provider.py"
246+ ],
247+ visibility = ["PUBLIC" ],
248+ deps = [
249+ "fbsource//third-party/pypi/coremltools:coremltools" ,
250+ ":coreml_recipe_types" ,
251+ ":backend" ,
252+ ":partitioner" ,
253+ ":quantizer" ,
254+ "//caffe2:torch" ,
255+ "//executorch/exir:lib" ,
256+ "//executorch/exir/backend:compile_spec_schema" ,
257+ "//executorch/exir/backend:partitioner" ,
258+ "//executorch/exir/backend:utils" ,
259+ "//executorch/export:lib" ,
260+ "//executorch/runtime:runtime" , # @manual
261+ ],
262+ )
263+
264+ fbcode_target (_kind = runtime .python_library ,
265+ name = "coreml_recipe_types" ,
266+ srcs = [
267+ "recipes/coreml_recipe_types.py" ,
268+ ],
269+ visibility = ["PUBLIC" ],
270+ deps = [
271+ "//executorch/export:recipe" ,
272+ ],
273+ )
274+
275+ fbcode_target (_kind = runtime .cxx_python_extension ,
276+ name = "executorchcoreml" ,
277+ srcs = [
278+ "runtime/inmemoryfs/inmemory_filesystem.cpp" ,
279+ "runtime/inmemoryfs/inmemory_filesystem_py.cpp" ,
280+ "runtime/inmemoryfs/inmemory_filesystem_utils.cpp" ,
281+ "runtime/inmemoryfs/memory_buffer.cpp" ,
282+ "runtime/inmemoryfs/memory_stream.cpp" ,
283+ "runtime/inmemoryfs/reversed_memory_stream.cpp" ,
284+ "runtime/util/json_util.cpp" ,
285+ ],
286+ headers = glob ([
287+ "runtime/inmemoryfs/**/*.hpp" ,
288+ ]),
289+ base_module = "executorch.backends.apple.coreml" ,
290+ compiler_flags = [
291+ "-std=c++17" ,
292+ ],
293+ preprocessor_flags = [
294+ "-Iexecutorch/backends/apple/coreml/runtime/util" ,
295+ ],
296+ types = [
297+ "executorchcoreml.pyi" ,
298+ ],
299+ visibility = ["PUBLIC" ],
300+ deps = [
301+ "fbsource//third-party/nlohmann-json:nlohmann-json" ,
302+ "fbsource//third-party/pybind11:pybind11" ,
303+ ],
304+ )
305+
306+ fbcode_target (_kind = runtime .python_test ,
307+ name = "test" ,
308+ srcs = glob ([
309+ "test/*.py" ,
310+ ]),
311+ deps = [
312+ "fbsource//third-party/pypi/coremltools:coremltools" ,
313+ "fbsource//third-party/pypi/pytest:pytest" ,
314+ ":partitioner" ,
315+ ":quantizer" ,
316+ ":coreml_recipes" ,
317+ "//caffe2:torch" ,
318+ "//pytorch/vision:torchvision" ,
319+ "fbsource//third-party/pypi/scikit-learn:scikit-learn" ,
320+ ],
321+ )
322+
323+ # Header-only library for CoreML backend options
324+ fbcode_target (_kind = runtime .cxx_library ,
325+ name = "coreml_backend_options" ,
326+ exported_headers = [
327+ "runtime/include/coreml_backend/coreml_backend_options.h" ,
328+ ],
329+ header_namespace = "executorch/backends/apple/coreml" ,
330+ visibility = ["PUBLIC" ],
331+ exported_deps = [
332+ "//executorch/runtime/backend:backend_options" ,
333+ ],
334+ )
335+
336+ fbcode_target (_kind = runtime .cxx_test ,
337+ name = "coreml_backend_options_test" ,
338+ srcs = [
339+ "runtime/test/coreml_backend_options_test.cpp" ,
340+ ],
341+ deps = [
342+ ":coreml_backend_options" ,
343+ "//executorch/runtime/backend:backend_options" ,
344+ "//executorch/runtime/backend:backend_options_map" ,
345+ "//executorch/runtime/core:core" ,
346+ ],
347+ )
0 commit comments