From 219c69108f72a0c01f0f14dda579fc0bce808d07 Mon Sep 17 00:00:00 2001 From: Moritz Pflanzer Date: Sat, 23 Sep 2017 19:22:51 +0100 Subject: 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 Tested-by: Kaizen --- tests/Utils.h | 42 +----------------------------------------- 1 file changed, 1 insertion(+), 41 deletions(-) (limited to 'tests/Utils.h') 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(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)) { -- cgit v1.2.1