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 @@ -643,13 +643,18 @@ target_link_options_shared_lib(executorch)
643
643
# Real integrations should supply their own YAML file that only lists the
644
644
# operators necessary for the models that will run.
645
645
#
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_portable_kernels can use it.
650
+ find_package_torch_headers ()
651
+ endif ()
652
+
646
653
if (BUILD_EXECUTORCH_PORTABLE_OPS )
647
654
add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR} /kernels/portable )
648
655
endif ()
649
656
650
657
if (EXECUTORCH_BUILD_KERNELS_OPTIMIZED )
651
- # find pytorch lib here to make it available to all sub-directories
652
- find_package_torch_headers ()
653
658
add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR} /kernels/optimized )
654
659
endif ()
655
660
Original file line number Diff line number Diff line change @@ -62,6 +62,7 @@ message("Generated files ${gen_command_sources}")
62
62
list (TRANSFORM _optimized_kernels__srcs PREPEND "${EXECUTORCH_ROOT} /" )
63
63
add_library (optimized_kernels ${_optimized_kernels__srcs} )
64
64
target_include_directories (optimized_kernels PRIVATE ${TORCH_INCLUDE_DIRS} "${EXECUTORCH_ROOT} /third-party/pocketfft" )
65
+ target_compile_definitions (optimized_kernels PRIVATE ET_USE_PYTORCH_HEADERS )
65
66
target_link_libraries (
66
67
optimized_kernels PUBLIC executorch_core cpublas extension_threadpool
67
68
)
Original file line number Diff line number Diff line change @@ -73,6 +73,8 @@ if(BUILD_OPTIMIZED_PORTABLE_KERNELS)
73
73
target_link_libraries (optimized_portable_kernels PRIVATE executorch )
74
74
target_link_libraries (optimized_portable_kernels PUBLIC extension_threadpool )
75
75
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 )
76
78
install (
77
79
TARGETS optimized_portable_kernels
78
80
DESTINATION lib
Original file line number Diff line number Diff line change @@ -73,6 +73,7 @@ def define_common_targets():
73
73
# -Wmacro-redefined, and we only care about getting
74
74
# reasonable vectorization and Sleef support.
75
75
"-DCPU_CAPABILITY_AVX2" ,
76
+ "-DET_USE_PYTORCH_HEADERS" ,
76
77
"-DHAVE_AVX2_CPU_DEFINITION" ,
77
78
"-DSTANDALONE_TORCH_HEADER" ,
78
79
] + get_sleef_preprocessor_flags (),
@@ -86,5 +87,5 @@ def define_common_targets():
86
87
# linker failure.
87
88
"ovr_config//cpu:arm64" : get_sleef_preprocessor_flags (),
88
89
"DEFAULT" : [],
89
- }) + ["-DSTANDALONE_TORCH_HEADER" ],
90
+ }) + ["-DSTANDALONE_TORCH_HEADER" ] + ([] if runtime . is_oss else [ "-DET_USE_PYTORCH_HEADERS" ]) ,
90
91
)
You can’t perform that action at this time.
0 commit comments