Skip to content
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
20 changes: 17 additions & 3 deletions kernels/portable/cpu/util/activation_ops_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <cstring>

#include <executorch/kernels/portable/cpu/util/activation_ops_util.h>
#include <executorch/runtime/core/exec_aten/util/tensor_shape_to_c_string.h>

namespace torch {
namespace executor {
Expand Down Expand Up @@ -45,9 +46,22 @@ bool check_glu_args(const Tensor& in, int64_t dim, Tensor& out) {

for (size_t i = 0; i < in.dim(); ++i) {
if (i != non_negative_dim) {
ET_LOG_MSG_AND_RETURN_IF_FALSE(
out.size(i) == in.size(i),
"output tensor must have the same size as the input tensor in all dimensions except for the specified dimension.");
if (out.size(i) != in.size(i)) {
#if ET_LOG_ENABLED
auto out_shape_str = executorch::runtime::tensor_shape_to_c_string(
executorch::runtime::Span<const Tensor::SizesType>(
out.sizes().data(), out.sizes().size()));
auto in_shape_str = executorch::runtime::tensor_shape_to_c_string(
executorch::runtime::Span<const Tensor::SizesType>(
in.sizes().data(), in.sizes().size()));
ET_LOG(
Error,
"output tensor must have the same size as the input tensor in all dimensions except for the specified dimension. (output shape: %s input shape: %s)",
out_shape_str.data(),
in_shape_str.data());
#endif // ET_LOG_ENABLED
return false;
}
}
}

Expand Down
1 change: 1 addition & 0 deletions kernels/portable/cpu/util/targets.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def define_common_targets():
],
compiler_flags = ["-Wno-missing-prototypes"],
deps = [
"//executorch/runtime/core/exec_aten/util:tensor_shape_to_c_string",
"//executorch/runtime/kernel:kernel_includes",
],
visibility = ["//executorch/kernels/portable/cpu/...", "//executorch/kernels/optimized/cpu/..."],
Expand Down
Loading