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 <sang-hoon.park@arm.com>
Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/3107
Tested-by: Arm Jenkins <bsgcomp@arm.com>
Reviewed-by: Georgios Pinitas <georgios.pinitas@arm.com>
Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
diff --git a/tests/Globals.h b/tests/Globals.h
index 2a13f34..db79e33 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 test
{
extern std::unique_ptr<AssetsLibrary> library;
+extern std::unique_ptr<AssetsLibrary> fixed_library;
extern std::unique_ptr<ParametersLibrary> parameters;
} // namespace test
} // namespace arm_compute
diff --git a/tests/main.cpp b/tests/main.cpp
index bbb43c9..17342fc 100644
--- a/tests/main.cpp
+++ b/tests/main.cpp
@@ -75,7 +75,11 @@
{
namespace test
{
-std::unique_ptr<AssetsLibrary> library;
+std::unique_ptr<AssetsLibrary> library;
+
+static constexpr uint32_t fixed_seed = 1;
+std::unique_ptr<AssetsLibrary> fixed_library;
+
extern std::unique_ptr<ParametersLibrary> parameters;
} // namespace test
} // namespace arm_compute
@@ -308,7 +312,8 @@
return 0;
}
- library = support::cpp14::make_unique<AssetsLibrary>(assets->value(), seed->value());
+ library = support::cpp14::make_unique<AssetsLibrary>(assets->value(), seed->value());
+ fixed_library = support::cpp14::make_unique<AssetsLibrary>(assets->value(), fixed_seed);
if(!parser.validate())
{
diff --git a/tests/validate_examples/RunExample.cpp b/tests/validate_examples/RunExample.cpp
index 5d5291a..998d501 100644
--- a/tests/validate_examples/RunExample.cpp
+++ b/tests/validate_examples/RunExample.cpp
@@ -53,6 +53,8 @@
namespace test
{
std::unique_ptr<AssetsLibrary> library;
+static constexpr uint32_t fixed_seed = 1;
+std::unique_ptr<AssetsLibrary> fixed_library;
} // namespace test
namespace utils
{
@@ -136,7 +138,8 @@
g_example_argv.emplace_back(const_cast<char *>(arg.c_str())); // NOLINT
}
- library = support::cpp14::make_unique<AssetsLibrary>("." /* Only using random values */, seed->value());
+ library = support::cpp14::make_unique<AssetsLibrary>("." /* Only using random values */, seed->value());
+ fixed_library = support::cpp14::make_unique<AssetsLibrary>(".", 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 fdbd07b..34ba3ab 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 @@
template <typename T>
using CLCopyFixture = CopyFixture<CLTensor, CLAccessor, CLCopy, T>;
+TEST_SUITE(FixedSeed)
TEST_SUITE(F32)
FIXTURE_DATA_TEST_CASE(RunSmall, CLCopyFixture<float>, framework::DatasetMode::ALL, combine(zip(datasets::SmallShapes(), datasets::SmallShapes()), framework::dataset::make("DataType",
DataType::F32)))
@@ -93,6 +94,7 @@
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 c2dedef..350fd00 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 @@
}
// clang-format on
// *INDENT-ON*
-
+TEST_SUITE(FixedSeed)
TEST_SUITE(F32)
FIXTURE_DATA_TEST_CASE(RunSmall, NECopyFixture<float>, framework::DatasetMode::ALL, combine(zip(datasets::SmallShapes(), datasets::SmallShapes()), framework::dataset::make("DataType",
DataType::F32)))
@@ -89,6 +89,7 @@
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 911d908..534d5b3 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 @@
template <typename U>
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)