Skip to content

Show output of the size command in size test scripts #12018

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 28, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
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
2 changes: 2 additions & 0 deletions test/build_size_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading