From d7647d4ebd0f0b5253b7f31ffcd48a851ba62947 Mon Sep 17 00:00:00 2001 From: Giuseppe Rossini Date: Tue, 17 Jul 2018 18:13:13 +0100 Subject: [COMPMID-1229] Implementing Pad on OpenCL -FP32/FP16 Change-Id: Ideead99410e5e0bda1035030af1bbcd0a65ea15e Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/144792 Tested-by: bsgcomp Reviewed-by: Georgios Pinitas --- src/core/Utils.cpp | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'src/core/Utils.cpp') diff --git a/src/core/Utils.cpp b/src/core/Utils.cpp index 11bdbdafe0..229579d8d9 100644 --- a/src/core/Utils.cpp +++ b/src/core/Utils.cpp @@ -252,6 +252,55 @@ const std::string &arm_compute::string_from_pooling_type(PoolingType type) return pool_type_map[type]; } +std::string arm_compute::string_from_pixel_value(const PixelValue &value, const DataType data_type) +{ + std::stringstream ss; + std::string converted_string; + + switch(data_type) + { + case DataType::U8: + case DataType::QASYMM8: + // Needs conversion to 32 bit, otherwise interpreted as ASCII values + ss << uint32_t(value.get()); + converted_string = ss.str(); + break; + case DataType::S8: + // Needs conversion to 32 bit, otherwise interpreted as ASCII values + ss << int32_t(value.get()); + converted_string = ss.str(); + break; + case DataType::U16: + ss << value.get(); + converted_string = ss.str(); + break; + case DataType::S16: + ss << value.get(); + converted_string = ss.str(); + break; + case DataType::U32: + ss << value.get(); + converted_string = ss.str(); + break; + case DataType::S32: + ss << value.get(); + converted_string = ss.str(); + break; + case DataType::F32: + converted_string = float_to_string_with_full_precision(value.get()); + break; + case DataType::F16: + static_assert(sizeof(half) == 2, "Half must be 16 bit"); + ss << value.get(); + converted_string = ss.str(); + break; + default: + ARM_COMPUTE_ERROR("Not handled"); + } + + return converted_string; +} + std::string arm_compute::lower_string(const std::string &val) { std::string res = val; -- cgit v1.2.1