forked from pytorch/executorch
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBUCK
More file actions
103 lines (92 loc) · 4.02 KB
/
BUCK
File metadata and controls
103 lines (92 loc) · 4.02 KB
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
load("@fbcode_macros//build_defs:build_file_migration.bzl", "fbcode_target", "non_fbcode_target")
load("@fbcode_macros//build_defs:cpp_library.bzl", "cpp_library")
load("@fbcode_macros//build_defs:cpp_python_extension.bzl", "cpp_python_extension")
# Any targets that should be shared between fbcode and xplat must be defined in
# targets.bzl. This file can contain fbcode-only targets.
load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")
load("@fbsource//xplat/executorch/extension/pybindings:pybindings.bzl", "ATEN_MODULE_DEPS", "MODELS_ATEN_OPS_ATEN_MODE_GENERATED_LIB", "MODELS_ATEN_OPS_LEAN_MODE_GENERATED_LIB", "PORTABLE_MODULE_DEPS", "executorch_pybindings")
oncall("executorch")
# Export this so the internal fb/ subdir can create pybindings with custom internal deps
# without forking the pybinding source.
fbcode_target(_kind = runtime.export_file,
name = "pybindings.cpp",
visibility = ["//executorch/extension/pybindings/..."],
)
# cxx_python_extension kwarg 'types' can't take export_file rules directly and we need to rename the .pyi
# file to match the lib anyway, so we just expose the file like this and then have genrules consume and
# rename it before passing it to executorch pybindings.
fbcode_target(_kind = runtime.filegroup,
name = "pybinding_types",
srcs = ["pybindings.pyi"],
visibility = ["//executorch/extension/pybindings/..."],
)
# In order to have pyre recognize the pybindings module, the name of the .pyi must exactly match the
# name of the lib. To avoid copy pasting the pyi file in tree a whole bunch of times we use genrules
# to do it for us
fbcode_target(_kind = runtime.genrule,
name = "pybindings_types_gen",
srcs = [":pybinding_types"],
outs = {
"aten_lib.pyi": ["aten_lib.pyi"],
"core.pyi": ["core.pyi"],
"_portable_lib.pyi": ["_portable_lib.pyi"],
},
cmd = "cp $(location :pybinding_types)/* $OUT/_portable_lib.pyi && cp $(location :pybinding_types)/* $OUT/aten_lib.pyi && cp $(location :pybinding_types)/* $OUT/core.pyi",
visibility = ["//executorch/extension/pybindings/..."],
)
fbcode_target(_kind = executorch_pybindings,
cppdeps = PORTABLE_MODULE_DEPS,
python_module_name = "core",
types = ["//executorch/extension/pybindings:pybindings_types_gen[core.pyi]"],
visibility = ["PUBLIC"],
)
fbcode_target(_kind = executorch_pybindings,
cppdeps = PORTABLE_MODULE_DEPS + MODELS_ATEN_OPS_LEAN_MODE_GENERATED_LIB,
# Give this an underscore prefix because it has a pure python wrapper.
python_module_name = "_portable_lib",
types = ["//executorch/extension/pybindings:pybindings_types_gen[_portable_lib.pyi]"],
visibility = ["PUBLIC"],
)
fbcode_target(_kind = executorch_pybindings,
cppdeps = ATEN_MODULE_DEPS + MODELS_ATEN_OPS_ATEN_MODE_GENERATED_LIB,
python_module_name = "aten_lib",
types = ["//executorch/extension/pybindings:pybindings_types_gen[aten_lib.pyi]"],
visibility = ["PUBLIC"],
)
fbcode_target(_kind = runtime.python_library,
name = "portable_lib",
srcs = ["portable_lib.py"],
visibility = ["PUBLIC"],
deps = [
":_portable_lib",
"//executorch/exir:_warnings",
],
)
# Header-only library that provides PyDataLoader for external pybinding extensions.
# This allows external libraries (like PTEZ) to create custom data loaders that can
# be passed to _load_for_executorch_from_data_loader().
fbcode_target(
_kind = cpp_library,
name = "data_loader_types",
headers = ["pybindings_data_loader.h"],
exported_deps = [
"//executorch/runtime/core:core",
],
visibility = ["PUBLIC"],
)
# Python extension that registers the PyDataLoader type.
# This allows external libraries to create PyDataLoader instances without
# importing the full core pybindings.
fbcode_target(
_kind = cpp_python_extension,
name = "data_loader",
srcs = ["pybindings_data_loader.cpp"],
base_module = "executorch.extension.pybindings",
deps = [
":data_loader_types",
],
external_deps = [
"pybind11",
],
visibility = ["PUBLIC"],
)