@@ -407,6 +407,28 @@ def copy_files(genrule_name, target, file_list):
407
407
default_outs = ["." ],
408
408
)
409
409
410
+ def get_portable_lib_deps ():
411
+ return [
412
+ "//executorch/kernels/portable/cpu:math_constants" ,
413
+ "//executorch/kernels/portable/cpu:scalar_utils" ,
414
+ "//executorch/kernels/portable/cpu:vec_ops" ,
415
+ "//executorch/kernels/portable/cpu/pattern:all_deps" ,
416
+ "//executorch/kernels/portable/cpu/util:all_deps" ,
417
+ ]
418
+
419
+ def get_optimized_lib_deps ():
420
+ return [
421
+ "//executorch/kernels/optimized/cpu:add_sub_impl" ,
422
+ "//executorch/kernels/optimized/cpu:binary_ops" ,
423
+ "//executorch/kernels/optimized/cpu:fft_utils" ,
424
+ "//executorch/kernels/optimized/cpu:moments_utils" ,
425
+ "//executorch/kernels/optimized:libblas" ,
426
+ "//executorch/kernels/optimized:libutils" ,
427
+ "//executorch/kernels/optimized:libvec" ,
428
+ "//executorch/runtime/core/portable_type/c10/c10:aten_headers_for_executorch" ,
429
+ "//executorch/runtime/kernel:kernel_includes" ,
430
+ ] + get_vec_deps ()
431
+
410
432
def build_portable_header_lib (name , oplist_header_name , feature = None ):
411
433
"""Build the portable headers into a header-only library.
412
434
Ensures that includes work across portable and optimized libs.
@@ -453,13 +475,7 @@ def build_portable_lib(name, oplist_header_name, portable_header_lib, feature =
453
475
name = name ,
454
476
srcs = portable_source_files ,
455
477
exported_preprocessor_flags = ["-DEXECUTORCH_SELECTIVE_BUILD_DTYPE" ],
456
- deps = [
457
- "//executorch/kernels/portable/cpu:math_constants" ,
458
- "//executorch/kernels/portable/cpu:scalar_utils" ,
459
- "//executorch/kernels/portable/cpu:vec_ops" ,
460
- "//executorch/kernels/portable/cpu/pattern:all_deps" ,
461
- "//executorch/kernels/portable/cpu/util:all_deps" ,
462
- ] + [":" + portable_header_lib ],
478
+ deps = get_portable_lib_deps () + [":" + portable_header_lib ],
463
479
compiler_flags = compiler_flags ,
464
480
# WARNING: using a deprecated API to avoid being built into a shared
465
481
# library. In the case of dynamically loading so library we don't want
@@ -499,30 +515,12 @@ def build_optimized_lib(name, oplist_header_name, portable_header_lib, feature =
499
515
# This allows operators to be called outside of the kernel registry.
500
516
compiler_flags += ["-fvisibility=hidden" ]
501
517
502
- # Set up dependencies.
503
- portable_lib_deps = [
504
- "//executorch/runtime/core/portable_type/c10/c10:aten_headers_for_executorch" ,
505
- "//executorch/runtime/kernel:kernel_includes" ,
506
- "//executorch/kernels/portable/cpu:scalar_utils" ,
507
- "//executorch/kernels/portable/cpu/pattern:all_deps" ,
508
- "//executorch/kernels/portable/cpu/util:all_deps" ,
509
- ]
510
- optimized_lib_deps = [
511
- "//executorch/kernels/optimized/cpu:add_sub_impl" ,
512
- "//executorch/kernels/optimized/cpu:binary_ops" ,
513
- "//executorch/kernels/optimized/cpu:fft_utils" ,
514
- "//executorch/kernels/optimized/cpu:moments_utils" ,
515
- "//executorch/kernels/optimized:libblas" ,
516
- "//executorch/kernels/optimized:libutils" ,
517
- "//executorch/kernels/optimized:libvec" ,
518
- ] + get_vec_deps ()
519
-
520
518
# Build optimized lib.
521
519
runtime .cxx_library (
522
520
name = name ,
523
521
srcs = optimized_source_files ,
524
522
exported_preprocessor_flags = ["-DEXECUTORCH_SELECTIVE_BUILD_DTYPE" ],
525
- deps = portable_lib_deps + optimized_lib_deps + [":" + portable_header_lib ],
523
+ deps = get_portable_lib_deps () + get_optimized_lib_deps () + [":" + portable_header_lib ],
526
524
compiler_flags = compiler_flags ,
527
525
preprocessor_flags = get_vec_preprocessor_flags (),
528
526
# sleef needs to be added as a direct dependency of the operator target when building for Android,
@@ -651,7 +649,7 @@ def executorch_generated_lib(
651
649
there are undefined symbols otherwise. Please try to use xplat, or talk to the
652
650
executorch team. Setting expose_operator_symbols=True is not recommended as the
653
651
exposed symbols may clash (duplicate symbols errors) if multiple
654
- excutorch_generated_libs are included by a parent library.""" )
652
+ executorch_generated_libs are included by a parent library.""" )
655
653
656
654
if (not "//executorch/kernels/portable:operators" in kernel_deps ) and (not "//executorch/kernels/optimized:optimized_operators" in kernel_deps ):
657
655
fail ("""
@@ -766,8 +764,6 @@ def executorch_generated_lib(
766
764
platforms = platforms ,
767
765
)
768
766
769
- portable_lib = []
770
- optimized_lib = []
771
767
if dtype_selective_build :
772
768
# Build portable headers lib. Used for portable and optimized kernel libraries.
773
769
portable_header_lib = name + "_portable_header_lib"
@@ -780,7 +776,7 @@ def executorch_generated_lib(
780
776
# Build portable lib.
781
777
portable_lib_name = name + "_portable_lib"
782
778
build_portable_lib (portable_lib_name , oplist_header_name , portable_header_lib , feature , expose_operator_symbols )
783
- portable_lib = [ ":{}" .format (portable_lib_name )]
779
+ kernel_deps . append ( ":{}" .format (portable_lib_name ))
784
780
785
781
if "//executorch/kernels/optimized:optimized_operators" in kernel_deps :
786
782
# Remove optimized from kernel_deps as we're building it from source.
@@ -789,7 +785,7 @@ def executorch_generated_lib(
789
785
# Build optimized lib.
790
786
optimized_lib_name = name + "_optimized_lib"
791
787
build_optimized_lib (optimized_lib_name , oplist_header_name , portable_header_lib , feature , expose_operator_symbols )
792
- optimized_lib = [ ":{}" .format (optimized_lib_name )]
788
+ kernel_deps . append ( ":{}" .format (optimized_lib_name ))
793
789
794
790
# Exports headers that declare the function signatures of the C++ functions
795
791
# that map to entries in `functions.yaml` and `custom_ops.yaml`.
@@ -843,7 +839,7 @@ def executorch_generated_lib(
843
839
"//executorch/kernels/prim_ops:prim_ops_registry" + aten_suffix ,
844
840
"//executorch/runtime/core:evalue" + aten_suffix ,
845
841
"//executorch/codegen:macros" ,
846
- ] + deps + kernel_deps + portable_lib + optimized_lib ,
842
+ ] + deps + kernel_deps ,
847
843
exported_deps = [
848
844
"//executorch/runtime/core/exec_aten:lib" + aten_suffix ,
849
845
"//executorch/runtime/kernel:kernel_runtime_context" + aten_suffix ,
0 commit comments