diff --git a/CMakeLists.txt b/CMakeLists.txt index 3a3b1f7bfe0..5128a013076 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -694,7 +694,7 @@ if(EXECUTORCH_BUILD_EXECUTOR_RUNNER) endif() add_executable(executor_runner ${_executor_runner__srcs}) - if(CMAKE_BUILD_TYPE STREQUAL "Release") + if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug") if(APPLE) target_link_options(executor_runner PRIVATE "LINKER:-dead_strip") else() diff --git a/backends/qualcomm/CMakeLists.txt b/backends/qualcomm/CMakeLists.txt index 203cdf2c314..9f1be61de2b 100644 --- a/backends/qualcomm/CMakeLists.txt +++ b/backends/qualcomm/CMakeLists.txt @@ -60,7 +60,7 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") add_link_options("-flto=auto") endif() -if(CMAKE_BUILD_TYPE STREQUAL "Release") +if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug") # strip symbols add_link_options("-s") @@ -259,7 +259,7 @@ if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64") pybind11_strip(PyQnnWrapperAdaptor) endif() - if(CMAKE_BUILD_TYPE STREQUAL "Release") + if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug") # need to allow exceptions in pybind set(_pybind_compile_options -Wno-deprecated-declarations -fPIC -frtti -fexceptions diff --git a/examples/models/llama/CMakeLists.txt b/examples/models/llama/CMakeLists.txt index 8c27de20845..3216469c13a 100644 --- a/examples/models/llama/CMakeLists.txt +++ b/examples/models/llama/CMakeLists.txt @@ -209,7 +209,7 @@ if(ANDROID) endif() add_executable(llama_main ${_srcs}) -if(CMAKE_BUILD_TYPE STREQUAL "Release") +if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug") if(APPLE) target_link_options(llama_main PRIVATE "LINKER:-dead_strip") else() diff --git a/examples/models/llava/CMakeLists.txt b/examples/models/llava/CMakeLists.txt index 64be6111674..41270d0133f 100644 --- a/examples/models/llava/CMakeLists.txt +++ b/examples/models/llava/CMakeLists.txt @@ -197,7 +197,7 @@ list(APPEND _common_include_directories ${stb_SOURCE_DIR} ) add_executable(llava_main ${_srcs}) -if(CMAKE_BUILD_TYPE STREQUAL "Release") +if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug") if(APPLE) target_link_options(llava_main PRIVATE "LINKER:-dead_strip,-s") else() diff --git a/examples/selective_build/CMakeLists.txt b/examples/selective_build/CMakeLists.txt index 39b212b16fb..24fd102fee9 100644 --- a/examples/selective_build/CMakeLists.txt +++ b/examples/selective_build/CMakeLists.txt @@ -151,7 +151,7 @@ list(TRANSFORM _executor_runner__srcs PREPEND "${EXECUTORCH_ROOT}/") # link to # add_executable(selective_build_test ${_executor_runner__srcs}) -if(CMAKE_BUILD_TYPE EQUAL "Release") +if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug") target_link_options(selective_build_test PRIVATE "LINKER:--gc-sections") endif() target_link_libraries( diff --git a/kernels/portable/cpu/util/normalization_ops_util.cpp b/kernels/portable/cpu/util/normalization_ops_util.cpp index 4adcf02b303..dedab427ae7 100644 --- a/kernels/portable/cpu/util/normalization_ops_util.cpp +++ b/kernels/portable/cpu/util/normalization_ops_util.cpp @@ -7,6 +7,7 @@ */ #include +#include #include #include @@ -92,6 +93,11 @@ bool check_layer_norm_args( ", ndim = %zu", in.dim(), ndim); + ET_CHECK_OR_RETURN_FALSE( + ndim <= kTensorDimensionLimit, + "Expected normalized shape to have at most %zu dimensions but it had %zu", + kTensorDimensionLimit, + ndim); size_t shift = in.dim() - ndim; for (const auto d : c10::irange(ndim)) { ET_CHECK_OR_RETURN_FALSE( @@ -103,7 +109,7 @@ bool check_layer_norm_args( d, normalized_shape[d]); } - executorch::aten::SizesType shape[ndim]; + std::array shape; for (const auto i : c10::irange(ndim)) { shape[i] = static_cast(normalized_shape[i]); } @@ -111,12 +117,12 @@ bool check_layer_norm_args( if (weight.has_value()) { ET_LOG_AND_RETURN_IF_FALSE(tensors_have_same_dtype(in, weight.value())); ET_LOG_AND_RETURN_IF_FALSE( - tensor_has_expected_size(weight.value(), {shape, ndim})); + tensor_has_expected_size(weight.value(), {shape.data(), ndim})); } if (bias.has_value()) { ET_LOG_AND_RETURN_IF_FALSE(tensors_have_same_dtype(in, bias.value())); ET_LOG_AND_RETURN_IF_FALSE( - tensor_has_expected_size(bias.value(), {shape, ndim})); + tensor_has_expected_size(bias.value(), {shape.data(), ndim})); } ET_LOG_AND_RETURN_IF_FALSE(tensors_have_same_dtype(in, out)); ET_LOG_AND_RETURN_IF_FALSE(tensors_have_same_dtype(in, mean_out)); diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 0e3a6703c54..967610f48f8 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -52,7 +52,7 @@ list(TRANSFORM _size_test__srcs PREPEND "${EXECUTORCH_ROOT}/") # when we cross compile to ios add_executable(size_test ${_size_test__srcs}) target_link_libraries(size_test executorch) -if(CMAKE_BUILD_TYPE EQUAL "Release") +if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug") target_link_options(size_test PRIVATE "LINKER:--gc-sections") endif() @@ -64,7 +64,7 @@ target_link_options_shared_lib(portable_ops_lib) target_link_libraries( size_test_all_ops executorch portable_ops_lib portable_kernels ) -if(CMAKE_BUILD_TYPE EQUAL "Release") +if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug") target_link_options(size_test_all_ops PRIVATE "LINKER:--gc-sections") endif() @@ -76,7 +76,7 @@ add_executable(size_test_all_optimized_ops ${_size_test__srcs}) target_link_options_shared_lib(optimized_native_cpu_ops_lib) target_link_libraries( size_test_all_optimized_ops executorch optimized_native_cpu_ops_lib) -if(CMAKE_BUILD_TYPE EQUAL "Release") +if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug") target_link_options(size_test_all_optimized_ops PRIVATE "LINKER:--gc-sections") endif() endif() diff --git a/test/build_optimized_size_test.sh b/test/build_optimized_size_test.sh index d7b055559f0..3141a29e9f1 100644 --- a/test/build_optimized_size_test.sh +++ b/test/build_optimized_size_test.sh @@ -41,12 +41,15 @@ test_cmake_size_test() { echo 'ExecuTorch with no ops binary size, unstripped:' ls -al cmake-out/test/size_test + size cmake-out/test/size_test echo 'ExecuTorch with portable ops binary size, unstripped:' ls -al cmake-out/test/size_test_all_ops + size cmake-out/test/size_test_all_ops echo 'ExecuTorch with optimized ops binary size, unstripped:' ls -al cmake-out/test/size_test_all_optimized_ops + size cmake-out/test/size_test_all_optimized_ops } if [[ -z $PYTHON_EXECUTABLE ]]; then diff --git a/test/build_size_test.sh b/test/build_size_test.sh index d020ab58c95..baeef5a849e 100644 --- a/test/build_size_test.sh +++ b/test/build_size_test.sh @@ -46,9 +46,11 @@ test_cmake_size_test() { echo 'ExecuTorch with no ops binary size, unstripped:' ls -al cmake-out/test/size_test + size cmake-out/test/size_test echo 'ExecuTorch with portable ops binary size, unstripped:' ls -al cmake-out/test/size_test_all_ops + size cmake-out/test/size_test_all_ops } if [[ -z $PYTHON_EXECUTABLE ]]; then diff --git a/tools/cmake/preset/default.cmake b/tools/cmake/preset/default.cmake index 21f3cf53ae8..f2733f591eb 100644 --- a/tools/cmake/preset/default.cmake +++ b/tools/cmake/preset/default.cmake @@ -4,7 +4,7 @@ # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. -if(CMAKE_BUILD_TYPE STREQUAL "Release") +if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug") set(_is_build_type_release ON) set(_is_build_type_debug OFF) else()