From 44e9c2d2a2d0d9111989a0611b30bb3f7d80f2b3 Mon Sep 17 00:00:00 2001 From: Alexey Sotkin Date: Thu, 30 Dec 2021 16:07:29 +0300 Subject: [PATCH 1/4] Update SYCL_INTEL_bf16_conversion.asciidoc Align the document with changes made in https://github.com/intel/llvm/pull/4989 --- .../SYCL_INTEL_bf16_conversion.asciidoc | 29 ++++++++++++++----- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/sycl/doc/extensions/Bf16Conversion/SYCL_INTEL_bf16_conversion.asciidoc b/sycl/doc/extensions/Bf16Conversion/SYCL_INTEL_bf16_conversion.asciidoc index 125a2c3d203d1..2936dfe8bc7ff 100644 --- a/sycl/doc/extensions/Bf16Conversion/SYCL_INTEL_bf16_conversion.asciidoc +++ b/sycl/doc/extensions/Bf16Conversion/SYCL_INTEL_bf16_conversion.asciidoc @@ -124,6 +124,9 @@ public: bfloat16(const bfloat16 &) = default; ~bfloat16() = default; + // Explicit initialization + static bfloat16 from_bits(const storage_t &a); + // Explicit conversion functions static storage_t from_float(const float &a); static float to_float(const storage_t &a); @@ -132,15 +135,16 @@ public: bfloat16(const float &a); bfloat16 &operator=(const float &a); - // Convert from bfloat16 to float + // Convert bfloat16 to floating-point types operator float() const; + operator sycl::half() const - // Get bfloat16 as uint16. - operator storage_t() const; - - // Convert to bool type + // Convert bfloat16 to bool type explicit operator bool(); + // Get bfloat16 as raw bits. + storage_t raw() const; + friend bfloat16 operator-(bfloat16 &bf) { /* ... */ } // OP is: prefix ++, -- @@ -177,6 +181,9 @@ Table 1. Member functions of `bfloat16` class. |=== | Member Function | Description +| `static bfloat16 from_bits(const storage_t &a);` +| Create `bfloat16` with the `value` equals to `a`. + | `static storage_t from_float(const float &a);` | Explicitly convert from `float` to `bfloat16`. @@ -192,13 +199,16 @@ Table 1. Member functions of `bfloat16` class. | `operator float() const;` | Return `bfloat16` value converted to `float`. -| `operator storage_t() const;` -| Return `uint16_t` value, whose bits represent `bfloat16` value. +| `operator sycl::half() const;` +| Return `bfloat16` value converted to `sycl::half`. | `explicit operator bool() { /* ... */ }` -| Convert `bfloat16` to `bool` type. Return `false` if the value equals to +| Convert `bfloat16` to `bool` type. Return `false` if the `value` equals to zero, return `true` otherwise. +| `storage_t raw() const` +| Return raw bits representing the `bfloat16` value. + | `friend bfloat16 operator-(bfloat16 &bf) { /* ... */ }` | Construct new instance of `bfloat16` class with negated value of the `bf`. @@ -329,4 +339,7 @@ None. Add operator overloadings + Apply code review suggestions |3|2021-08-18|Alexey Sotkin |Remove `uint16_t` constructor +|4|2021-12-30|Alexey Sotkin |Add methods to explicitly set/get the value + with/as raw bits. + + Add `operator sycl::half()` |======================================== From a533286d97532009f67037ea9545d7995de16dd7 Mon Sep 17 00:00:00 2001 From: Rajiv Deodhar Date: Fri, 29 Apr 2022 15:06:20 -0700 Subject: [PATCH 2/4] Removed proposed raw() and from_bits() functions. --- .../Bf16Conversion/SYCL_INTEL_bf16_conversion.asciidoc | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/sycl/doc/extensions/Bf16Conversion/SYCL_INTEL_bf16_conversion.asciidoc b/sycl/doc/extensions/Bf16Conversion/SYCL_INTEL_bf16_conversion.asciidoc index 2936dfe8bc7ff..3332f572dc5ca 100644 --- a/sycl/doc/extensions/Bf16Conversion/SYCL_INTEL_bf16_conversion.asciidoc +++ b/sycl/doc/extensions/Bf16Conversion/SYCL_INTEL_bf16_conversion.asciidoc @@ -181,9 +181,6 @@ Table 1. Member functions of `bfloat16` class. |=== | Member Function | Description -| `static bfloat16 from_bits(const storage_t &a);` -| Create `bfloat16` with the `value` equals to `a`. - | `static storage_t from_float(const float &a);` | Explicitly convert from `float` to `bfloat16`. @@ -206,9 +203,6 @@ Table 1. Member functions of `bfloat16` class. | Convert `bfloat16` to `bool` type. Return `false` if the `value` equals to zero, return `true` otherwise. -| `storage_t raw() const` -| Return raw bits representing the `bfloat16` value. - | `friend bfloat16 operator-(bfloat16 &bf) { /* ... */ }` | Construct new instance of `bfloat16` class with negated value of the `bf`. @@ -339,7 +333,5 @@ None. Add operator overloadings + Apply code review suggestions |3|2021-08-18|Alexey Sotkin |Remove `uint16_t` constructor -|4|2021-12-30|Alexey Sotkin |Add methods to explicitly set/get the value - with/as raw bits. + - Add `operator sycl::half()` +|4|2021-12-30|Alexey Sotkin |Add `operator sycl::half()` |======================================== From 04fc2993fb007fc0c19f064f67b58fb98ae1e40c Mon Sep 17 00:00:00 2001 From: Rajiv Deodhar Date: Mon, 2 May 2022 09:25:50 -0700 Subject: [PATCH 3/4] Remove unneeded functions. --- .../Bf16Conversion/SYCL_INTEL_bf16_conversion.asciidoc | 6 ------ 1 file changed, 6 deletions(-) diff --git a/sycl/doc/extensions/Bf16Conversion/SYCL_INTEL_bf16_conversion.asciidoc b/sycl/doc/extensions/Bf16Conversion/SYCL_INTEL_bf16_conversion.asciidoc index 3332f572dc5ca..9b0646e1c9dbf 100644 --- a/sycl/doc/extensions/Bf16Conversion/SYCL_INTEL_bf16_conversion.asciidoc +++ b/sycl/doc/extensions/Bf16Conversion/SYCL_INTEL_bf16_conversion.asciidoc @@ -124,9 +124,6 @@ public: bfloat16(const bfloat16 &) = default; ~bfloat16() = default; - // Explicit initialization - static bfloat16 from_bits(const storage_t &a); - // Explicit conversion functions static storage_t from_float(const float &a); static float to_float(const storage_t &a); @@ -142,9 +139,6 @@ public: // Convert bfloat16 to bool type explicit operator bool(); - // Get bfloat16 as raw bits. - storage_t raw() const; - friend bfloat16 operator-(bfloat16 &bf) { /* ... */ } // OP is: prefix ++, -- From 37835ee9d094969b7d3516da3b8f2395b98b451c Mon Sep 17 00:00:00 2001 From: Greg Lueck Date: Mon, 9 May 2022 09:44:51 -0400 Subject: [PATCH 4/4] Fix merge mistake We decided in the PR comments to remove this implicit conversion to `uint16_t`, and it was removed from the table describing the member functions. I think it was just a merge mistake that this conversion was re-added to the synopsis, so remove it. --- .../extensions/experimental/sycl_ext_oneapi_bfloat16.asciidoc | 3 --- 1 file changed, 3 deletions(-) diff --git a/sycl/doc/extensions/experimental/sycl_ext_oneapi_bfloat16.asciidoc b/sycl/doc/extensions/experimental/sycl_ext_oneapi_bfloat16.asciidoc index 25bd949e6a789..4167a91570d97 100644 --- a/sycl/doc/extensions/experimental/sycl_ext_oneapi_bfloat16.asciidoc +++ b/sycl/doc/extensions/experimental/sycl_ext_oneapi_bfloat16.asciidoc @@ -139,9 +139,6 @@ public: operator float() const; operator sycl::half() const; - // Get bfloat16 as uint16. - operator storage_t() const; - // Convert bfloat16 to bool type explicit operator bool();