File tree Expand file tree Collapse file tree 4 files changed +12
-3
lines changed
runtime/core/portable_type/c10/c10 Expand file tree Collapse file tree 4 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -645,13 +645,18 @@ target_link_options_shared_lib(executorch)
645645# Real integrations should supply their own YAML file that only lists the
646646# operators necessary for the models that will run.
647647#
648+ if (EXECUTORCH_BUILD_KERNELS_OPTIMIZED)
649+ # find pytorch lib here to make it available to all
650+ # sub-directories. Find it before including portable so that
651+ # optimized_portable_kernels can use it.
652+ find_package_torch_headers()
653+ endif ()
654+
648655if (BUILD_EXECUTORCH_PORTABLE_OPS)
649656 add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR} /kernels/portable)
650657endif ()
651658
652659if (EXECUTORCH_BUILD_KERNELS_OPTIMIZED)
653- # find pytorch lib here to make it available to all sub-directories
654- find_package_torch_headers()
655660 add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR} /kernels/optimized)
656661endif ()
657662
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+ }) + ["-DSTANDALONE_TORCH_HEADER" ] + ([] if runtime . is_oss else [ "-DET_USE_PYTORCH_HEADERS" ]) ,
9091 )
You can’t perform that action at this time.
0 commit comments