From 06cf9339ed4b86d559c837dcb7c1c273ae6a35eb Mon Sep 17 00:00:00 2001 From: Sang-Hoon Park Date: Tue, 31 Mar 2020 15:59:41 +0100 Subject: COMPMID-3294: Add AssetLibrary instance using a fixed seed - Add fixed_seed instance for future use - Make Copy fixture use the new instance to validate functionality Change-Id: I7e8c1504b8db3203213d084b300f10ecd384f7fa Signed-off-by: Sang-Hoon Park Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/3107 Tested-by: Arm Jenkins Reviewed-by: Georgios Pinitas Comments-Addressed: Arm Jenkins --- tests/Globals.h | 3 ++- tests/main.cpp | 9 +++++++-- tests/validate_examples/RunExample.cpp | 5 ++++- tests/validation/CL/Copy.cpp | 4 +++- tests/validation/NEON/Copy.cpp | 5 +++-- tests/validation/fixtures/CopyFixture.h | 5 +++-- 6 files changed, 22 insertions(+), 9 deletions(-) diff --git a/tests/Globals.h b/tests/Globals.h index 2a13f343d0..db79e33f02 100644 --- a/tests/Globals.h +++ b/tests/Globals.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2019 ARM Limited. + * Copyright (c) 2017-2020 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -34,6 +34,7 @@ namespace arm_compute namespace test { extern std::unique_ptr library; +extern std::unique_ptr fixed_library; extern std::unique_ptr parameters; } // namespace test } // namespace arm_compute diff --git a/tests/main.cpp b/tests/main.cpp index bbb43c9a39..17342fc2c1 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -75,7 +75,11 @@ namespace arm_compute { namespace test { -std::unique_ptr library; +std::unique_ptr library; + +static constexpr uint32_t fixed_seed = 1; +std::unique_ptr fixed_library; + extern std::unique_ptr parameters; } // namespace test } // namespace arm_compute @@ -308,7 +312,8 @@ int main(int argc, char **argv) return 0; } - library = support::cpp14::make_unique(assets->value(), seed->value()); + library = support::cpp14::make_unique(assets->value(), seed->value()); + fixed_library = support::cpp14::make_unique(assets->value(), fixed_seed); if(!parser.validate()) { diff --git a/tests/validate_examples/RunExample.cpp b/tests/validate_examples/RunExample.cpp index 5d5291abfb..998d5013a8 100644 --- a/tests/validate_examples/RunExample.cpp +++ b/tests/validate_examples/RunExample.cpp @@ -53,6 +53,8 @@ namespace arm_compute namespace test { std::unique_ptr library; +static constexpr uint32_t fixed_seed = 1; +std::unique_ptr fixed_library; } // namespace test namespace utils { @@ -136,7 +138,8 @@ int run_example(int argc, char **argv, std::unique_ptr example) g_example_argv.emplace_back(const_cast(arg.c_str())); // NOLINT } - library = support::cpp14::make_unique("." /* Only using random values */, seed->value()); + library = support::cpp14::make_unique("." /* Only using random values */, seed->value()); + fixed_library = support::cpp14::make_unique(".", fixed_seed); if(options.log_level->value() > framework::LogLevel::NONE) { diff --git a/tests/validation/CL/Copy.cpp b/tests/validation/CL/Copy.cpp index fdbd07bd4b..34ba3ab532 100644 --- a/tests/validation/CL/Copy.cpp +++ b/tests/validation/CL/Copy.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2019 ARM Limited. + * Copyright (c) 2018-2020 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -67,6 +67,7 @@ DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip( template using CLCopyFixture = CopyFixture; +TEST_SUITE(FixedSeed) TEST_SUITE(F32) FIXTURE_DATA_TEST_CASE(RunSmall, CLCopyFixture, framework::DatasetMode::ALL, combine(zip(datasets::SmallShapes(), datasets::SmallShapes()), framework::dataset::make("DataType", DataType::F32))) @@ -93,6 +94,7 @@ FIXTURE_DATA_TEST_CASE(RunSmall, CLCopyFixture, framework::DatasetMode validate(CLAccessor(_target), _reference); } TEST_SUITE_END() // U16 +TEST_SUITE_END() // FixedSeed TEST_SUITE_END() // Copy TEST_SUITE_END() // CL diff --git a/tests/validation/NEON/Copy.cpp b/tests/validation/NEON/Copy.cpp index c2dedeff76..350fd0085e 100644 --- a/tests/validation/NEON/Copy.cpp +++ b/tests/validation/NEON/Copy.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2019 ARM Limited. + * Copyright (c) 2018-2020 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -62,7 +62,7 @@ DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip( } // clang-format on // *INDENT-ON* - +TEST_SUITE(FixedSeed) TEST_SUITE(F32) FIXTURE_DATA_TEST_CASE(RunSmall, NECopyFixture, framework::DatasetMode::ALL, combine(zip(datasets::SmallShapes(), datasets::SmallShapes()), framework::dataset::make("DataType", DataType::F32))) @@ -89,6 +89,7 @@ FIXTURE_DATA_TEST_CASE(RunSmall, NECopyFixture, framework::DatasetMode validate(Accessor(_target), _reference); } TEST_SUITE_END() // U16 +TEST_SUITE_END() // FixedSeed TEST_SUITE_END() // Copy TEST_SUITE_END() // NEON diff --git a/tests/validation/fixtures/CopyFixture.h b/tests/validation/fixtures/CopyFixture.h index 911d908e53..534d5b3145 100644 --- a/tests/validation/fixtures/CopyFixture.h +++ b/tests/validation/fixtures/CopyFixture.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 ARM Limited. + * Copyright (c) 2018-2020 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -54,7 +54,8 @@ protected: template void fill(U &&tensor, int i) { - library->fill_tensor_uniform(tensor, i); + // This kernel doesn't benefit from using random seed as it just copies values. + fixed_library->fill_tensor_uniform(tensor, i); } TensorType compute_target(const TensorShape &input_shape, const TensorShape &output_shape, DataType data_type) -- cgit v1.2.1