File tree Expand file tree Collapse file tree
runtime/core/portable_type/c10/c10 Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -643,13 +643,18 @@ target_link_options_shared_lib(executorch)
643643# Real integrations should supply their own YAML file that only lists the
644644# operators necessary for the models that will run.
645645#
646+ if (EXECUTORCH_BUILD_KERNELS_OPTIMIZED)
647+ # find pytorch lib here to make it available to all
648+ # sub-directories. Find it before including portable so that
649+ # optimized_portabale_kernels can use it.
650+ find_package_torch_headers ()
651+ endif ()
652+
646653if (BUILD_EXECUTORCH_PORTABLE_OPS)
647654 add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR} /kernels/portable )
648655endif ()
649656
650657if (EXECUTORCH_BUILD_KERNELS_OPTIMIZED)
651- # find pytorch lib here to make it available to all sub-directories
652- find_package_torch_headers ()
653658 add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR} /kernels/optimized )
654659endif ()
655660
Original file line number Diff line number Diff line change @@ -62,6 +62,7 @@ message("Generated files ${gen_command_sources}")
6262list (TRANSFORM _optimized_kernels__srcs PREPEND "${EXECUTORCH_ROOT} /" )
6363add_library (optimized_kernels ${_optimized_kernels__srcs} )
6464target_include_directories (optimized_kernels PRIVATE ${TORCH_INCLUDE_DIRS} "${EXECUTORCH_ROOT} /third-party/pocketfft" )
65+ target_compile_definitions (optimized_kernels PRIVATE ET_USE_PYTORCH_HEADERS )
6566target_link_libraries (
6667 optimized_kernels PUBLIC executorch_core cpublas extension_threadpool
6768)
Original file line number Diff line number Diff line change @@ -73,6 +73,8 @@ if(BUILD_OPTIMIZED_PORTABLE_KERNELS)
7373 target_link_libraries (optimized_portable_kernels PRIVATE executorch )
7474 target_link_libraries (optimized_portable_kernels PUBLIC extension_threadpool )
7575 target_compile_options (optimized_portable_kernels PUBLIC ${_common_compile_options} )
76+ target_include_directories (optimized_portable_kernels PRIVATE ${TORCH_INCLUDE_DIRS} )
77+ target_compile_definitions (optimized_portable_kernels PRIVATE ET_USE_PYTORCH_HEADERS )
7678 install (
7779 TARGETS optimized_portable_kernels
7880 DESTINATION lib
Original file line number Diff line number Diff line change @@ -73,6 +73,7 @@ def define_common_targets():
7373 # -Wmacro-redefined, and we only care about getting
7474 # reasonable vectorization and Sleef support.
7575 "-DCPU_CAPABILITY_AVX2" ,
76+ "-DET_USE_PYTORCH_HEADERS" ,
7677 "-DHAVE_AVX2_CPU_DEFINITION" ,
7778 "-DSTANDALONE_TORCH_HEADER" ,
7879 ] + get_sleef_preprocessor_flags (),
@@ -86,5 +87,5 @@ def define_common_targets():
8687 # linker failure.
8788 "ovr_config//cpu:arm64" : get_sleef_preprocessor_flags (),
8889 "DEFAULT" : [],
89- }) + ["-DSTANDALONE_TORCH_HEADER" ],
90+ }) + ["-DET_USE_PYTORCH_HEADERS" , "- DSTANDALONE_TORCH_HEADER" ],
9091 )
You can’t perform that action at this time.
0 commit comments