COMPMID-3294: Add AssetLibrary instance using a fixed seed
authorSang-Hoon Park <sang-hoon.park@arm.com>
Tue, 31 Mar 2020 14:59:41 +0000 (15:59 +0100)
committerGeorgios Pinitas <georgios.pinitas@arm.com>
Tue, 28 Apr 2020 18:30:41 +0000 (18:30 +0000)
- 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>

tests/Globals.h
tests/main.cpp
tests/validate_examples/RunExample.cpp
tests/validation/CL/Copy.cpp
tests/validation/NEON/Copy.cpp
tests/validation/fixtures/CopyFixture.h

index 2a13f343d04deb1362ede2dcea8f737ea20f5982..db79e33f0214723c957b42089800689a256cd730 100644 (file)
@@ -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<AssetsLibrary>     library;
+extern std::unique_ptr<AssetsLibrary>     fixed_library;
 extern std::unique_ptr<ParametersLibrary> parameters;
 } // namespace test
 } // namespace arm_compute
index bbb43c9a39439c8af5ab266288b5f699e282d823..17342fc2c15d021181586ebc27f9f701ca77a0be 100644 (file)
@@ -75,7 +75,11 @@ namespace arm_compute
 {
 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 @@ int main(int argc, char **argv)
             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())
         {
index 5d5291abfbeaf5fbb1cf756cf067cb37017ee376..998d5013a837492c688d275242cfa3e547e57ba0 100644 (file)
@@ -53,6 +53,8 @@ namespace arm_compute
 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 @@ int run_example(int argc, char **argv, std::unique_ptr<ValidateExample> example)
         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)
     {
index fdbd07bd4bb3f6b396887775a97e895bd832e73b..34ba3ab532cf30674f67a724b4baec14c9ddff82 100644 (file)
@@ -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 <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 @@ FIXTURE_DATA_TEST_CASE(RunSmall, CLCopyFixture<uint16_t>, framework::DatasetMode
     validate(CLAccessor(_target), _reference);
 }
 TEST_SUITE_END() // U16
+TEST_SUITE_END() // FixedSeed
 
 TEST_SUITE_END() // Copy
 TEST_SUITE_END() // CL
index c2dedeff76f07845885bcfc692a694cac7d85a75..350fd0085e961c622c0dc2309f40a6c19d19d287 100644 (file)
@@ -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<float>, 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<uint16_t>, framework::DatasetMode
     validate(Accessor(_target), _reference);
 }
 TEST_SUITE_END() // U16
+TEST_SUITE_END() // FixedSeed
 
 TEST_SUITE_END() // Copy
 TEST_SUITE_END() // NEON
index 911d908e534c6859c039a1a5dc8af58ce98b1759..534d5b3145cfe0e92828cb7ba6efa0eefd3483f2 100644 (file)
@@ -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 <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)