diff options
author | Giorgio Arena <giorgio.arena@arm.com> | 2017-06-16 13:57:33 +0100 |
---|---|---|
committer | Anthony Barbier <anthony.barbier@arm.com> | 2018-09-17 14:13:23 +0100 |
commit | fda461824f18f0c7429abc899caea39937af88bc (patch) | |
tree | 0908c7822e8a5e8e945519d53335360318a40af1 /tests | |
parent | 5b51229fad2fcf639051abb6eabfffe98eaadd06 (diff) | |
download | ComputeLibrary-fda461824f18f0c7429abc899caea39937af88bc.tar.gz |
COMPMID-378 IntegralImage testing completed.
Change-Id: I848713c8aa4382b01111af714a207f92eefcdb44
Reviewed-on: http://mpd-gerrit.cambridge.arm.com/77878
Tested-by: Kaizen <jeremy.johnson+kaizengerrit@arm.com>
Reviewed-by: Steven Niu <steven.niu@arm.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/TensorLibrary.cpp | 37 | ||||
-rw-r--r-- | tests/TensorLibrary.h | 6 |
2 files changed, 18 insertions, 25 deletions
diff --git a/tests/TensorLibrary.cpp b/tests/TensorLibrary.cpp index 0c85136a38..21bb4ecd73 100644 --- a/tests/TensorLibrary.cpp +++ b/tests/TensorLibrary.cpp @@ -46,33 +46,14 @@ namespace test { namespace { -void convert_rgb_to_u8(const RawTensor &src, RawTensor &dst) +template <typename T, typename std::enable_if<std::is_integral<T>::value, int>::type = 0> +void rgb_to_luminance(const RawTensor &src, RawTensor &dst) { const size_t min_size = std::min(src.size(), dst.size()); for(size_t i = 0, j = 0; i < min_size; i += 3, ++j) { - dst.data()[j] = 0.2126f * src.data()[i + 0] + 0.7152f * src.data()[i + 1] + 0.0722f * src.data()[i + 2]; - } -} - -void convert_rgb_to_u16(const RawTensor &src, RawTensor &dst) -{ - const size_t min_size = std::min(src.size(), dst.size()); - - for(size_t i = 0, j = 0; i < min_size; i += 3, ++j) - { - reinterpret_cast<uint16_t *>(dst.data())[j] = 0.2126f * src.data()[i + 0] + 0.7152f * src.data()[i + 1] + 0.0722f * src.data()[i + 2]; - } -} - -void convert_rgb_to_s16(const RawTensor &src, RawTensor &dst) -{ - const size_t min_size = std::min(src.size(), dst.size()); - - for(size_t i = 0, j = 0; i < min_size; i += 3, ++j) - { - reinterpret_cast<int16_t *>(dst.data())[j] = 0.2126f * src.data()[i + 0] + 0.7152f * src.data()[i + 1] + 0.0722f * src.data()[i + 2]; + reinterpret_cast<T *>(dst.data())[j] = 0.2126f * src.data()[i + 0] + 0.7152f * src.data()[i + 1] + 0.0722f * src.data()[i + 2]; } } @@ -261,9 +242,10 @@ const TensorLibrary::Converter &TensorLibrary::get_converter(Format src, Format { static std::map<std::pair<Format, Format>, Converter> converters = { - { std::make_pair(Format::RGB888, Format::U8), convert_rgb_to_u8 }, - { std::make_pair(Format::RGB888, Format::U16), convert_rgb_to_u16 }, - { std::make_pair(Format::RGB888, Format::S16), convert_rgb_to_s16 } + { std::make_pair(Format::RGB888, Format::U8), rgb_to_luminance<uint8_t> }, + { std::make_pair(Format::RGB888, Format::U16), rgb_to_luminance<uint16_t> }, + { std::make_pair(Format::RGB888, Format::S16), rgb_to_luminance<int16_t> }, + { std::make_pair(Format::RGB888, Format::U32), rgb_to_luminance<uint32_t> } }; const auto it = converters.find(std::make_pair(src, dst)); @@ -413,6 +395,11 @@ const RawTensor &TensorLibrary::find_or_create_raw_tensor(const std::string &nam return _cache.add(std::make_tuple(name, format, channel), std::move(dst)); } +TensorShape TensorLibrary::get_image_shape(const std::string &name) +{ + return load_image(name).shape(); +} + RawTensor TensorLibrary::get(const TensorShape &shape, DataType data_type, int num_channels, int fixed_point_position) { return RawTensor(shape, data_type, num_channels, fixed_point_position); diff --git a/tests/TensorLibrary.h b/tests/TensorLibrary.h index b3974836ae..bdf91c6eda 100644 --- a/tests/TensorLibrary.h +++ b/tests/TensorLibrary.h @@ -73,6 +73,12 @@ public: /** Seed that is used to fill tensors with random values. */ std::random_device::result_type seed() const; + /** Provides a tensor shape for the specified image. + * + * @param[in] name Image file used to look up the raw tensor. + */ + TensorShape get_image_shape(const std::string &name); + /** Creates an uninitialised raw tensor with the given @p shape, @p * data_type and @p num_channels. * |