From e8291acc1d9e89c9274d31f0d5bb4779eb95588c Mon Sep 17 00:00:00 2001 From: Georgios Pinitas Date: Wed, 26 Feb 2020 09:58:13 +0000 Subject: COMPMID-3152: Initial Bfloat16 support Signed-off-by: Georgios Pinitas Change-Id: Ie6959e37e13731c86b2ee29392a99a293450a1b4 Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/2824 Tested-by: Arm Jenkins Comments-Addressed: Arm Jenkins Reviewed-by: Michalis Spyrou --- arm_compute/core/PixelValue.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'arm_compute/core/PixelValue.h') diff --git a/arm_compute/core/PixelValue.h b/arm_compute/core/PixelValue.h index 31bc55098a..337ccbc3f7 100644 --- a/arm_compute/core/PixelValue.h +++ b/arm_compute/core/PixelValue.h @@ -89,6 +89,9 @@ public: case DataType::S64: value.s64 = static_cast(v); break; + case DataType::BFLOAT16: + value.bf16 = static_cast(v); + break; case DataType::F16: value.f16 = static_cast(v); break; @@ -174,6 +177,15 @@ public: { value.s64 = v; } + /** Initialize the union with a BFLOAT16 pixel value + * + * @param[in] v F16 value. + */ + PixelValue(bfloat16 v) + : PixelValue() + { + value.bf16 = v; + } /** Initialize the union with a F16 pixel value * * @param[in] v F16 value. @@ -214,6 +226,7 @@ public: double f64; /**< Single channel double */ float f32; /**< Single channel float 32 */ half f16; /**< Single channel F16 */ + bfloat16 bf16; /**< Single channel brain floating-point number */ uint8_t u8; /**< Single channel U8 */ int8_t s8; /**< Single channel S8 */ uint16_t u16; /**< Single channel U16 */ @@ -285,6 +298,14 @@ public: { v = value.s64; } + /** Interpret the pixel value as a BFLOAT16 + * + * @param[out] v Returned value + */ + void get(bfloat16 &v) const + { + v = value.bf16; + } /** Interpret the pixel value as a F16 * * @param[out] v Returned value -- cgit v1.2.1