aboutsummaryrefslogtreecommitdiff
path: root/tests/Utils.h
diff options
context:
space:
mode:
authorMoritz Pflanzer <moritz.pflanzer@arm.com>2017-09-23 19:22:51 +0100
committerAnthony Barbier <anthony.barbier@arm.com>2018-11-02 16:35:24 +0000
commit219c69108f72a0c01f0f14dda579fc0bce808d07 (patch)
treebc455e5e8b39606b52ae102addd45997e7b8dc1f /tests/Utils.h
parent2fd5d95446b3f89001313335cf129c30cf7951e7 (diff)
downloadComputeLibrary-219c69108f72a0c01f0f14dda579fc0bce808d07.tar.gz
COMPMID-417: Fix is_in_valid_region
A coordinate is always a point no matter of the dimensionality. Thus it always fits into any shape as the latter doesn't have to start at the origin. Change-Id: Id4fe82d9e1461c3248ef454d5c4ddfda1d2cbcc0 Reviewed-on: http://mpd-gerrit.cambridge.arm.com/88882 Reviewed-by: Pablo Tello <pablo.tello@arm.com> Tested-by: Kaizen <jeremy.johnson+kaizengerrit@arm.com>
Diffstat (limited to 'tests/Utils.h')
-rw-r--r--tests/Utils.h42
1 files changed, 1 insertions, 41 deletions
diff --git a/tests/Utils.h b/tests/Utils.h
index 3861577d31..4745b8bbd7 100644
--- a/tests/Utils.h
+++ b/tests/Utils.h
@@ -351,50 +351,10 @@ inline int coord2index(const TensorShape &shape, const Coordinates &coord)
return index;
}
-/** Check if Coordinates dimensionality can match the respective shape one.
- *
- * @param coords Coordinates
- * @param shape Shape to match dimensionality
- *
- * @return True if Coordinates can match the dimensionality of the shape else false.
- */
-inline bool match_shape(Coordinates &coords, const TensorShape &shape)
-{
- auto check_nz = [](int i)
- {
- return i != 0;
- };
-
- const int coords_dims = coords.num_dimensions();
- const int shape_dims = shape.num_dimensions();
-
- // Increase coordinates scenario
- if(coords_dims < shape_dims)
- {
- coords.set_num_dimensions(shape_dims);
- return true;
- }
- // Decrease coordinates scenario
- if(coords_dims > shape_dims && !std::any_of(coords.begin() + shape_dims, coords.end(), check_nz))
- {
- coords.set_num_dimensions(shape_dims);
- return true;
- }
-
- return (coords_dims == shape_dims);
-}
-
/** Check if a coordinate is within a valid region */
inline bool is_in_valid_region(const ValidRegion &valid_region, Coordinates coord)
{
- const bool match = match_shape(coord, valid_region.shape);
-
- if(!match)
- {
- return false;
- }
-
- for(int d = 0; static_cast<size_t>(d) < coord.num_dimensions(); ++d)
+ for(size_t d = 0; d < Coordinates::num_max_dimensions; ++d)
{
if(coord[d] < valid_region.start(d) || coord[d] >= valid_region.end(d))
{