From d616cb906e6fb7eda3d1527c0ac3d630fc1c71c7 Mon Sep 17 00:00:00 2001 From: Pablo Tello Date: Wed, 27 Sep 2017 10:07:45 +0100 Subject: COMPMID-510: Cleaned up Warp tests. Change-Id: I8e3fece5b786b5529e8f1320fb5794e43756ec4a Reviewed-on: http://mpd-gerrit.cambridge.arm.com/89274 Tested-by: Kaizen Reviewed-by: Georgios Pinitas Reviewed-by: Anthony Barbier --- tests/validation/CL/WarpAffine.cpp | 2 +- tests/validation/CL/WarpPerspective.cpp | 2 +- tests/validation/CPP/Utils.h | 13 +++++-------- tests/validation/NEON/WarpAffine.cpp | 2 +- tests/validation/NEON/WarpPerspective.cpp | 2 +- tests/validation/fixtures/WarpAffineFixture.h | 4 ++-- tests/validation/fixtures/WarpPerspectiveFixture.h | 2 +- 7 files changed, 12 insertions(+), 15 deletions(-) diff --git a/tests/validation/CL/WarpAffine.cpp b/tests/validation/CL/WarpAffine.cpp index 9177fcb5a7..9db2ccaacc 100644 --- a/tests/validation/CL/WarpAffine.cpp +++ b/tests/validation/CL/WarpAffine.cpp @@ -66,7 +66,7 @@ DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(combi // Create the matrix std::array matrix{ {} }; - fill_warp_matrix<6>(matrix, 3, 2); + fill_warp_matrix<6>(matrix); // Create tensors CLTensor src = create_tensor(shape, data_type); diff --git a/tests/validation/CL/WarpPerspective.cpp b/tests/validation/CL/WarpPerspective.cpp index 011fe905da..2edf9119d6 100644 --- a/tests/validation/CL/WarpPerspective.cpp +++ b/tests/validation/CL/WarpPerspective.cpp @@ -67,7 +67,7 @@ DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(combi // Create the matrix std::array matrix = { { 0 } }; - fill_warp_matrix<9>(matrix, 3, 3); + fill_warp_matrix<9>(matrix); // Create tensors CLTensor src = create_tensor(shape, data_type); diff --git a/tests/validation/CPP/Utils.h b/tests/validation/CPP/Utils.h index 38fd924afc..0733411462 100644 --- a/tests/validation/CPP/Utils.h +++ b/tests/validation/CPP/Utils.h @@ -106,21 +106,18 @@ RawTensor transpose(const RawTensor &src, int chunk_width = 1); * @param[in,out] matrix Matrix */ template -inline void fill_warp_matrix(std::array &matrix, int cols, int rows) +inline void fill_warp_matrix(std::array &matrix) { std::mt19937 gen(library.get()->seed()); std::uniform_real_distribution dist(-1, 1); - - for(int v = 0, r = 0; r < rows; ++r) + for(auto &x : matrix) { - for(int c = 0; c < cols; ++c, ++v) - { - matrix[v] = dist(gen); - } + x = dist(gen); } if(SIZE == 9) { - matrix[(cols * rows) - 1] = 1; + // This is only used in Warp Perspective, we set M[3][3] = 1 so that Z0 is not 0 and we avoid division by 0. + matrix[8] = 1.f; } } diff --git a/tests/validation/NEON/WarpAffine.cpp b/tests/validation/NEON/WarpAffine.cpp index 1b52f9f07c..2460f1a510 100644 --- a/tests/validation/NEON/WarpAffine.cpp +++ b/tests/validation/NEON/WarpAffine.cpp @@ -65,7 +65,7 @@ DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(combi // Create the matrix std::array matrix{ {} }; - fill_warp_matrix<6>(matrix, 3, 2); + fill_warp_matrix<6>(matrix); // Create tensors Tensor src = create_tensor(shape, data_type); diff --git a/tests/validation/NEON/WarpPerspective.cpp b/tests/validation/NEON/WarpPerspective.cpp index 9c1358bb15..45d3a0b878 100644 --- a/tests/validation/NEON/WarpPerspective.cpp +++ b/tests/validation/NEON/WarpPerspective.cpp @@ -67,7 +67,7 @@ DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(combi // Create the matrix std::array matrix = { { 0 } }; - fill_warp_matrix<9>(matrix, 3, 3); + fill_warp_matrix<9>(matrix); // Create tensors Tensor src = create_tensor(shape, data_type); diff --git a/tests/validation/fixtures/WarpAffineFixture.h b/tests/validation/fixtures/WarpAffineFixture.h index 3b106e15d6..fef1f6b626 100644 --- a/tests/validation/fixtures/WarpAffineFixture.h +++ b/tests/validation/fixtures/WarpAffineFixture.h @@ -56,7 +56,7 @@ public: // Create the matrix std::array matrix{ {} }; - fill_warp_matrix<6>(matrix, 3, 2); + fill_warp_matrix<6>(matrix); _target = compute_target(shape, data_type, matrix.data(), policy, border_mode, constant_border_value); _reference = compute_reference(shape, data_type, matrix.data(), policy, border_mode, constant_border_value); @@ -118,4 +118,4 @@ protected: } // namespace validation } // namespace test } // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_WARP_AFFINE_FIXTURE */ \ No newline at end of file +#endif /* ARM_COMPUTE_TEST_WARP_AFFINE_FIXTURE */ diff --git a/tests/validation/fixtures/WarpPerspectiveFixture.h b/tests/validation/fixtures/WarpPerspectiveFixture.h index a99ee4e55b..c77efbdc0d 100644 --- a/tests/validation/fixtures/WarpPerspectiveFixture.h +++ b/tests/validation/fixtures/WarpPerspectiveFixture.h @@ -62,7 +62,7 @@ public: // Create the matrix std::array matrix = { { 0 } }; - fill_warp_matrix<9>(matrix, 3, 3); + fill_warp_matrix<9>(matrix); _target = compute_target(input_shape, vmask_shape, matrix.data(), policy, border_mode, constant_border_value, data_type); _reference = compute_reference(input_shape, vmask_shape, matrix.data(), policy, border_mode, constant_border_value, data_type); -- cgit v1.2.1