diff options
author | Michalis Spyrou <michalis.spyrou@arm.com> | 2017-09-27 15:55:31 +0100 |
---|---|---|
committer | Anthony Barbier <anthony.barbier@arm.com> | 2018-11-02 16:35:24 +0000 |
commit | 53b405f1e08ad41cb9a527abfe0308ec1edf18ff (patch) | |
tree | 558ab134cd084fc7bc072e06e9cffb10447c058e /utils/GraphUtils.h | |
parent | b2881fcabbc7507bb1d670e5233dd786ae597714 (diff) | |
download | ComputeLibrary-53b405f1e08ad41cb9a527abfe0308ec1edf18ff.tar.gz |
COMPMID-417 - Add RandomAccessor support in Graph API.
Change-Id: I54dd435258a2d0ff486ded64b23654bab6b80f3f
Reviewed-on: http://mpd-gerrit.cambridge.arm.com/89373
Tested-by: Kaizen <jeremy.johnson+kaizengerrit@arm.com>
Reviewed-by: Georgios Pinitas <georgios.pinitas@arm.com>
Diffstat (limited to 'utils/GraphUtils.h')
-rw-r--r-- | utils/GraphUtils.h | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/utils/GraphUtils.h b/utils/GraphUtils.h index a19f7e510d..c8cbb00237 100644 --- a/utils/GraphUtils.h +++ b/utils/GraphUtils.h @@ -24,9 +24,12 @@ #ifndef __ARM_COMPUTE_GRAPH_UTILS_H__ #define __ARM_COMPUTE_GRAPH_UTILS_H__ +#include "arm_compute/core/PixelValue.h" #include "arm_compute/graph/ITensorAccessor.h" #include "arm_compute/graph/Types.h" +#include <random> + namespace arm_compute { namespace graph_utils @@ -54,7 +57,7 @@ private: }; /** Dummy accessor class */ -class DummyAccessor : public graph::ITensorAccessor +class DummyAccessor final : public graph::ITensorAccessor { public: /** Constructor @@ -73,8 +76,33 @@ private: unsigned int _maximum; }; +/** Random accessor class */ +class RandomAccessor final : public graph::ITensorAccessor +{ +public: + /** Constructor + * + * @param[in] lower Lower bound value. + * @param[in] upper Upper bound value. + * @param[in] seed (Optional) Seed used to initialise the random number generator. + */ + RandomAccessor(PixelValue lower, PixelValue upper, const std::random_device::result_type seed = 0); + /** Allows instances to move constructed */ + RandomAccessor(RandomAccessor &&) = default; + + // Inherited methods overriden: + bool access_tensor(ITensor &tensor) override; + +private: + template <typename T, typename D> + void fill(ITensor &tensor, D &&distribution); + PixelValue _lower; + PixelValue _upper; + std::random_device::result_type _seed; +}; + /** Numpy Binary loader class*/ -class NumPyBinLoader : public graph::ITensorAccessor +class NumPyBinLoader final : public graph::ITensorAccessor { public: /** Default Constructor |