diff --git a/.ci/docker/ci_commit_pins/pytorch.txt b/.ci/docker/ci_commit_pins/pytorch.txt index 9c24945f7d..8fb1371869 100644 --- a/.ci/docker/ci_commit_pins/pytorch.txt +++ b/.ci/docker/ci_commit_pins/pytorch.txt @@ -1 +1 @@ -2ea4b56ec872424e486c4fe2d55da061067a2ed3 +f0c50a619c282a01ef1ad33690b7ab5e615d9fef diff --git a/build/Codegen.cmake b/build/Codegen.cmake index 435b3d2480..abadadd444 100644 --- a/build/Codegen.cmake +++ b/build/Codegen.cmake @@ -11,13 +11,14 @@ # arguments. function(gen_selected_ops) set(arg_names LIB_NAME OPS_SCHEMA_YAML ROOT_OPS INCLUDE_ALL_OPS) - cmake_parse_arguments(GEN "" "" "${arg_names}" ${ARGN}) + cmake_parse_arguments(GEN "${options}" "" "${arg_names}" ${ARGN}) message(STATUS "Generating operator lib:") message(STATUS " LIB_NAME: ${GEN_LIB_NAME}") message(STATUS " OPS_SCHEMA_YAML: ${GEN_OPS_SCHEMA_YAML}") message(STATUS " ROOT_OPS: ${GEN_ROOT_OPS}") message(STATUS " INCLUDE_ALL_OPS: ${GEN_INCLUDE_ALL_OPS}") + message(STATUS " ADD_EXCEPTION_BOUNDARY: ${GEN_ADD_EXCEPTION_BOUNDARTY}") set(_oplist_yaml ${CMAKE_CURRENT_BINARY_DIR}/${GEN_LIB_NAME}/selected_operators.yaml @@ -59,13 +60,15 @@ endfunction() # Invoked as generate_bindings_for_kernels( LIB_NAME lib_name FUNCTIONS_YAML # functions_yaml CUSTOM_OPS_YAML custom_ops_yaml ) function(generate_bindings_for_kernels) + set(options ADD_EXCEPTION_BOUNDARY) set(arg_names LIB_NAME FUNCTIONS_YAML CUSTOM_OPS_YAML) - cmake_parse_arguments(GEN "" "${arg_names}" "" ${ARGN}) + cmake_parse_arguments(GEN "${options}" "${arg_names}" "" ${ARGN}) message(STATUS "Generating kernel bindings:") message(STATUS " LIB_NAME: ${GEN_LIB_NAME}") message(STATUS " FUNCTIONS_YAML: ${GEN_FUNCTIONS_YAML}") message(STATUS " CUSTOM_OPS_YAML: ${GEN_CUSTOM_OPS_YAML}") + message(STATUS " ADD_EXCEPTION_BOUNDARY: ${GEN_ADD_EXCEPTION_BOUNDARY}") # Command to generate selected_operators.yaml from custom_ops.yaml. file(GLOB_RECURSE _codegen_templates "${EXECUTORCH_ROOT}/codegen/templates/*") @@ -93,7 +96,10 @@ function(generate_bindings_for_kernels) --tags-path=${site-packages-out}/torchgen/packaged/ATen/native/tags.yaml --aten-yaml-path=${site-packages-out}/torchgen/packaged/ATen/native/native_functions.yaml --op-selection-yaml-path=${_oplist_yaml} - ) + ) + if(GEN_ADD_EXCEPTION_BOUNDARY) + set(_gen_command "${_gen_command} --add-exception-boundary") + endif() set(_gen_command_sources ${_out_dir}/RegisterCodegenUnboxedKernelsEverything.cpp diff --git a/configurations/CMakeLists.txt b/configurations/CMakeLists.txt index 9c61800196..9701a65d97 100644 --- a/configurations/CMakeLists.txt +++ b/configurations/CMakeLists.txt @@ -42,7 +42,7 @@ if(EXECUTORCH_BUILD_KERNELS_OPTIMIZED) generate_bindings_for_kernels( LIB_NAME "optimized_native_cpu_ops_lib" FUNCTIONS_YAML - ${CMAKE_CURRENT_BINARY_DIR}/merged.yaml + ${CMAKE_CURRENT_BINARY_DIR}/merged.yaml ADD_EXCEPTION_BOUNDARY ) message("Generated files ${gen_command_sources}") @@ -56,6 +56,7 @@ if(EXECUTORCH_BUILD_KERNELS_OPTIMIZED) DEPS executorch ) + target_compile_options(optimized_native_cpu_ops_lib PRIVATE "-fexceptions") install(TARGETS optimized_native_cpu_ops_lib DESTINATION lib) endif() diff --git a/kernels/optimized/CMakeLists.txt b/kernels/optimized/CMakeLists.txt index abdeeb7345..34a869e407 100644 --- a/kernels/optimized/CMakeLists.txt +++ b/kernels/optimized/CMakeLists.txt @@ -23,6 +23,8 @@ endif() set(_common_compile_options -Wno-deprecated-declarations) +add_compile_options("-fexceptions") + # Note for apple platform we can rely on Accelerate framework Will come back to # this include(${CMAKE_CURRENT_LIST_DIR}/External/EigenBLAS.cmake) @@ -55,6 +57,7 @@ gen_selected_ops(LIB_NAME "optimized_ops_lib" OPS_SCHEMA_YAML "${_yaml}") generate_bindings_for_kernels( LIB_NAME "optimized_ops_lib" FUNCTIONS_YAML ${CMAKE_CURRENT_SOURCE_DIR}/optimized-oss.yaml + ADD_EXCEPTION_BOUNDARY ) message("Generated files ${gen_command_sources}")