DPC++ Runtime
Runtime libraries for oneAPI DPC++
tfloat32.hpp
Go to the documentation of this file.
1
//==--------- tfloat32.hpp ------- SYCL tensorfloat32 conversion ------==//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
// Implementation of SIMD tfloat32 type.
9
//===----------------------------------------------------------------------===//
10
11
#pragma once
12
13
#include <
CL/__spirv/spirv_ops.hpp
>
14
#include <
sycl/bit_cast.hpp
>
15
16
namespace
sycl
{
17
inline
namespace
_V1 {
18
namespace
ext {
19
namespace
intel {
20
namespace
experimental {
21
namespace
esimd {
22
23
class
tfloat32
{
24
using
storage_t = uint32_t;
25
storage_t value;
26
27
public
:
28
tfloat32
() =
default
;
29
tfloat32
(
const
tfloat32
&) =
default
;
30
~tfloat32
() =
default
;
31
32
// Explicit conversion functions
33
static
storage_t
from_float
(
const
float
&a) {
34
storage_t tmp_uint = sycl::bit_cast<storage_t>(
a
);
35
tmp_uint &= 0xFFFFE000u;
36
return
tmp_uint;
37
}
38
static
float
to_float
(
const
storage_t &a) {
39
return
sycl::bit_cast<float>(
a
& 0xFFFFE000u);
40
}
41
42
// Implicit conversion from float to tfloat32
43
tfloat32
(
const
float
&a) { value =
from_float
(
a
); }
44
45
tfloat32
&
operator=
(
const
float
&rhs) {
46
value =
from_float
(rhs);
47
return
*
this
;
48
}
49
50
// Implicit conversion from tfloat32 to float
51
operator
float()
const
{
return
to_float
(value); }
52
53
// Get raw bits representation of tfloat32
54
storage_t
raw
()
const
{
return
value; }
55
56
// Logical operators (!,||,&&) are covered if we can cast to bool
57
explicit
operator
bool() {
return
to_float
(value) != 0.0f; }
58
59
// Unary minus operator overloading
60
friend
tfloat32
operator-
(
tfloat32
&lhs) {
return
tfloat32
(-
to_float
(lhs)); }
61
};
62
63
}
// namespace esimd
64
}
// namespace experimental
65
}
// namespace intel
66
}
// namespace ext
67
68
}
// namespace _V1
69
}
// namespace sycl
bit_cast.hpp
sycl::_V1::ext::intel::experimental::esimd::tfloat32
Definition:
tfloat32.hpp:23
sycl::_V1::ext::intel::experimental::esimd::tfloat32::tfloat32
tfloat32()=default
sycl::_V1::ext::intel::experimental::esimd::tfloat32::raw
storage_t raw() const
Definition:
tfloat32.hpp:54
sycl::_V1::ext::intel::experimental::esimd::tfloat32::tfloat32
tfloat32(const float &a)
Definition:
tfloat32.hpp:43
sycl::_V1::ext::intel::experimental::esimd::tfloat32::operator-
friend tfloat32 operator-(tfloat32 &lhs)
Definition:
tfloat32.hpp:60
sycl::_V1::ext::intel::experimental::esimd::tfloat32::tfloat32
tfloat32(const tfloat32 &)=default
sycl::_V1::ext::intel::experimental::esimd::tfloat32::from_float
static storage_t from_float(const float &a)
Definition:
tfloat32.hpp:33
sycl::_V1::ext::intel::experimental::esimd::tfloat32::operator=
tfloat32 & operator=(const float &rhs)
Definition:
tfloat32.hpp:45
sycl::_V1::ext::intel::experimental::esimd::tfloat32::~tfloat32
~tfloat32()=default
sycl::_V1::ext::intel::experimental::esimd::tfloat32::to_float
static float to_float(const storage_t &a)
Definition:
tfloat32.hpp:38
sycl::_V1::a
auto a
Definition:
integer_functions.cpp:179
sycl
Definition:
access.hpp:18
spirv_ops.hpp
include
sycl
ext
intel
experimental
esimd
tfloat32.hpp
Generated by
1.9.1