From 37908d9e675a240f65e038796f44691c4c530229 Mon Sep 17 00:00:00 2001 From: Gian Marco Date: Tue, 7 Nov 2017 14:38:22 +0000 Subject: COMPMID-560 - Validation mismatches Gaussian Pyramid Half Scale Change-Id: If09afa444c6b3e91117d1b1a529faa0778457cd3 Reviewed-on: http://mpd-gerrit.cambridge.arm.com/96099 Tested-by: Kaizen Reviewed-by: Anthony Barbier --- tests/validation/CPP/GaussianPyramidHalf.cpp | 66 ++++++++++++++++++++++++++++ tests/validation/CPP/GaussianPyramidHalf.h | 43 ++++++++++++++++++ tests/validation/CPP/Scale.cpp | 21 +++++---- tests/validation/CPP/Scale.h | 2 +- 4 files changed, 123 insertions(+), 9 deletions(-) create mode 100644 tests/validation/CPP/GaussianPyramidHalf.cpp create mode 100644 tests/validation/CPP/GaussianPyramidHalf.h (limited to 'tests/validation/CPP') diff --git a/tests/validation/CPP/GaussianPyramidHalf.cpp b/tests/validation/CPP/GaussianPyramidHalf.cpp new file mode 100644 index 0000000000..18d3daa288 --- /dev/null +++ b/tests/validation/CPP/GaussianPyramidHalf.cpp @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "GaussianPyramidHalf.h" + +#include "arm_compute/core/Helpers.h" + +#include "Gaussian5x5.h" +#include "Scale.h" +#include "Utils.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace reference +{ +template +std::vector> gaussian_pyramid_half(const SimpleTensor &src, BorderMode border_mode, uint8_t constant_border_value, size_t num_levels) +{ + std::vector> dst; + + // Level0 is equal to src + dst.push_back(src); + + for(size_t i = 1; i < num_levels; ++i) + { + // Gaussian Filter + const SimpleTensor out_gaus5x5 = reference::gaussian5x5(dst[i - 1], border_mode, constant_border_value); + + // Scale down by 2 with nearest interpolation + const SimpleTensor out = reference::scale(out_gaus5x5, SCALE_PYRAMID_HALF, SCALE_PYRAMID_HALF, InterpolationPolicy::NEAREST_NEIGHBOR, border_mode, constant_border_value, true); + + dst.push_back(out); + } + + return dst; +} + +template std::vector> gaussian_pyramid_half(const SimpleTensor &src, BorderMode border_mode, uint8_t constant_border_value, size_t num_levels); +} // namespace reference +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/CPP/GaussianPyramidHalf.h b/tests/validation/CPP/GaussianPyramidHalf.h new file mode 100644 index 0000000000..abd29e1700 --- /dev/null +++ b/tests/validation/CPP/GaussianPyramidHalf.h @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_GAUSSIAN_PYRAMID_HALF_H__ +#define __ARM_COMPUTE_TEST_GAUSSIAN_PYRAMID_HALF_H__ + +#include "tests/SimpleTensor.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace reference +{ +template +std::vector> gaussian_pyramid_half(const SimpleTensor &src, BorderMode border_mode, uint8_t constant_border_value, size_t num_levels); +} // namespace reference +} // namespace validation +} // namespace test +} // namespace arm_compute +#endif /* __ARM_COMPUTE_TEST_GAUSSIAN_PYRAMID_HALF_H__ */ \ No newline at end of file diff --git a/tests/validation/CPP/Scale.cpp b/tests/validation/CPP/Scale.cpp index 0da7497277..c368fa277a 100644 --- a/tests/validation/CPP/Scale.cpp +++ b/tests/validation/CPP/Scale.cpp @@ -36,11 +36,13 @@ namespace validation namespace reference { template -SimpleTensor scale(const SimpleTensor &in, float scale_x, float scale_y, InterpolationPolicy policy, BorderMode border_mode, T constant_border_value) +SimpleTensor scale(const SimpleTensor &in, float scale_x, float scale_y, InterpolationPolicy policy, BorderMode border_mode, T constant_border_value, bool ceil_policy_scale) { - TensorShape shape_scaled(in.shape()); - shape_scaled.set(0, in.shape()[0] * scale_x); - shape_scaled.set(1, in.shape()[1] * scale_y); + // Add 1 if ceil_policy_scale is true + const size_t round_value = ceil_policy_scale ? 1U : 0U; + TensorShape shape_scaled(in.shape()); + shape_scaled.set(0, (in.shape()[0] + round_value) * scale_x); + shape_scaled.set(1, (in.shape()[1] + round_value) * scale_y); SimpleTensor out(shape_scaled, in.data_type()); // Compute the ratio between source width/height and destination width/height @@ -149,10 +151,13 @@ SimpleTensor scale(const SimpleTensor &in, float scale_x, float scale_y, I return out; } -template SimpleTensor scale(const SimpleTensor &src, float scale_x, float scale_y, InterpolationPolicy policy, BorderMode border_mode, uint8_t constant_border_value); -template SimpleTensor scale(const SimpleTensor &src, float scale_x, float scale_y, InterpolationPolicy policy, BorderMode border_mode, int16_t constant_border_value); -template SimpleTensor scale(const SimpleTensor &src, float scale_x, float scale_y, InterpolationPolicy policy, BorderMode border_mode, half constant_border_value); -template SimpleTensor scale(const SimpleTensor &src, float scale_x, float scale_y, InterpolationPolicy policy, BorderMode border_mode, float constant_border_value); +template SimpleTensor scale(const SimpleTensor &src, float scale_x, float scale_y, InterpolationPolicy policy, BorderMode border_mode, uint8_t constant_border_value, + bool ceil_policy_scale); +template SimpleTensor scale(const SimpleTensor &src, float scale_x, float scale_y, InterpolationPolicy policy, BorderMode border_mode, int16_t constant_border_value, + bool ceil_policy_scale); +template SimpleTensor scale(const SimpleTensor &src, float scale_x, float scale_y, InterpolationPolicy policy, BorderMode border_mode, half constant_border_value, bool ceil_policy_scale); +template SimpleTensor scale(const SimpleTensor &src, float scale_x, float scale_y, InterpolationPolicy policy, BorderMode border_mode, float constant_border_value, + bool ceil_policy_scale); } // namespace reference } // namespace validation } // namespace test diff --git a/tests/validation/CPP/Scale.h b/tests/validation/CPP/Scale.h index 53183ae742..87af2fd204 100644 --- a/tests/validation/CPP/Scale.h +++ b/tests/validation/CPP/Scale.h @@ -35,7 +35,7 @@ namespace validation namespace reference { template -SimpleTensor scale(const SimpleTensor &in, float scale_x, float scale_y, InterpolationPolicy policy, BorderMode border_mode, T constant_border_value = 0); +SimpleTensor scale(const SimpleTensor &in, float scale_x, float scale_y, InterpolationPolicy policy, BorderMode border_mode, T constant_border_value = 0, bool ceil_policy_scale = false); } // namespace reference } // namespace validation } // namespace test -- cgit v1.2.1