Skip to content
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/pull.yml
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ jobs:
# build module for executorch.extension.pybindings.portable_lib
bash test/build_size_test.sh
strip cmake-out/test/size_test
strip --strip-debug cmake-out/test/size_test
output=$(ls -la cmake-out/test/size_test)
arr=($output)
size=${arr[4]}
Expand Down Expand Up @@ -403,6 +404,7 @@ jobs:
# build module for executorch.extension.pybindings.portable_lib
bash test/build_size_test.sh
strip cmake-out/test/size_test
strip --strip-debug cmake-out/test/size_test
output=$(ls -la cmake-out/test/size_test)
arr=($output)
size=${arr[4]}
Expand Down
12 changes: 9 additions & 3 deletions kernels/portable/cpu/util/normalization_ops_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

#include <c10/util/irange.h>
#include <array>
#include <cstring>

#include <executorch/kernels/portable/cpu/util/normalization_ops_util.h>
Expand Down Expand Up @@ -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(
Expand All @@ -103,20 +109,20 @@ bool check_layer_norm_args(
d,
normalized_shape[d]);
}
executorch::aten::SizesType shape[ndim];
std::array<executorch::aten::SizesType, kTensorDimensionLimit> shape;
for (const auto i : c10::irange(ndim)) {
shape[i] = static_cast<executorch::aten::SizesType>(normalized_shape[i]);
}

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));
Expand Down
3 changes: 3 additions & 0 deletions test/build_optimized_size_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 6 additions & 4 deletions test/build_size_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,29 +26,31 @@ cmake_install_executorch_lib() {
CXXFLAGS="$COMMON_CXXFLAGS" retry cmake -DBUCK2="$BUCK2" \
-DCMAKE_CXX_STANDARD_REQUIRED=ON \
-DCMAKE_INSTALL_PREFIX=cmake-out \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DEXECUTORCH_BUILD_EXECUTOR_RUNNER=OFF \
-DEXECUTORCH_OPTIMIZE_SIZE=ON \
-DPYTHON_EXECUTABLE="$PYTHON_EXECUTABLE" \
${EXTRA_BUILD_ARGS} \
-Bcmake-out .
cmake --build cmake-out -j9 --target install --config Release
cmake --build cmake-out -j9 --target install --config RelWithDebInfo
}

test_cmake_size_test() {
CXXFLAGS="$COMMON_CXXFLAGS" retry cmake -DCMAKE_BUILD_TYPE=Release \
CXXFLAGS="$COMMON_CXXFLAGS" retry cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_INSTALL_PREFIX=cmake-out \
${EXTRA_BUILD_ARGS} \
-Bcmake-out/test test

echo "Build size test"
cmake --build cmake-out/test -j9 --config Release
cmake --build cmake-out/test -j9 --config RelWithDebInfo

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
Expand Down
Loading