Skip to content

Commit 96d258e

Browse files
committed
Update
[ghstack-poisoned]
1 parent 9e42e93 commit 96d258e

File tree

2 files changed

+70
-0
lines changed

2 files changed

+70
-0
lines changed

test/CMakeLists.txt

+13
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,18 @@ if(CMAKE_BUILD_TYPE EQUAL "Release")
6868
target_link_options(size_test_all_ops PRIVATE "LINKER:--gc-sections")
6969
endif()
7070

71+
#
72+
# size_test_all_optimized_ops: binary with optimized ops and no delegate backend
73+
#
74+
if(EXECUTORCH_BUILD_KERNELS_OPTIMIZED)
75+
add_executable(size_test_all_optimized_ops ${_size_test__srcs})
76+
target_link_options_shared_lib(optimized_native_cpu_ops_lib)
77+
target_link_libraries(
78+
size_test_all_optimized_ops executorch optimized_native_cpu_ops_lib)
79+
if(CMAKE_BUILD_TYPE EQUAL "Release")
80+
target_link_options(size_test_all_optimized_ops PRIVATE "LINKER:--gc-sections")
81+
endif()
82+
endif()
83+
7184
# Print all summary
7285
executorch_print_configuration_summary()

test/build_optimized_size_test.sh

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/bin/bash
2+
# Copyright (c) Meta Platforms, Inc. and affiliates.
3+
# All rights reserved.
4+
#
5+
# This source code is licensed under the BSD-style license found in the
6+
# LICENSE file in the root directory of this source tree.
7+
8+
# Unlike build_size_test.sh, this script:
9+
# - does not attempt to disable exceptions and RTTI
10+
# - as a consequence, is able to build optimized kernels
11+
# - uses MinSizeRel builds
12+
# - is not currently intended to run in CI
13+
# - sets -g to make it easier to use tools like bloaty to investigate size
14+
15+
set -e
16+
17+
# shellcheck source=/dev/null
18+
source "$(dirname "${BASH_SOURCE[0]}")/../.ci/scripts/utils.sh"
19+
20+
cmake_install_executorch_lib() {
21+
echo "Installing libexecutorch.a"
22+
clean_executorch_install_folders
23+
update_tokenizers_git_submodule
24+
CXXFLAGS="-g" retry cmake -DBUCK2="$BUCK2" \
25+
-DCMAKE_CXX_STANDARD_REQUIRED=ON \
26+
-DCMAKE_INSTALL_PREFIX=cmake-out \
27+
-DCMAKE_BUILD_TYPE=MinSizeRel \
28+
-DEXECUTORCH_BUILD_EXECUTOR_RUNNER=OFF \
29+
-DEXECUTORCH_BUILD_KERNELS_OPTIMIZED=ON \
30+
-DOPTIMIZE_SIZE=ON \
31+
-DPYTHON_EXECUTABLE="$PYTHON_EXECUTABLE" \
32+
-Bcmake-out .
33+
cmake --build cmake-out -j9 --target install --config MinSizeRel
34+
}
35+
36+
test_cmake_size_test() {
37+
CXXFLAGS="-g" retry cmake -DCMAKE_BUILD_TYPE=MinSizeRel -DEXECUTORCH_BUILD_KERNELS_OPTIMIZED=ON -DCMAKE_INSTALL_PREFIX=cmake-out -Bcmake-out/test test
38+
39+
echo "Build size test"
40+
cmake --build cmake-out/test -j9 --config MinSizeRel
41+
42+
echo 'ExecuTorch with no ops binary size, unstripped:'
43+
ls -al cmake-out/test/size_test
44+
45+
echo 'ExecuTorch with portable ops binary size, unstripped:'
46+
ls -al cmake-out/test/size_test_all_ops
47+
48+
echo 'ExecuTorch with optimized ops binary size, unstripped:'
49+
ls -al cmake-out/test/size_test_all_optimized_ops
50+
}
51+
52+
if [[ -z $PYTHON_EXECUTABLE ]]; then
53+
PYTHON_EXECUTABLE=python3
54+
fi
55+
56+
cmake_install_executorch_lib
57+
test_cmake_size_test

0 commit comments

Comments
 (0)