diff options
author | Mike Kelly <mike.kelly@arm.com> | 2021-06-27 22:39:21 +0100 |
---|---|---|
committer | mike.kelly <mike.kelly@arm.com> | 2021-06-30 10:38:30 +0000 |
commit | 0d677db72eb7945e304fc49cedf744f0c34ed330 (patch) | |
tree | ee85b7f50e4ad9d5e568b46df46777513a2197cd /src/backends/backendsCommon/test/CommonTestUtils.hpp | |
parent | 6f24b1aac9cbf5dfb3918cb59a7e903ddcec420e (diff) | |
download | armnn-0d677db72eb7945e304fc49cedf744f0c34ed330.tar.gz |
IVGCVSW-6114 Create multiple LoadedNetworks from one OptimizedNetwork
* Added IOptimizedNetwork constructor that takes another
IOptimizedNetwork and a ModelOptions.
* Changed PreCompiledLayer to use shared_ptr rather than unique_ptr
to store the PreCompiledObject (no interface changes).
* Added unit tests to ensure that PreCompiledLayer::Clone() clones
the pointer to the PreCompiledObject correctly.
Signed-off-by: Mike Kelly <mike.kelly@arm.com>
Change-Id: I3ef56055e0d189ffce9e651882d34da16c70a240
Diffstat (limited to 'src/backends/backendsCommon/test/CommonTestUtils.hpp')
-rw-r--r-- | src/backends/backendsCommon/test/CommonTestUtils.hpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/backends/backendsCommon/test/CommonTestUtils.hpp b/src/backends/backendsCommon/test/CommonTestUtils.hpp index 99412b9694..c7537f1eed 100644 --- a/src/backends/backendsCommon/test/CommonTestUtils.hpp +++ b/src/backends/backendsCommon/test/CommonTestUtils.hpp @@ -18,6 +18,8 @@ #include <test/TestUtils.hpp> #include <algorithm> +#include <random> +#include <vector> // Checks that two collections have the exact same contents (in any order) // The given collections do not have to contain duplicates @@ -94,3 +96,24 @@ armnn::TensorShape MakeTensorShape(unsigned int batches, unsigned int height, unsigned int width, armnn::DataLayout layout); + +template<typename DataType> +static std::vector<DataType> GenerateRandomData(size_t size) +{ + constexpr bool isIntegerType = std::is_integral<DataType>::value; + using Distribution = + typename std::conditional<isIntegerType, + std::uniform_int_distribution<DataType>, + std::uniform_real_distribution<DataType>>::type; + + static constexpr DataType lowerLimit = std::numeric_limits<DataType>::min(); + static constexpr DataType upperLimit = std::numeric_limits<DataType>::max(); + + static Distribution distribution(lowerLimit, upperLimit); + static std::default_random_engine generator; + + std::vector<DataType> randomData(size); + generate(randomData.begin(), randomData.end(), []() { return distribution(generator); }); + + return randomData; +} |