1
- load ("@fbsource//tools/build_defs:fbsource_utils.bzl" , "is_xplat" )
2
1
load ("@fbsource//xplat/executorch/build:runtime_wrapper.bzl" , "get_default_executorch_platforms" , "runtime" )
3
2
4
3
# Headers that declare the function signatures of the C++ functions that
@@ -111,11 +110,13 @@ def _prepare_genrule_and_lib(
111
110
},
112
111
}
113
112
"""
113
+ target = runtime .external_dep_location ("gen-executorch" )
114
+ aten_src_path = runtime .external_dep_location ("aten-src-path" )
114
115
genrule_cmd = [
115
- "$(exe " + runtime . external_dep_location ( "gen-executorch" ) + ")" ,
116
+ "$(exe {})" . format ( target ) ,
116
117
"--source-path=$(location //executorch/codegen:templates)" ,
117
- "--tags-path $(location " + runtime . external_dep_location ( "aten-src-path" ) + ") /aten/src/ATen/native/tags.yaml" ,
118
- "--aten_yaml_path $(location " + runtime . external_dep_location ( "aten-src-path" ) + ") /aten/src/ATen/native/native_functions.yaml" ,
118
+ "--tags-path $(location {}) /aten/src/ATen/native/tags.yaml" . format ( aten_src_path ) ,
119
+ "--aten_yaml_path $(location {}) /aten/src/ATen/native/native_functions.yaml" . format ( aten_src_path ) ,
119
120
"--install_dir=${OUT}" ,
120
121
# TODO(dbort): Add a second step that verifies that the set of
121
122
# actually-generated files matches GENERATED_FILES.
@@ -146,7 +147,7 @@ def _prepare_genrule_and_lib(
146
147
147
148
if need_reg_aten_ops :
148
149
path = (
149
- "$(location fbsource//xplat/caffe2:aten_src_path )/aten/src/ATen/native/native_functions.yaml"
150
+ "$(location {} )/aten/src/ATen/native/native_functions.yaml" . format ( aten_src_path )
150
151
) if not functions_yaml_path else functions_yaml_path
151
152
genrule_cmd = genrule_cmd + [
152
153
"--functions_yaml_path={}" .format (path ),
@@ -341,8 +342,6 @@ def executorch_generated_lib(
341
342
],
342
343
)
343
344
344
- xplat_deps = xplat_deps + (["//xplat/caffe2:torch_mobile_all_ops" ] if aten_mode and use_default_aten_ops_lib else [])
345
- fbcode_deps = fbcode_deps + (["//caffe2:libtorch" ] if aten_mode and use_default_aten_ops_lib else [])
346
345
if name in libs :
347
346
lib_name = name
348
347
runtime .cxx_library (
@@ -376,6 +375,7 @@ def executorch_generated_lib(
376
375
],
377
376
xplat_deps = xplat_deps ,
378
377
fbcode_deps = fbcode_deps ,
378
+ external_deps = ["libtorch" ] if aten_mode and use_default_aten_ops_lib else [],
379
379
define_static_target = define_static_targets ,
380
380
# Relax visibility restrictions since deps may include targets outside
381
381
# of //executorch.
@@ -392,12 +392,6 @@ def executorch_generated_lib(
392
392
# custom_ops_requires_runtime_registration is True.
393
393
compiler_lib = "custom_ops_" + name if "custom_ops_" + name in libs else None
394
394
if compiler_lib :
395
- # The library needs to be able to include <torch/library.h>.
396
- if is_xplat ():
397
- torch_dep = ["//xplat/caffe2:torch" ]
398
- else :
399
- torch_dep = ["//caffe2:libtorch" ]
400
-
401
395
# TODO(T129125039): Rename this to make it clear that it's not part of
402
396
# the embedded runtime; it's only for registering custom ops with the
403
397
# PyTorch authoring runtime.
@@ -419,10 +413,11 @@ def executorch_generated_lib(
419
413
"//executorch/runtime/core/exec_aten:lib_aten" ,
420
414
"//executorch/runtime/core:core" ,
421
415
"//executorch/codegen:macros" ,
422
- ] + torch_dep + custom_ops_aten_kernel_deps ,
416
+ ] + custom_ops_aten_kernel_deps ,
423
417
exported_deps = [
424
418
"//executorch/runtime/kernel:kernel_runtime_context_aten" ,
425
419
],
420
+ external_deps = ["libtorch" ],
426
421
define_static_target = define_static_targets ,
427
422
# Relax visibility restrictions since deps may include targets
428
423
# outside of //executorch.
0 commit comments