diff options
author | Alex Gilday <alexander.gilday@arm.com> | 2018-01-09 11:40:19 +0000 |
---|---|---|
committer | Anthony Barbier <anthony.barbier@arm.com> | 2018-11-02 16:42:33 +0000 |
commit | 345ab188c66017bf80512024a42b8e85ee96c872 (patch) | |
tree | 995d7147444483e8d7c342a9c90e615ca9445bc7 /tests/validation | |
parent | 780db4eb6a9e3dee565d14f36d772038cd3253da (diff) | |
download | ComputeLibrary-345ab188c66017bf80512024a42b8e85ee96c872.tar.gz |
COMPMID-742: Add image input support for Harris Corners tests
Change-Id: I4833eec0734776d8683fe867bb4f4d827f1a2fb7
Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/115503
Tested-by: Jenkins <bsgcomp@arm.com>
Reviewed-by: Georgios Pinitas <georgios.pinitas@arm.com>
Diffstat (limited to 'tests/validation')
-rw-r--r-- | tests/validation/CL/HarrisCorners.cpp | 8 | ||||
-rw-r--r-- | tests/validation/NEON/HarrisCorners.cpp | 8 | ||||
-rw-r--r-- | tests/validation/fixtures/HarrisCornersFixture.h | 32 |
3 files changed, 28 insertions, 20 deletions
diff --git a/tests/validation/CL/HarrisCorners.cpp b/tests/validation/CL/HarrisCorners.cpp index 4188cb54f0..00b6910223 100644 --- a/tests/validation/CL/HarrisCorners.cpp +++ b/tests/validation/CL/HarrisCorners.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017, 2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -30,6 +30,7 @@ #include "tests/CL/CLArrayAccessor.h" #include "tests/PaddingCalculator.h" #include "tests/datasets/BorderModeDataset.h" +#include "tests/datasets/ImageFileDatasets.h" #include "tests/datasets/ShapeDatasets.h" #include "tests/framework/Asserts.h" #include "tests/framework/Macros.h" @@ -101,14 +102,15 @@ DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(conca template <typename T> using CLHarrisCornersFixture = HarrisCornersValidationFixture<CLTensor, CLAccessor, CLKeyPointArray, CLHarrisCorners, T>; -FIXTURE_DATA_TEST_CASE(RunSmall, CLHarrisCornersFixture<uint8_t>, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::Small2DShapes(), data), framework::dataset::make("Format", Format::U8))) +FIXTURE_DATA_TEST_CASE(RunSmall, CLHarrisCornersFixture<uint8_t>, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallImageFiles(), data), framework::dataset::make("Format", + Format::U8))) { // Validate output CLArrayAccessor<KeyPoint> array(_target); validate_keypoints(array.buffer(), array.buffer() + array.num_values(), _reference.begin(), _reference.end(), RelativeTolerance<float>(0.0001f)); } -FIXTURE_DATA_TEST_CASE(RunLarge, CLHarrisCornersFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(datasets::Large2DShapes(), data), framework::dataset::make("Format", Format::U8))) +FIXTURE_DATA_TEST_CASE(RunLarge, CLHarrisCornersFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeImageFiles(), data), framework::dataset::make("Format", Format::U8))) { // Validate output CLArrayAccessor<KeyPoint> array(_target); diff --git a/tests/validation/NEON/HarrisCorners.cpp b/tests/validation/NEON/HarrisCorners.cpp index fa8d3cbad6..b8d791774f 100644 --- a/tests/validation/NEON/HarrisCorners.cpp +++ b/tests/validation/NEON/HarrisCorners.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017, 2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -29,6 +29,7 @@ #include "tests/NEON/ArrayAccessor.h" #include "tests/PaddingCalculator.h" #include "tests/datasets/BorderModeDataset.h" +#include "tests/datasets/ImageFileDatasets.h" #include "tests/datasets/ShapeDatasets.h" #include "tests/framework/Asserts.h" #include "tests/framework/Macros.h" @@ -107,7 +108,8 @@ DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(conca template <typename T> using NEHarrisCornersFixture = HarrisCornersValidationFixture<Tensor, Accessor, KeyPointArray, NEHarrisCorners, T>; -FIXTURE_DATA_TEST_CASE(RunSmall, NEHarrisCornersFixture<uint8_t>, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::Small2DShapes(), data), framework::dataset::make("Format", Format::U8))) +FIXTURE_DATA_TEST_CASE(RunSmall, NEHarrisCornersFixture<uint8_t>, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallImageFiles(), data), framework::dataset::make("Format", + Format::U8))) { // Validate output ArrayAccessor<KeyPoint> array(_target); @@ -120,7 +122,7 @@ FIXTURE_DATA_TEST_CASE(RunSmall, NEHarrisCornersFixture<uint8_t>, framework::Dat allowed_mismatch_percentage); } -FIXTURE_DATA_TEST_CASE(RunLarge, NEHarrisCornersFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(datasets::Large2DShapes(), data), framework::dataset::make("Format", Format::U8))) +FIXTURE_DATA_TEST_CASE(RunLarge, NEHarrisCornersFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeImageFiles(), data), framework::dataset::make("Format", Format::U8))) { // Validate output ArrayAccessor<KeyPoint> array(_target); diff --git a/tests/validation/fixtures/HarrisCornersFixture.h b/tests/validation/fixtures/HarrisCornersFixture.h index 6395e3b6d8..1c30157344 100644 --- a/tests/validation/fixtures/HarrisCornersFixture.h +++ b/tests/validation/fixtures/HarrisCornersFixture.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017, 2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -47,20 +47,20 @@ class HarrisCornersValidationFixture : public framework::Fixture { public: template <typename...> - void setup(TensorShape shape, int gradient_size, int block_size, BorderMode border_mode, bool use_fp16, Format format) + void setup(std::string image, int gradient_size, int block_size, BorderMode border_mode, bool use_fp16, Format format) { HarrisCornersParameters params = harris_corners_parameters(); - _target = compute_target(shape, gradient_size, block_size, border_mode, use_fp16, format, params); + _target = compute_target(image, gradient_size, block_size, border_mode, use_fp16, format, params); //TODO(COMPMID-543): Add use_fp16 to reference - _reference = compute_reference(shape, gradient_size, block_size, border_mode, format, params); + _reference = compute_reference(image, gradient_size, block_size, border_mode, format, params); } protected: template <typename U> - void fill(U &&tensor) + void fill(U &&tensor, RawTensor raw) { - library->fill_tensor_uniform(tensor, 0); + library->fill(tensor, raw); } template <typename F, typename std::enable_if<std::is_same<F, NEHarrisCorners>::value, int>::type = 0> @@ -77,14 +77,16 @@ protected: func.configure(&src, params.threshold, params.min_dist, params.sensitivity, gradient_size, block_size, &corners, border_mode, params.constant_border_value); } - ArrayType compute_target(const TensorShape &shape, int gradient_size, int block_size, BorderMode border_mode, bool use_fp16, Format format, const HarrisCornersParameters ¶ms) + ArrayType compute_target(std::string image, int gradient_size, int block_size, BorderMode border_mode, bool use_fp16, Format format, const HarrisCornersParameters ¶ms) { + // Load the image (cached by the library if loaded before) + const RawTensor &raw = library->get(image, format); + // Create tensors - TensorType src = create_tensor<TensorType>(shape, data_type_from_format(format)); - src.info()->set_format(format); + TensorType src = create_tensor<TensorType>(raw.shape(), format); // Create array of keypoints - ArrayType corners(shape.total_size()); + ArrayType corners(raw.shape().total_size()); // Create harris corners configure function FunctionType harris_corners; @@ -98,7 +100,7 @@ protected: ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); // Fill tensors - fill(AccessorType(src)); + fill(AccessorType(src), raw); // Compute function harris_corners.run(); @@ -106,13 +108,15 @@ protected: return corners; } - std::vector<KeyPoint> compute_reference(const TensorShape &shape, int gradient_size, int block_size, BorderMode border_mode, Format format, const HarrisCornersParameters ¶ms) + std::vector<KeyPoint> compute_reference(std::string image, int gradient_size, int block_size, BorderMode border_mode, Format format, const HarrisCornersParameters ¶ms) { + // Load the image (cached by the library if loaded before) + const RawTensor &raw = library->get(image, format); // Create reference - SimpleTensor<T> src{ shape, format }; + SimpleTensor<T> src{ raw.shape(), format }; // Fill reference - fill(src); + fill(src, raw); return reference::harris_corner_detector<T>(src, params.threshold, params.min_dist, params.sensitivity, gradient_size, block_size, border_mode, params.constant_border_value); } |