@@ -66,19 +66,22 @@ target_include_directories(custom_ops PUBLIC "${_common_include_directories}")
66
66
target_include_directories (
67
67
custom_ops PRIVATE "${CMAKE_CURRENT_BINARY_DIR} /../../../../include"
68
68
)
69
- target_link_libraries (custom_ops PUBLIC ${custom_ops_libs} executorch_no_prim_ops )
69
+ target_link_libraries (
70
+ custom_ops PUBLIC ${custom_ops_libs} executorch_no_prim_ops
71
+ )
70
72
71
73
target_compile_options (
72
74
custom_ops PUBLIC ${_common_compile_options} -DET_USE_THREADPOOL
73
75
)
74
76
75
77
install (TARGETS custom_ops DESTINATION lib )
76
78
77
- if (EXECUTORCH_BUILD_KERNELS_CUSTOM_AOT AND EXECUTORCH_BUILD_PYBIND )
79
+ if (EXECUTORCH_BUILD_KERNELS_CUSTOM_AOT )
78
80
# Add a AOT library
79
81
find_package (Torch CONFIG REQUIRED )
80
82
add_library (
81
- custom_ops_aot_lib SHARED ${_custom_ops__srcs} ${CMAKE_CURRENT_SOURCE_DIR} /op_sdpa_aot.cpp
83
+ custom_ops_aot_lib SHARED ${_custom_ops__srcs}
84
+ ${CMAKE_CURRENT_SOURCE_DIR} /op_sdpa_aot.cpp
82
85
)
83
86
target_include_directories (
84
87
custom_ops_aot_lib PUBLIC "${_common_include_directories} "
@@ -87,10 +90,21 @@ if(EXECUTORCH_BUILD_KERNELS_CUSTOM_AOT AND EXECUTORCH_BUILD_PYBIND)
87
90
custom_ops_aot_lib
88
91
PRIVATE "${CMAKE_CURRENT_BINARY_DIR} /../../../../include"
89
92
)
90
- target_link_libraries (custom_ops_aot_lib PUBLIC portable_lib cpublas torch )
93
+ if (TARGET portable_lib )
94
+ # If we have portable_lib built, custom_ops_aot_lib gives the ability to use
95
+ # the ops in PyTorch and ExecuTorch through pybind
96
+ target_link_libraries (custom_ops_aot_lib PUBLIC portable_lib )
97
+ else ()
98
+ # If no portable_lib, custom_ops_aot_lib still gives the ability to use the
99
+ # ops in PyTorch
100
+ target_link_libraries (custom_ops_aot_lib PUBLIC executorch_no_prim_ops )
101
+ endif ()
102
+
103
+ target_link_libraries (custom_ops_aot_lib PUBLIC cpublas torch )
91
104
target_compile_options (
92
- custom_ops_aot_lib PUBLIC -Wno-deprecated-declarations -fPIC -frtti
93
- -fexceptions ${_common_compile_options} -DET_USE_THREADPOOL
105
+ custom_ops_aot_lib
106
+ PUBLIC -Wno-deprecated-declarations -fPIC -frtti -fexceptions
107
+ ${_common_compile_options} -DET_USE_THREADPOOL
94
108
)
95
109
96
110
install (TARGETS custom_ops_aot_lib DESTINATION lib )
0 commit comments