Skip to content

Commit 6b055a4

Browse files
JacobSzwejbkafacebook-github-bot
authored andcommitted
fb/ pybindings
Summary: Before we had 2 pybinding libs. Portable and ATen. Now we have 4. Portable, Portable+custom, ATen, ATen + Custom. The + Custom variants are internal only (as they include all the internal custom ops). Reviewed By: dbort Differential Revision: D47775647 fbshipit-source-id: a7cda8cc051304ed980c19560ae32d2feb3bb505
1 parent ff09bd0 commit 6b055a4

File tree

5 files changed

+22
-28
lines changed

5 files changed

+22
-28
lines changed

backends/test/demos/rpc/targets.bzl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ load(
44
"CXX",
55
)
66
load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")
7-
load("@fbsource//xplat/executorch/extension/pybindings:targets.bzl", "MODELS_ALL_OPS_LEAN_MODE_GENERATED_LIB")
7+
load("@fbsource//xplat/executorch/extension/pybindings:targets.bzl", "MODELS_ATEN_OPS_LEAN_MODE_GENERATED_LIB")
88

99
def define_common_targets():
1010
"""Defines targets that should be shared between fbcode and xplat.
@@ -28,7 +28,7 @@ def define_common_targets():
2828
"//executorch/runtime/backend:backend_registry",
2929
"//executorch/extension/data_loader:buffer_data_loader",
3030
"//executorch/util:util",
31-
] + MODELS_ALL_OPS_LEAN_MODE_GENERATED_LIB,
31+
] + MODELS_ATEN_OPS_LEAN_MODE_GENERATED_LIB,
3232
exported_deps = [
3333
"//executorch/runtime/core:core",
3434
],

extension/pybindings/TARGETS

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Any targets that should be shared between fbcode and xplat must be defined in
33
# targets.bzl. This file can contain fbcode-only targets.
44

5-
load("@fbcode//executorch/extension/pybindings:targets.bzl", "MODELS_ALL_OPS_ATEN_MODE_GENERATED_LIB", "MODELS_ALL_OPS_LEAN_MODE_GENERATED_LIB", "MODULE_DEPS", "define_common_targets", "executorch_pybindings")
5+
load("@fbcode//executorch/extension/pybindings:targets.bzl", "MODELS_ATEN_OPS_ATEN_MODE_GENERATED_LIB", "MODELS_ATEN_OPS_LEAN_MODE_GENERATED_LIB", "MODULE_DEPS", "define_common_targets", "executorch_pybindings")
66
load("@fbcode_macros//build_defs:python_library.bzl", "python_library")
77

88
define_common_targets()
@@ -20,7 +20,7 @@ executorch_pybindings(
2020
srcs = [
2121
"module.cpp",
2222
],
23-
cppdeps = MODULE_DEPS + MODELS_ALL_OPS_LEAN_MODE_GENERATED_LIB,
23+
cppdeps = MODULE_DEPS + MODELS_ATEN_OPS_LEAN_MODE_GENERATED_LIB,
2424
python_module_name = "portable",
2525
visibility = ["PUBLIC"],
2626
)
@@ -42,7 +42,7 @@ executorch_pybindings(
4242
"//executorch/util:bundled_program_verification_aten",
4343
"//caffe2:torch-cpp",
4444
"//executorch/runtime/executor/test:test_backend_compiler_lib_aten",
45-
] + MODELS_ALL_OPS_ATEN_MODE_GENERATED_LIB,
45+
] + MODELS_ATEN_OPS_ATEN_MODE_GENERATED_LIB,
4646
python_module_name = "aten_mode_lib",
4747
visibility = ["PUBLIC"],
4848
)

extension/pybindings/targets.bzl

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,6 @@ MODELS_ATEN_OPS_LEAN_MODE_GENERATED_LIB = [
66
"//executorch/kernels/portable:generated_lib",
77
]
88

9-
# Custom ops with portable kernel
10-
MODELS_CUSTOM_OPS_LEAN_MODE_GENERATED_LIB = [
11-
"//executorch/kernels/quantized:generated_lib",
12-
"//pye/model_inventory/asr_models/runtime:generated_custom_op_lib_lean",
13-
]
14-
15-
MODELS_ALL_OPS_LEAN_MODE_GENERATED_LIB = MODELS_ATEN_OPS_LEAN_MODE_GENERATED_LIB + MODELS_CUSTOM_OPS_LEAN_MODE_GENERATED_LIB
16-
179
MODULE_DEPS = [
1810
"//caffe2:ATen",
1911
"//caffe2:torch",
@@ -37,22 +29,11 @@ MODELS_ATEN_OPS_ATEN_MODE_GENERATED_LIB = [
3729
"//executorch/kernels/aten:generated_lib_aten",
3830
]
3931

40-
# Generated libs for all ATen ops AND custom ops used by models in //pye/model_inventory
41-
MODELS_ALL_OPS_ATEN_MODE_GENERATED_LIB = MODELS_ATEN_OPS_ATEN_MODE_GENERATED_LIB + [
42-
"//caffe2/fb/custom_ops/turing:turing_lib_aten",
43-
"//pye/model_inventory/asr_models/runtime:generated_lib_aten",
44-
"//pye/model_inventory/asr_models/runtime:custom_ops_generated_lib_aten",
45-
"//pye/model_inventory/fam_models/runtime:generated_lib_aten",
46-
"//pye/model_inventory/ocr_detection_model_non_quantized/runtime:generated_lib_aten",
47-
"//caffe2/fb/custom_ops/nimble/et_runtime:generated_lib_aten",
48-
"//pye/model_inventory/keyboard_tracking_model/runtime:generated_lib_aten",
49-
]
50-
5132
def executorch_pybindings(python_module_name, srcs = [], cppdeps = [], visibility = ["//executorch/..."]):
5233
runtime.cxx_python_extension(
5334
name = python_module_name,
5435
srcs = [
55-
"pybindings.cpp",
36+
"//executorch/extension/pybindings:pybindings.cpp",
5637
] + srcs,
5738
base_module = "executorch.extension.pybindings",
5839
preprocessor_flags = [
@@ -78,6 +59,18 @@ def define_common_targets():
7859
TARGETS and BUCK files that call this function.
7960
"""
8061

62+
# Export these so the internal fb/ subdir can create pybindings with custom internal deps
63+
# without forking the pybinding source.
64+
runtime.export_file(
65+
name = "pybindings.cpp",
66+
visibility = ["//executorch/extension/pybindings/..."],
67+
)
68+
69+
runtime.export_file(
70+
name = "module.cpp",
71+
visibility = ["//executorch/extension/pybindings/..."],
72+
)
73+
8174
executorch_pybindings(
8275
srcs = [
8376
"module_stub.cpp",

sdk/runners/targets.bzl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ load(
44
"CXX",
55
)
66
load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")
7-
load("@fbsource//xplat/executorch/extension/pybindings:targets.bzl", "MODELS_ALL_OPS_ATEN_MODE_GENERATED_LIB", "MODELS_ALL_OPS_LEAN_MODE_GENERATED_LIB")
7+
load("@fbsource//xplat/executorch/extension/pybindings:targets.bzl", "MODELS_ATEN_OPS_ATEN_MODE_GENERATED_LIB", "MODELS_ATEN_OPS_LEAN_MODE_GENERATED_LIB")
88

99
def define_common_targets():
1010
"""Defines targets that should be shared between fbcode and xplat.
@@ -27,9 +27,9 @@ def define_common_targets():
2727
"//executorch/extension/data_loader:buffer_data_loader",
2828
"//executorch/extension/data_loader:file_data_loader",
2929
"//executorch/util:util" + aten_suffix,
30-
] + (MODELS_ALL_OPS_ATEN_MODE_GENERATED_LIB if aten_mode else [
30+
] + (MODELS_ATEN_OPS_ATEN_MODE_GENERATED_LIB if aten_mode else [
3131
"//executorch/configurations:executor_cpu_optimized",
32-
] + MODELS_ALL_OPS_LEAN_MODE_GENERATED_LIB),
32+
] + MODELS_ATEN_OPS_LEAN_MODE_GENERATED_LIB),
3333
preprocessor_flags = ["-DUSE_ATEN_LIB"] if aten_mode else [],
3434
external_deps = [
3535
"gflags",

shim/xplat/executorch/build/runtime_wrapper.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ def _cxx_test(*args, **kwargs):
267267

268268
def _cxx_python_extension(*args, **kwargs):
269269
_patch_kwargs_common(kwargs)
270+
kwargs["srcs"] = _patch_executorch_references(kwargs["srcs"])
270271
env.cxx_python_extension(*args, **kwargs)
271272

272273
def _export_file(*args, **kwargs):

0 commit comments

Comments
 (0)