aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorViet-Hoa Do <viet-hoa.do@arm.com>2023-08-02 11:59:07 +0100
committerViet-Hoa Do <viet-hoa.do@arm.com>2023-08-03 13:45:13 +0000
commit4f76a00a40947b9e3549c18d319cf057c6f0271e (patch)
treef742120efd6bf7be3b329d7ab3bdb46adcd73af0
parent0c19f59279a88384074635bf273a99001602ed21 (diff)
downloadComputeLibrary-4f76a00a40947b9e3549c18d319cf057c6f0271e.tar.gz
Fix ReduceMean validate issue
Resolves: COMPMID-6406 Signed-off-by: Viet-Hoa Do <viet-hoa.do@arm.com> Change-Id: Ic638616f4cb228673928815b759caee3d094780d Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/10043 Reviewed-by: Gunes Bayir <gunes.bayir@arm.com> Comments-Addressed: Arm Jenkins <bsgcomp@arm.com> Tested-by: Arm Jenkins <bsgcomp@arm.com> Benchmark: Arm Jenkins <bsgcomp@arm.com>
-rw-r--r--arm_compute/core/TensorShape.h12
-rw-r--r--src/runtime/CL/functions/CLReduceMean.cpp6
-rw-r--r--src/runtime/NEON/functions/NEReduceMean.cpp6
3 files changed, 14 insertions, 10 deletions
diff --git a/arm_compute/core/TensorShape.h b/arm_compute/core/TensorShape.h
index b6ab9dc75a..4c9186ac64 100644
--- a/arm_compute/core/TensorShape.h
+++ b/arm_compute/core/TensorShape.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016-2021 Arm Limited.
+ * Copyright (c) 2016-2021, 2023 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -106,9 +106,10 @@ public:
*
* @note The upper dimensions of the tensor shape will be shifted down by 1
*
- * @param[in] n Dimension to remove
+ * @param[in] n Dimension to remove
+ * @param[in] apply_dim_correction (Optional) Flag to state whether apply dimension correction (removing trailing dimensions with size of 1) after removing a dimension.
*/
- void remove_dimension(size_t n)
+ void remove_dimension(size_t n, bool apply_dim_correction = true)
{
ARM_COMPUTE_ERROR_ON(_num_dimensions < 1);
ARM_COMPUTE_ERROR_ON(n >= _num_dimensions);
@@ -122,7 +123,10 @@ public:
std::fill(_id.begin() + _num_dimensions, _id.end(), 1);
// Correct number dimensions to ignore trailing dimensions of size 1
- apply_dimension_correction();
+ if(apply_dim_correction)
+ {
+ apply_dimension_correction();
+ }
}
/** Collapse the first n dimensions.
diff --git a/src/runtime/CL/functions/CLReduceMean.cpp b/src/runtime/CL/functions/CLReduceMean.cpp
index 6a2fcc600a..cddbf77d7c 100644
--- a/src/runtime/CL/functions/CLReduceMean.cpp
+++ b/src/runtime/CL/functions/CLReduceMean.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2021 Arm Limited.
+ * Copyright (c) 2018-2021, 2023 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -82,7 +82,7 @@ Status validate_config(const ITensorInfo *input, const Coordinates &reduction_ax
ARM_COMPUTE_RETURN_ERROR_ON(i > static_cast<unsigned int>(axis_local[i]));
const unsigned int remove_index = axis_local[i] - i;
ARM_COMPUTE_RETURN_ERROR_ON(remove_index >= out_shape.num_dimensions());
- out_shape.remove_dimension(remove_index);
+ out_shape.remove_dimension(remove_index, false);
}
}
const TensorInfo out_info = input->clone()->set_tensor_shape(out_shape);
@@ -182,7 +182,7 @@ void CLReduceMean::configure(const CLCompileContext &compile_context, ICLTensor
std::sort(axis_local.begin(), axis_local.begin() + _reduction_ops);
for(int i = 0; i < _reduction_ops; ++i)
{
- out_shape.remove_dimension(axis_local[i] - i);
+ out_shape.remove_dimension(axis_local[i] - i, false);
}
auto_init_if_empty(*tmp_output->info(), tmp_input->info()->clone()->set_tensor_shape(out_shape));
_reshape.configure(compile_context, &_reduced_outs[_reduction_ops - 1], tmp_output);
diff --git a/src/runtime/NEON/functions/NEReduceMean.cpp b/src/runtime/NEON/functions/NEReduceMean.cpp
index 9c9b79a1e5..9f96479295 100644
--- a/src/runtime/NEON/functions/NEReduceMean.cpp
+++ b/src/runtime/NEON/functions/NEReduceMean.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2022 Arm Limited.
+ * Copyright (c) 2018-2023 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -78,7 +78,7 @@ Status validate_config(const ITensorInfo *input, const Coordinates &reduction_ax
ARM_COMPUTE_RETURN_ERROR_ON(i > static_cast<unsigned int>(axis_local[i]));
const unsigned int remove_index = axis_local[i] - i;
ARM_COMPUTE_RETURN_ERROR_ON(remove_index >= out_shape.num_dimensions());
- out_shape.remove_dimension(remove_index);
+ out_shape.remove_dimension(remove_index, false);
}
}
const TensorInfo out_info = input->clone()->set_tensor_shape(out_shape);
@@ -156,7 +156,7 @@ void NEReduceMean::configure(ITensor *input, const Coordinates &reduction_axis,
std::sort(axis_local.begin(), axis_local.begin() + _reduction_ops);
for(int i = 0; i < _reduction_ops; ++i)
{
- out_shape.remove_dimension(axis_local[i] - i);
+ out_shape.remove_dimension(axis_local[i] - i, false);
}
auto_init_if_empty(*tmp_output->info(), tmp_input->info()->clone()->set_tensor_shape(out_shape));
_reshape.configure(&_reduced_outs[_reduction_ops - 1], tmp_output);