File tree 4 files changed +12
-3
lines changed
runtime/core/portable_type/c10/c10
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)
645
645
# Real integrations should supply their own YAML file that only lists the
646
646
# operators necessary for the models that will run.
647
647
#
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
+
648
655
if (BUILD_EXECUTORCH_PORTABLE_OPS)
649
656
add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR} /kernels/portable)
650
657
endif ()
651
658
652
659
if (EXECUTORCH_BUILD_KERNELS_OPTIMIZED)
653
- # find pytorch lib here to make it available to all sub-directories
654
- find_package_torch_headers()
655
660
add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR} /kernels/optimized)
656
661
endif ()
657
662
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