Skip to content

Update SYCL_INTEL_bf16_conversion.asciidoc #5248

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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 ++, --
Expand Down Expand Up @@ -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`.

Expand All @@ -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`.

Expand Down Expand Up @@ -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()`
|========================================