From 2d008a476f5f09f63574990a93e8bf606ae5629e Mon Sep 17 00:00:00 2001 From: John Richardson Date: Thu, 22 Mar 2018 13:48:41 +0000 Subject: COMPMID-586: Port LaplacianPyramid to new validation Change-Id: Ic746d5f297eb354e63cefa8c682b03fc339be81d Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/128409 Reviewed-by: Pablo Tello Tested-by: Jenkins Reviewed-by: John Richardson Reviewed-by: Anthony Barbier --- tests/Utils.h | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'tests/Utils.h') diff --git a/tests/Utils.h b/tests/Utils.h index 7d960dd08f..d0eebb1204 100644 --- a/tests/Utils.h +++ b/tests/Utils.h @@ -306,6 +306,38 @@ inline ValidRegion shape_to_valid_region_gaussian_pyramid_half(const TensorShape return valid_region; } +/** Create a valid region for Laplacian Pyramid based on tensor shape and valid region at level "i - 1" and border mode + * + * @note The border size is 2 in case of Laplacian Pyramid + * + * @param[in] a_shape Shape used at level "i - 1" of Laplacian Pyramid + * @param[in] a_valid_region Valid region used at level "i - 1" of Laplacian Pyramid + * @param[in] border_undefined (Optional) Boolean indicating if the border mode is undefined. + * + * return The valid region for the level "i" of Laplacian Pyramid + */ +inline ValidRegion shape_to_valid_region_laplacian_pyramid(const TensorShape &a_shape, const ValidRegion &a_valid_region, bool border_undefined = false) +{ + ValidRegion valid_region = shape_to_valid_region_gaussian_pyramid_half(a_shape, a_valid_region, border_undefined); + + if(border_undefined) + { + const BorderSize gaussian5x5_border(2); + + auto border_left = static_cast(gaussian5x5_border.left); + auto border_right = static_cast(gaussian5x5_border.right); + auto border_top = static_cast(gaussian5x5_border.top); + auto border_bottom = static_cast(gaussian5x5_border.bottom); + + valid_region.anchor.set(0, valid_region.anchor[0] + border_left); + valid_region.anchor.set(1, valid_region.anchor[1] + border_top); + valid_region.shape.set(0, std::max(0, static_cast(valid_region.shape[0]) - border_right - border_left)); + valid_region.shape.set(1, std::max(0, static_cast(valid_region.shape[1]) - border_top - border_bottom)); + } + + return valid_region; +} + /** Write the value after casting the pointer according to @p data_type. * * @warning The type of the value must match the specified data type. -- cgit v1.2.1