@@ -407,6 +407,28 @@ def copy_files(genrule_name, target, file_list):
407407 default_outs = ["." ],
408408 )
409409
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+
410432def build_portable_header_lib (name , oplist_header_name , feature = None ):
411433 """Build the portable headers into a header-only library.
412434 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 =
453475 name = name ,
454476 srcs = portable_source_files ,
455477 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 ],
463479 compiler_flags = compiler_flags ,
464480 # WARNING: using a deprecated API to avoid being built into a shared
465481 # 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 =
499515 # This allows operators to be called outside of the kernel registry.
500516 compiler_flags += ["-fvisibility=hidden" ]
501517
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-
520518 # Build optimized lib.
521519 runtime .cxx_library (
522520 name = name ,
523521 srcs = optimized_source_files ,
524522 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 ],
526524 compiler_flags = compiler_flags ,
527525 preprocessor_flags = get_vec_preprocessor_flags (),
528526 # 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(
651649 there are undefined symbols otherwise. Please try to use xplat, or talk to the
652650 executorch team. Setting expose_operator_symbols=True is not recommended as the
653651 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.""" )
655653
656654 if (not "//executorch/kernels/portable:operators" in kernel_deps ) and (not "//executorch/kernels/optimized:optimized_operators" in kernel_deps ):
657655 fail ("""
@@ -766,8 +764,6 @@ def executorch_generated_lib(
766764 platforms = platforms ,
767765 )
768766
769- portable_lib = []
770- optimized_lib = []
771767 if dtype_selective_build :
772768 # Build portable headers lib. Used for portable and optimized kernel libraries.
773769 portable_header_lib = name + "_portable_header_lib"
@@ -780,7 +776,7 @@ def executorch_generated_lib(
780776 # Build portable lib.
781777 portable_lib_name = name + "_portable_lib"
782778 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 ))
784780
785781 if "//executorch/kernels/optimized:optimized_operators" in kernel_deps :
786782 # Remove optimized from kernel_deps as we're building it from source.
@@ -789,7 +785,7 @@ def executorch_generated_lib(
789785 # Build optimized lib.
790786 optimized_lib_name = name + "_optimized_lib"
791787 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 ))
793789
794790 # Exports headers that declare the function signatures of the C++ functions
795791 # that map to entries in `functions.yaml` and `custom_ops.yaml`.
@@ -843,7 +839,7 @@ def executorch_generated_lib(
843839 "//executorch/kernels/prim_ops:prim_ops_registry" + aten_suffix ,
844840 "//executorch/runtime/core:evalue" + aten_suffix ,
845841 "//executorch/codegen:macros" ,
846- ] + deps + kernel_deps + portable_lib + optimized_lib ,
842+ ] + deps + kernel_deps ,
847843 exported_deps = [
848844 "//executorch/runtime/core/exec_aten:lib" + aten_suffix ,
849845 "//executorch/runtime/kernel:kernel_runtime_context" + aten_suffix ,
0 commit comments