forked from pytorch/executorch
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_size_test.sh
More file actions
62 lines (51 loc) · 2.03 KB
/
build_size_test.sh
File metadata and controls
62 lines (51 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/bash
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
# Build size_test and show the size of it
set -ex
# shellcheck source=/dev/null
source "$(dirname "${BASH_SOURCE[0]}")/../.ci/scripts/utils.sh"
EXTRA_BUILD_ARGS="${@:-}"
# TODO(#8357): Remove -Wno-int-in-bool-context
# TODO: Replace -ET_HAVE_PREAD=0 with a CMake option.
# FileDataLoader used in the size_test breaks baremetal builds with pread when missing.
COMMON_CXXFLAGS="-fno-exceptions -fno-rtti -Wall -Werror -Wno-int-in-bool-context -DET_HAVE_PREAD=0"
cmake_install_executorch_lib() {
echo "Installing libexecutorch.a"
clean_executorch_install_folders
update_tokenizers_git_submodule
local EXTRA_BUILD_ARGS="${@}"
CXXFLAGS="$COMMON_CXXFLAGS" retry cmake \
-DCMAKE_CXX_STANDARD_REQUIRED=ON \
-DCMAKE_INSTALL_PREFIX=cmake-out \
-DCMAKE_BUILD_TYPE=Release \
-DEXECUTORCH_BUILD_EXECUTOR_RUNNER=OFF \
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
-DEXECUTORCH_OPTIMIZE_SIZE=ON \
-DPYTHON_EXECUTABLE="$PYTHON_EXECUTABLE" \
${EXTRA_BUILD_ARGS} \
-Bcmake-out .
cmake --build cmake-out -j9 --target install --config Release
}
test_cmake_size_test() {
CXXFLAGS="$COMMON_CXXFLAGS" retry cmake -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=cmake-out \
${EXTRA_BUILD_ARGS} \
-Bcmake-out/test test
echo "Build size test"
cmake --build cmake-out/test -j9 --config Release
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
PYTHON_EXECUTABLE=python3
fi
cmake_install_executorch_lib ${EXTRA_BUILD_ARGS}
test_cmake_size_test ${EXTRA_BUILD_ARGS}