96#ifndef _HIP_INCLUDE_HIP_AMD_DETAIL_HIP_BF16_H_
97#define _HIP_INCLUDE_HIP_AMD_DETAIL_HIP_BF16_H_
99#if !defined(__HIPCC_RTC__)
100#include <hip/amd_detail/amd_hip_common.h>
103#include "amd_hip_vector_types.h"
107#define __BF16_DEVICE__ __device__
108#if defined(__HIPCC_RTC__)
109#define __BF16_HOST_DEVICE__ __BF16_DEVICE__
114#define __BF16_HOST_DEVICE__ __host__ __BF16_DEVICE__
116#define __BF16_DEVICE_STATIC__ __BF16_DEVICE__ static inline
117#define __BF16_HOST_DEVICE_STATIC__ __BF16_HOST_DEVICE__ static inline
119#if defined(__AVX512VL__) and defined(__AVX512BF16__) and not defined(__HIP_DEVICE_COMPILE__)
121#if defined(__MINGW64__)
124#include <immintrin.h>
126#define HIP_BF16_AVX512_OP 1
127static_assert(
sizeof(__bf16) ==
sizeof(
unsigned short),
128 "sizeof __bf16 should match sizeof unsigned short");
130#define HIP_BF16_AVX512_OP 0
133#define HIPRT_ONE_BF16 __float2bfloat16(1.0f)
134#define HIPRT_ZERO_BF16 __float2bfloat16(0.0f)
135#define HIPRT_INF_BF16 __ushort_as_bfloat16((unsigned short)0x7F80U)
136#define HIPRT_MAX_NORMAL_BF16 __ushort_as_bfloat16((unsigned short)0x7F7FU)
137#define HIPRT_MIN_DENORM_BF16 __ushort_as_bfloat16((unsigned short)0x0001U)
138#define HIPRT_NAN_BF16 __ushort_as_bfloat16((unsigned short)0x7FFFU)
139#define HIPRT_NEG_ZERO_BF16 __ushort_as_bfloat16((unsigned short)0x8000U)
144#if !defined(__HIPCC_RTC__)
145static_assert(CHAR_BIT == 8,
"byte size should be of 8 bits");
147static_assert(
sizeof(
unsigned short) == 2,
"size of unsigned short should be 2 bytes");
164} __hip_bfloat162_raw;
174 __BF16_HOST_DEVICE_STATIC__
float bfloatraw_2_float(
unsigned short val) {
175#if HIP_BF16_AVX512_OP
180 return _mm_cvtsbh_ss(u.bf16);
182 unsigned int uval = val << 16;
190 __BF16_HOST_DEVICE_STATIC__
unsigned short float_2_bfloatraw(
float f) {
191#if HIP_BF16_AVX512_OP
195 } u = {_mm_cvtness_sbh(f)};
202 if (~u.u32 & 0x7f800000) {
219 u.u32 += 0x7fff + ((u.u32 >> 16) & 1);
220 }
else if (u.u32 & 0xffff) {
231 return static_cast<unsigned short>(u.u32 >> 16);
235 __BF16_HOST_DEVICE_STATIC__
unsigned short double_2_bfloatraw(
double d_in) {
239 } u = {
static_cast<float>(d_in)};
243 if ((d_in > 0.0 && d > d_in) || (d_in < 0.0 && d < d_in)) {
248 return float_2_bfloatraw(u.fp32);
265 __BF16_HOST_DEVICE__ __hip_bfloat16(
unsigned int val)
266 : __x(double_2_bfloatraw(static_cast<double>(val))) {}
269 __BF16_HOST_DEVICE__ __hip_bfloat16(
int val)
270 : __x(double_2_bfloatraw(static_cast<double>(val))) {}
273 __BF16_HOST_DEVICE__ __hip_bfloat16(
unsigned short val)
274 : __x(float_2_bfloatraw(static_cast<float>(val))) {}
277 __BF16_HOST_DEVICE__ __hip_bfloat16(
short val)
278 : __x(float_2_bfloatraw(static_cast<float>(val))) {}
281 __BF16_HOST_DEVICE__ __hip_bfloat16(
const double val) : __x(double_2_bfloatraw(val)) {}
284 __BF16_HOST_DEVICE__ __hip_bfloat16(
const float val) : __x(float_2_bfloatraw(val)) {}
287 __BF16_HOST_DEVICE__ __hip_bfloat16(
const __hip_bfloat16_raw& val) : __x(val.x) {}
290 __BF16_HOST_DEVICE__ __hip_bfloat16() =
default;
293 __BF16_HOST_DEVICE__
operator __hip_bfloat16_raw()
const {
return __hip_bfloat16_raw{__x}; }
296 __BF16_HOST_DEVICE__
operator __hip_bfloat16_raw()
const volatile {
297 return __hip_bfloat16_raw{__x};
301 __BF16_HOST_DEVICE__
operator bool()
const {
302 auto val = bfloatraw_2_float(__x);
303 return val != 0.0f && val != -0.0f;
307 __BF16_HOST_DEVICE__
operator char()
const {
return static_cast<char>(bfloatraw_2_float(__x)); }
310 __BF16_HOST_DEVICE__
operator float()
const {
return bfloatraw_2_float(__x); }
313 __BF16_HOST_DEVICE__
operator int()
const {
return static_cast<int>(bfloatraw_2_float(__x)); }
316 __BF16_HOST_DEVICE__
operator long()
const {
return static_cast<long>(bfloatraw_2_float(__x)); }
319 __BF16_HOST_DEVICE__
operator long long()
const {
320 return static_cast<long long>(bfloatraw_2_float(__x));
324 __BF16_HOST_DEVICE__
operator short()
const {
return static_cast<short>(bfloatraw_2_float(__x)); }
327 __BF16_HOST_DEVICE__
operator signed char()
const {
328 return static_cast<signed char>(bfloatraw_2_float(__x));
332 __BF16_HOST_DEVICE__
operator unsigned char()
const {
333 return static_cast<unsigned char>(bfloatraw_2_float(__x));
337 __BF16_HOST_DEVICE__
operator unsigned int()
const {
338 return static_cast<unsigned int>(bfloatraw_2_float(__x));
342 __BF16_HOST_DEVICE__
operator unsigned long()
const {
343 return static_cast<unsigned long>(bfloatraw_2_float(__x));
347 __BF16_HOST_DEVICE__
operator unsigned long long()
const {
348 return static_cast<unsigned long long>(bfloatraw_2_float(__x));
352 __BF16_HOST_DEVICE__
operator unsigned short()
const {
353 return static_cast<unsigned short>(bfloatraw_2_float(__x));
359 __BF16_HOST_DEVICE__ __hip_bfloat16& operator=(
unsigned int val) {
360 __x = float_2_bfloatraw(
static_cast<float>(val));
365 __BF16_HOST_DEVICE__ __hip_bfloat16& operator=(
int val) {
366 __x = float_2_bfloatraw(
static_cast<float>(val));
371 __BF16_HOST_DEVICE__ __hip_bfloat16& operator=(
unsigned short val) {
372 __x = float_2_bfloatraw(
static_cast<float>(val));
377 __BF16_HOST_DEVICE__ __hip_bfloat16& operator=(
short val) {
378 __x = float_2_bfloatraw(
static_cast<float>(val));
383 __BF16_HOST_DEVICE__ __hip_bfloat16& operator=(
const double f) {
384 __x = float_2_bfloatraw(
static_cast<float>(f));
389 __BF16_HOST_DEVICE__ __hip_bfloat16& operator=(
const float f) {
390 __x = float_2_bfloatraw(f);
395 __BF16_HOST_DEVICE__ __hip_bfloat16& operator=(
const __hip_bfloat16_raw& hr) {
401 __BF16_HOST_DEVICE__
volatile __hip_bfloat16& operator=(
const __hip_bfloat16_raw& hr)
volatile {
407 __BF16_HOST_DEVICE__
volatile __hip_bfloat16& operator=(
408 const volatile __hip_bfloat16_raw& hr)
volatile {
429 __BF16_HOST_DEVICE__ __hip_bfloat162(
const __hip_bfloat162_raw& h2r)
430 : x(__hip_bfloat16(__hip_bfloat16_raw{h2r.x})),
431 y(__hip_bfloat16(__hip_bfloat16_raw{h2r.y})) {}
434 __BF16_HOST_DEVICE__ __hip_bfloat162(
const __hip_bfloat162& val) {
435 __hip_bfloat162_raw hr = val;
436 x = __hip_bfloat16_raw{hr.x};
437 y = __hip_bfloat16_raw{hr.y};
441 __BF16_HOST_DEVICE__ __hip_bfloat162(
const __hip_bfloat16& a,
const __hip_bfloat16& b)
445 __BF16_HOST_DEVICE__ __hip_bfloat162() =
default;
448 __BF16_HOST_DEVICE__
operator __hip_bfloat162_raw()
const {
449 __hip_bfloat16_raw l = x;
450 __hip_bfloat16_raw r = y;
451 return __hip_bfloat162_raw{l.x, r.x};
455 __BF16_HOST_DEVICE__
operator float2()
const {
456#if HIP_BF16_AVX512_OP
458 __hip_bfloat162_raw raw2;
460 static_assert(
sizeof(__bf16[2]) ==
sizeof(__hip_bfloat162_raw));
463 __m128bh pbf16{u.bf162[0], u.bf162[1], 0, 0};
464 __m128 pf32 = _mm_cvtpbh_ps(pbf16);
465 float2 ret(pf32[0], pf32[1]);
473 __BF16_HOST_DEVICE__ __hip_bfloat162& operator=(
const __hip_bfloat162_raw& h2r) {
474 x = __hip_bfloat16(__hip_bfloat16_raw{h2r.x});
475 y = __hip_bfloat16(__hip_bfloat16_raw{h2r.y});
480 __BF16_HOST_DEVICE__ __hip_bfloat162& operator=(
const __hip_bfloat162& src) {
481 __hip_bfloat162_raw hr = src;
482 x = __hip_bfloat16(__hip_bfloat16_raw{hr.x});
483 y = __hip_bfloat16(__hip_bfloat16_raw{hr.y});
503 __hip_bfloat16 ret{f};
521 return __hip_bfloat162(a, a);
538 unsigned short ret = h;
547 __hip_bfloat16 ret{a};
564 const __hip_bfloat16 b) {
565 return __hip_bfloat162(a, b);
573 __hip_bfloat162_raw hr = a;
574 return __hip_bfloat16(__hip_bfloat16_raw{hr.y});
582 __hip_bfloat162_raw hr = a;
583 return __hip_bfloat162(__hip_bfloat16_raw{hr.y}, __hip_bfloat16_raw{hr.y});
590__BF16_HOST_DEVICE_STATIC__
float __high2float(
const __hip_bfloat162 a) {
591 __hip_bfloat162_raw hr = a;
600 const __hip_bfloat162 b) {
601 __hip_bfloat162_raw hr_a = a;
602 __hip_bfloat162_raw hr_b = b;
603 return __hip_bfloat162(__hip_bfloat162_raw{hr_a.y, hr_b.y});
610__BF16_HOST_DEVICE_STATIC__ __hip_bfloat16
__low2bfloat16(
const __hip_bfloat162 a) {
611 __hip_bfloat162_raw hr = a;
612 return __hip_bfloat16(hr.x);
620 __hip_bfloat162_raw hr = a;
621 return __hip_bfloat162(hr.x, hr.x);
628__BF16_HOST_DEVICE_STATIC__
float __low2float(
const __hip_bfloat162 a) {
629 __hip_bfloat162_raw hr = a;
638 __hip_bfloat162_raw hr = a;
639 return __hip_bfloat162(__hip_bfloat162_raw{hr.y, hr.x});
647 const __hip_bfloat162 b) {
648 __hip_bfloat162_raw hr_a = a;
649 __hip_bfloat162_raw hr_b = b;
650 return __hip_bfloat162(__hip_bfloat162_raw{hr_a.x, hr_b.x});
658 return __hip_bfloat16(a);
666 return __hip_bfloat16(a);
673__BF16_HOST_DEVICE_STATIC__ __hip_bfloat16
__hadd(
const __hip_bfloat16 a,
const __hip_bfloat16 b) {
681__BF16_HOST_DEVICE_STATIC__ __hip_bfloat16
__hsub(
const __hip_bfloat16 a,
const __hip_bfloat16 b) {
689__BF16_HOST_DEVICE_STATIC__ __hip_bfloat16
__hdiv(
const __hip_bfloat16 a,
const __hip_bfloat16 b) {
697__BF16_DEVICE_STATIC__ __hip_bfloat16
__hfma(
const __hip_bfloat16 a,
const __hip_bfloat16 b,
698 const __hip_bfloat16 c) {
707__BF16_HOST_DEVICE_STATIC__ __hip_bfloat16
__hmul(
const __hip_bfloat16 a,
const __hip_bfloat16 b) {
715__BF16_HOST_DEVICE_STATIC__ __hip_bfloat16
__hneg(
const __hip_bfloat16 a) {
716 __hip_bfloat16_raw hr = a;
718 return __hip_bfloat16(hr);
725__BF16_HOST_DEVICE_STATIC__ __hip_bfloat16
__habs(
const __hip_bfloat16 a) {
726 __hip_bfloat16_raw hr = a;
728 return __hip_bfloat16(hr);
735__BF16_HOST_DEVICE_STATIC__ __hip_bfloat162
__h2div(
const __hip_bfloat162 a,
736 const __hip_bfloat162 b) {
737 __hip_bfloat162_raw hr_a = a;
738 __hip_bfloat162_raw hr_b = b;
749__BF16_HOST_DEVICE_STATIC__ __hip_bfloat162
__habs2(
const __hip_bfloat162 a) {
750 __hip_bfloat162_raw hr_a = a;
751 return __hip_bfloat162(
__habs(__hip_bfloat16_raw{hr_a.x}),
__habs(__hip_bfloat16_raw{hr_a.y}));
758__BF16_HOST_DEVICE_STATIC__ __hip_bfloat162
__hadd2(
const __hip_bfloat162 a,
759 const __hip_bfloat162 b) {
760 __hip_bfloat162_raw hr_a = a;
761 __hip_bfloat162_raw hr_b = b;
762 return __hip_bfloat162(
__hadd(__hip_bfloat16_raw{hr_a.x}, __hip_bfloat16_raw{hr_b.x}),
763 __hadd(__hip_bfloat16_raw{hr_a.y}, __hip_bfloat16_raw{hr_b.y}));
770__BF16_DEVICE_STATIC__ __hip_bfloat162
__hfma2(
const __hip_bfloat162 a,
const __hip_bfloat162 b,
771 const __hip_bfloat162 c) {
772 __hip_bfloat162_raw hr_a = a;
773 __hip_bfloat162_raw hr_b = b;
774 __hip_bfloat162_raw hr_c = c;
775 return __hip_bfloat162(
776 __hfma(__hip_bfloat16_raw{hr_a.x}, __hip_bfloat16_raw{hr_b.x}, __hip_bfloat16_raw{hr_c.x}),
777 __hfma(__hip_bfloat16_raw{hr_a.y}, __hip_bfloat16_raw{hr_b.y}, __hip_bfloat16_raw{hr_c.y}));
784__BF16_HOST_DEVICE_STATIC__ __hip_bfloat162
__hmul2(
const __hip_bfloat162 a,
785 const __hip_bfloat162 b) {
786 __hip_bfloat162_raw hr_a = a;
787 __hip_bfloat162_raw hr_b = b;
788 return __hip_bfloat162(
__hmul(__hip_bfloat16_raw{hr_a.x}, __hip_bfloat16_raw{hr_b.x}),
789 __hmul(__hip_bfloat16_raw{hr_a.y}, __hip_bfloat16_raw{hr_b.y}));
796__BF16_HOST_DEVICE_STATIC__ __hip_bfloat162
__hneg2(
const __hip_bfloat162 a) {
797 __hip_bfloat162_raw hr_a = a;
798 return __hip_bfloat162(
__hneg(__hip_bfloat16_raw{hr_a.x}),
__hneg(__hip_bfloat16_raw{hr_a.y}));
805__BF16_HOST_DEVICE_STATIC__ __hip_bfloat162
__hsub2(
const __hip_bfloat162 a,
806 const __hip_bfloat162 b) {
807 __hip_bfloat162_raw hr_a = a;
808 __hip_bfloat162_raw hr_b = b;
809 return __hip_bfloat162(
__hsub(__hip_bfloat16_raw{hr_a.x}, __hip_bfloat16_raw{hr_b.x}),
810 __hsub(__hip_bfloat16_raw{hr_a.y}, __hip_bfloat16_raw{hr_b.y}));
817__BF16_HOST_DEVICE_STATIC__ __hip_bfloat16
operator*(
const __hip_bfloat16& l,
818 const __hip_bfloat16& r) {
826__BF16_HOST_DEVICE_STATIC__ __hip_bfloat16&
operator*=(__hip_bfloat16& l,
const __hip_bfloat16& r) {
835__BF16_HOST_DEVICE_STATIC__ __hip_bfloat16
operator+(
const __hip_bfloat16& l) {
return l; }
841__BF16_HOST_DEVICE_STATIC__ __hip_bfloat16
operator+(
const __hip_bfloat16& l,
842 const __hip_bfloat16& r) {
850__BF16_HOST_DEVICE_STATIC__ __hip_bfloat16
operator-(
const __hip_bfloat16& l) {
return __hneg(l); }
856__BF16_HOST_DEVICE_STATIC__ __hip_bfloat16
operator-(
const __hip_bfloat16& l,
857 const __hip_bfloat16& r) {
865__BF16_HOST_DEVICE_STATIC__ __hip_bfloat16
operator++(__hip_bfloat16& l,
const int) {
867 l =
__hadd(l, HIPRT_ONE_BF16);
875__BF16_HOST_DEVICE_STATIC__ __hip_bfloat16&
operator++(__hip_bfloat16& l) {
876 l =
__hadd(l, HIPRT_ONE_BF16);
884__BF16_HOST_DEVICE_STATIC__ __hip_bfloat16
operator--(__hip_bfloat16& l,
const int) {
886 l =
__hsub(l, HIPRT_ONE_BF16);
894__BF16_HOST_DEVICE_STATIC__ __hip_bfloat16&
operator--(__hip_bfloat16& l) {
895 l =
__hsub(l, HIPRT_ONE_BF16);
903__BF16_HOST_DEVICE_STATIC__ __hip_bfloat16&
operator+=(__hip_bfloat16& l,
const __hip_bfloat16& r) {
912__BF16_HOST_DEVICE_STATIC__ __hip_bfloat16&
operator-=(__hip_bfloat16& l,
const __hip_bfloat16& r) {
921__BF16_HOST_DEVICE_STATIC__ __hip_bfloat16
operator/(
const __hip_bfloat16& l,
922 const __hip_bfloat16& r) {
930__BF16_HOST_DEVICE_STATIC__ __hip_bfloat16&
operator/=(__hip_bfloat16& l,
const __hip_bfloat16& r) {
939__BF16_HOST_DEVICE_STATIC__ __hip_bfloat162
operator*(
const __hip_bfloat162& l,
940 const __hip_bfloat162& r) {
948__BF16_HOST_DEVICE_STATIC__ __hip_bfloat162&
operator*=(__hip_bfloat162& l,
949 const __hip_bfloat162& r) {
958__BF16_HOST_DEVICE_STATIC__ __hip_bfloat162
operator+(
const __hip_bfloat162& l) {
return l; }
964__BF16_HOST_DEVICE_STATIC__ __hip_bfloat162
operator+(
const __hip_bfloat162& l,
965 const __hip_bfloat162& r) {
973__BF16_HOST_DEVICE_STATIC__ __hip_bfloat162
operator-(
const __hip_bfloat162& l) {
981__BF16_HOST_DEVICE_STATIC__ __hip_bfloat162
operator-(
const __hip_bfloat162& l,
982 const __hip_bfloat162& r) {
990__BF16_HOST_DEVICE_STATIC__ __hip_bfloat162
operator++(__hip_bfloat162& l,
const int) {
992 l =
__hadd2(l, {HIPRT_ONE_BF16, HIPRT_ONE_BF16});
1000__BF16_HOST_DEVICE_STATIC__ __hip_bfloat162&
operator++(__hip_bfloat162& l) {
1001 l =
__hadd2(l, {HIPRT_ONE_BF16, HIPRT_ONE_BF16});
1009__BF16_HOST_DEVICE_STATIC__ __hip_bfloat162
operator--(__hip_bfloat162& l,
const int) {
1011 l =
__hsub2(l, {HIPRT_ONE_BF16, HIPRT_ONE_BF16});
1019__BF16_HOST_DEVICE_STATIC__ __hip_bfloat162&
operator--(__hip_bfloat162& l) {
1020 l =
__hsub2(l, {HIPRT_ONE_BF16, HIPRT_ONE_BF16});
1028__BF16_HOST_DEVICE_STATIC__ __hip_bfloat162&
operator+=(__hip_bfloat162& l,
1029 const __hip_bfloat162& r) {
1038__BF16_HOST_DEVICE_STATIC__ __hip_bfloat162&
operator-=(__hip_bfloat162& l,
1039 const __hip_bfloat162& r) {
1048__BF16_HOST_DEVICE_STATIC__ __hip_bfloat162
operator/(
const __hip_bfloat162& l,
1049 const __hip_bfloat162& r) {
1057__BF16_HOST_DEVICE_STATIC__ __hip_bfloat162&
operator/=(__hip_bfloat162& l,
1058 const __hip_bfloat162& r) {
1067__BF16_HOST_DEVICE_STATIC__
bool __heq(
const __hip_bfloat16 a,
const __hip_bfloat16 b) {
1075__BF16_HOST_DEVICE_STATIC__
bool __hequ(
const __hip_bfloat16 a,
const __hip_bfloat16 b) {
1084__BF16_HOST_DEVICE_STATIC__
bool __hgt(
const __hip_bfloat16 a,
const __hip_bfloat16 b) {
1092__BF16_HOST_DEVICE_STATIC__
bool __hgtu(
const __hip_bfloat16 a,
const __hip_bfloat16 b) {
1100__BF16_HOST_DEVICE_STATIC__
bool __hge(
const __hip_bfloat16 a,
const __hip_bfloat16 b) {
1108__BF16_HOST_DEVICE_STATIC__
bool __hgeu(
const __hip_bfloat16 a,
const __hip_bfloat16 b) {
1116__BF16_HOST_DEVICE_STATIC__
bool __hne(
const __hip_bfloat16 a,
const __hip_bfloat16 b) {
1124__BF16_HOST_DEVICE_STATIC__
bool __hneu(
const __hip_bfloat16 a,
const __hip_bfloat16 b) {
1132__BF16_HOST_DEVICE_STATIC__ __hip_bfloat16
__hmax(
const __hip_bfloat16 a,
const __hip_bfloat16 b) {
1133#if __HIP_DEVICE_COMPILE__
1144__BF16_HOST_DEVICE_STATIC__ __hip_bfloat16
__hmin(
const __hip_bfloat16 a,
const __hip_bfloat16 b) {
1145#if __HIP_DEVICE_COMPILE__
1156__BF16_HOST_DEVICE_STATIC__
bool __hlt(
const __hip_bfloat16 a,
const __hip_bfloat16 b) {
1164__BF16_HOST_DEVICE_STATIC__
bool __hltu(
const __hip_bfloat16 a,
const __hip_bfloat16 b) {
1172__BF16_HOST_DEVICE_STATIC__
bool __hle(
const __hip_bfloat16 a,
const __hip_bfloat16 b) {
1180__BF16_HOST_DEVICE_STATIC__
bool __hleu(
const __hip_bfloat16 a,
const __hip_bfloat16 b) {
1188__BF16_HOST_DEVICE_STATIC__
int __hisinf(
const __hip_bfloat16 a) {
1189 __hip_bfloat16_raw hr = a;
1190 return !(~hr.x & 0x7f80) && !(hr.x & 0x7f);
1197__BF16_HOST_DEVICE_STATIC__
bool __hisnan(
const __hip_bfloat16 a) {
1198 __hip_bfloat16_raw hr = a;
1199 return !(~hr.x & 0x7f80) && +(hr.x & 0x7f);
1206__BF16_HOST_DEVICE_STATIC__
bool __hbeq2(
const __hip_bfloat162 a,
const __hip_bfloat162 b) {
1207 __hip_bfloat162_raw hr_a = a;
1208 __hip_bfloat162_raw hr_b = b;
1209 return __heq(__hip_bfloat16_raw{hr_a.x}, __hip_bfloat16_raw{hr_b.x}) &&
1210 __heq(__hip_bfloat16_raw{hr_a.y}, __hip_bfloat16_raw{hr_b.y});
1217__BF16_HOST_DEVICE_STATIC__
bool __hbequ2(
const __hip_bfloat162 a,
const __hip_bfloat162 b) {
1218 __hip_bfloat162_raw hr_a = a;
1219 __hip_bfloat162_raw hr_b = b;
1220 return __hequ(__hip_bfloat16_raw{hr_a.x}, __hip_bfloat16_raw{hr_b.x}) &&
1221 __hequ(__hip_bfloat16_raw{hr_a.y}, __hip_bfloat16_raw{hr_b.y});
1228__BF16_HOST_DEVICE_STATIC__
bool __hbge2(
const __hip_bfloat162 a,
const __hip_bfloat162 b) {
1229 __hip_bfloat162_raw hr_a = a;
1230 __hip_bfloat162_raw hr_b = b;
1231 return __hge(__hip_bfloat16_raw{hr_a.x}, __hip_bfloat16_raw{hr_b.x}) &&
1232 __hge(__hip_bfloat16_raw{hr_a.y}, __hip_bfloat16_raw{hr_b.y});
1239__BF16_HOST_DEVICE_STATIC__
bool __hbgeu2(
const __hip_bfloat162 a,
const __hip_bfloat162 b) {
1240 __hip_bfloat162_raw hr_a = a;
1241 __hip_bfloat162_raw hr_b = b;
1242 return __hgeu(__hip_bfloat16_raw{hr_a.x}, __hip_bfloat16_raw{hr_b.x}) &&
1243 __hgeu(__hip_bfloat16_raw{hr_a.y}, __hip_bfloat16_raw{hr_b.y});
1250__BF16_HOST_DEVICE_STATIC__
bool __hbgt2(
const __hip_bfloat162 a,
const __hip_bfloat162 b) {
1251 __hip_bfloat162_raw hr_a = a;
1252 __hip_bfloat162_raw hr_b = b;
1253 return __hgt(__hip_bfloat16_raw{hr_a.x}, __hip_bfloat16_raw{hr_b.x}) &&
1254 __hgt(__hip_bfloat16_raw{hr_a.y}, __hip_bfloat16_raw{hr_b.y});
1261__BF16_HOST_DEVICE_STATIC__
bool __hbgtu2(
const __hip_bfloat162 a,
const __hip_bfloat162 b) {
1262 __hip_bfloat162_raw hr_a = a;
1263 __hip_bfloat162_raw hr_b = b;
1264 return __hgtu(__hip_bfloat16_raw{hr_a.x}, __hip_bfloat16_raw{hr_b.x}) &&
1265 __hgtu(__hip_bfloat16_raw{hr_a.y}, __hip_bfloat16_raw{hr_b.y});
1272__BF16_HOST_DEVICE_STATIC__
bool __hble2(
const __hip_bfloat162 a,
const __hip_bfloat162 b) {
1273 __hip_bfloat162_raw hr_a = a;
1274 __hip_bfloat162_raw hr_b = b;
1275 return __hle(__hip_bfloat16_raw{hr_a.x}, __hip_bfloat16_raw{hr_b.x}) &&
1276 __hle(__hip_bfloat16_raw{hr_a.y}, __hip_bfloat16_raw{hr_b.y});
1283__BF16_HOST_DEVICE_STATIC__
bool __hbleu2(
const __hip_bfloat162 a,
const __hip_bfloat162 b) {
1284 __hip_bfloat162_raw hr_a = a;
1285 __hip_bfloat162_raw hr_b = b;
1286 return __hleu(__hip_bfloat16_raw{hr_a.x}, __hip_bfloat16_raw{hr_b.x}) &&
1287 __hleu(__hip_bfloat16_raw{hr_a.y}, __hip_bfloat16_raw{hr_b.y});
1294__BF16_HOST_DEVICE_STATIC__
bool __hblt2(
const __hip_bfloat162 a,
const __hip_bfloat162 b) {
1295 __hip_bfloat162_raw hr_a = a;
1296 __hip_bfloat162_raw hr_b = b;
1297 return __hlt(__hip_bfloat16_raw{hr_a.x}, __hip_bfloat16_raw{hr_b.x}) &&
1298 __hlt(__hip_bfloat16_raw{hr_a.y}, __hip_bfloat16_raw{hr_b.y});
1305__BF16_HOST_DEVICE_STATIC__
bool __hbltu2(
const __hip_bfloat162 a,
const __hip_bfloat162 b) {
1306 __hip_bfloat162_raw hr_a = a;
1307 __hip_bfloat162_raw hr_b = b;
1308 return __hltu(__hip_bfloat16_raw{hr_a.x}, __hip_bfloat16_raw{hr_b.x}) &&
1309 __hltu(__hip_bfloat16_raw{hr_a.y}, __hip_bfloat16_raw{hr_b.y});
1316__BF16_HOST_DEVICE_STATIC__
bool __hbne2(
const __hip_bfloat162 a,
const __hip_bfloat162 b) {
1317 __hip_bfloat162_raw hr_a = a;
1318 __hip_bfloat162_raw hr_b = b;
1319 return __hne(__hip_bfloat16(__hip_bfloat16_raw{hr_a.x}),
1320 __hip_bfloat16(__hip_bfloat16_raw{hr_b.x})) &&
1321 __hne(__hip_bfloat16(__hip_bfloat16_raw{hr_a.y}), __hip_bfloat16(__hip_bfloat16_raw{hr_b.y}));
1328__BF16_HOST_DEVICE_STATIC__
bool __hbneu2(
const __hip_bfloat162 a,
const __hip_bfloat162 b) {
1329 __hip_bfloat162_raw hr_a = a;
1330 __hip_bfloat162_raw hr_b = b;
1331 return __hneu(__hip_bfloat16_raw{hr_a.x}, __hip_bfloat16_raw{hr_b.x}) ||
1332 __hneu(__hip_bfloat16_raw{hr_a.y}, __hip_bfloat16_raw{hr_b.y});
1339__BF16_HOST_DEVICE_STATIC__ __hip_bfloat162
__heq2(
const __hip_bfloat162 a,
1340 const __hip_bfloat162 b) {
1341 __hip_bfloat162_raw hr_a = a;
1342 __hip_bfloat162_raw hr_b = b;
1343 return __hip_bfloat162{
1344 {
__heq(__hip_bfloat16_raw{hr_a.x}, __hip_bfloat16_raw{hr_b.x}) ? HIPRT_ONE_BF16
1346 {
__heq(__hip_bfloat16_raw{hr_a.y}, __hip_bfloat16_raw{hr_b.y}) ? HIPRT_ONE_BF16
1347 : HIPRT_ZERO_BF16}};
1354__BF16_HOST_DEVICE_STATIC__ __hip_bfloat162
__hge2(
const __hip_bfloat162 a,
1355 const __hip_bfloat162 b) {
1356 __hip_bfloat162_raw hr_a = a;
1357 __hip_bfloat162_raw hr_b = b;
1358 return __hip_bfloat162{
1359 {
__hge(__hip_bfloat16_raw{hr_a.x}, __hip_bfloat16_raw{hr_b.x}) ? HIPRT_ONE_BF16
1361 {
__hge(__hip_bfloat16_raw{hr_a.y}, __hip_bfloat16_raw{hr_b.y}) ? HIPRT_ONE_BF16
1362 : HIPRT_ZERO_BF16}};
1369__BF16_HOST_DEVICE_STATIC__ __hip_bfloat162
__hgt2(
const __hip_bfloat162 a,
1370 const __hip_bfloat162 b) {
1371 __hip_bfloat162_raw hr_a = a;
1372 __hip_bfloat162_raw hr_b = b;
1373 return __hip_bfloat162{
1374 {
__hgt(__hip_bfloat16_raw{hr_a.x}, __hip_bfloat16_raw{hr_b.x}) ? HIPRT_ONE_BF16
1376 {
__hgt(__hip_bfloat16_raw{hr_a.y}, __hip_bfloat16_raw{hr_b.y}) ? HIPRT_ONE_BF16
1384__BF16_HOST_DEVICE_STATIC__ __hip_bfloat162
__hisnan2(
const __hip_bfloat162 a) {
1385 __hip_bfloat162_raw hr_a = a;
1386 return __hip_bfloat162{{
__hisnan(__hip_bfloat16_raw{hr_a.x}) ? HIPRT_ONE_BF16 : HIPRT_ZERO_BF16},
1387 {
__hisnan(__hip_bfloat16_raw{hr_a.y}) ? HIPRT_ONE_BF16 : HIPRT_ONE_BF16}};
1394__BF16_HOST_DEVICE_STATIC__ __hip_bfloat162
__hle2(
const __hip_bfloat162 a,
1395 const __hip_bfloat162 b) {
1396 __hip_bfloat162_raw hr_a = a;
1397 __hip_bfloat162_raw hr_b = b;
1398 return __hip_bfloat162{
1399 {
__hle(__hip_bfloat16_raw{hr_a.x}, __hip_bfloat16_raw{hr_b.x}) ? HIPRT_ONE_BF16
1401 {
__hle(__hip_bfloat16_raw{hr_a.y}, __hip_bfloat16_raw{hr_b.y}) ? HIPRT_ONE_BF16
1402 : HIPRT_ZERO_BF16}};
1409__BF16_HOST_DEVICE_STATIC__ __hip_bfloat162
__hlt2(
const __hip_bfloat162 a,
1410 const __hip_bfloat162 b) {
1411 __hip_bfloat162_raw hr_a = a;
1412 __hip_bfloat162_raw hr_b = b;
1413 return __hip_bfloat162{
1414 {
__hlt(__hip_bfloat16_raw{hr_a.x}, __hip_bfloat16_raw{hr_b.x}) ? HIPRT_ONE_BF16
1416 {
__hlt(__hip_bfloat16_raw{hr_a.y}, __hip_bfloat16_raw{hr_b.y}) ? HIPRT_ONE_BF16
1417 : HIPRT_ZERO_BF16}};
1424__BF16_HOST_DEVICE_STATIC__ __hip_bfloat162
__hmax2(
const __hip_bfloat162 a,
1425 const __hip_bfloat162 b) {
1426 __hip_bfloat162_raw hr_a = a;
1427 __hip_bfloat162_raw hr_b = b;
1428 return __hip_bfloat162(
__hmax(__hip_bfloat16_raw{hr_a.x}, __hip_bfloat16_raw{hr_b.x}),
1429 __hmax(__hip_bfloat16_raw{hr_a.y}, __hip_bfloat16_raw{hr_b.y}));
1436__BF16_HOST_DEVICE_STATIC__ __hip_bfloat162
__hmin2(
const __hip_bfloat162 a,
1437 const __hip_bfloat162 b) {
1438 __hip_bfloat162_raw hr_a = a;
1439 __hip_bfloat162_raw hr_b = b;
1440 return __hip_bfloat162(
__hmin(__hip_bfloat16_raw{hr_a.x}, __hip_bfloat16_raw{hr_b.x}),
1441 __hmin(__hip_bfloat16_raw{hr_a.y}, __hip_bfloat16_raw{hr_b.y}));
1448__BF16_HOST_DEVICE_STATIC__ __hip_bfloat162
__hne2(
const __hip_bfloat162 a,
1449 const __hip_bfloat162 b) {
1450 __hip_bfloat162_raw hr_a = a;
1451 __hip_bfloat162_raw hr_b = b;
1452 return __hip_bfloat162{
1453 {
__hne(__hip_bfloat16_raw{hr_a.x}, __hip_bfloat16_raw{hr_b.x}) ? HIPRT_ONE_BF16
1455 {
__hne(__hip_bfloat16_raw{hr_a.y}, __hip_bfloat16_raw{hr_b.y}) ? HIPRT_ONE_BF16
1456 : HIPRT_ZERO_BF16}};
1463__BF16_HOST_DEVICE_STATIC__
bool operator==(
const __hip_bfloat16& l,
const __hip_bfloat16& r) {
1471__BF16_HOST_DEVICE_STATIC__
bool operator!=(
const __hip_bfloat16& l,
const __hip_bfloat16& r) {
1479__BF16_HOST_DEVICE_STATIC__
bool operator<(
const __hip_bfloat16& l,
const __hip_bfloat16& r) {
1487__BF16_HOST_DEVICE_STATIC__
bool operator<=(
const __hip_bfloat16& l,
const __hip_bfloat16& r) {
1495__BF16_HOST_DEVICE_STATIC__
bool operator>(
const __hip_bfloat16& l,
const __hip_bfloat16& r) {
1503__BF16_HOST_DEVICE_STATIC__
bool operator>=(
const __hip_bfloat16& l,
const __hip_bfloat16& r) {
1511__BF16_HOST_DEVICE_STATIC__
bool operator==(
const __hip_bfloat162& l,
const __hip_bfloat162& r) {
1513 return ret.x != 0.0f && ret.y != 0.0f;
1520__BF16_HOST_DEVICE_STATIC__
bool operator!=(
const __hip_bfloat162& l,
const __hip_bfloat162& r) {
1528__BF16_HOST_DEVICE_STATIC__
bool operator<(
const __hip_bfloat162& l,
const __hip_bfloat162& r) {
1530 return fl.x < fr.x && fl.x < fr.y;
1537__BF16_HOST_DEVICE_STATIC__
bool operator<=(
const __hip_bfloat162& l,
const __hip_bfloat162& r) {
1539 return fl.x <= fr.x && fl.x <= fr.y;
1546__BF16_HOST_DEVICE_STATIC__
bool operator>(
const __hip_bfloat162& l,
const __hip_bfloat162& r) {
1548 return fl.x > fr.x && fl.x > fr.y;
1555__BF16_HOST_DEVICE_STATIC__
bool operator>=(
const __hip_bfloat162& l,
const __hip_bfloat162& r) {
1557 return fl.x >= fr.x && fl.x >= fr.y;
1564__BF16_DEVICE_STATIC__ __hip_bfloat16
hceil(
const __hip_bfloat16 h) {
1572__BF16_DEVICE_STATIC__ __hip_bfloat16
hcos(
const __hip_bfloat16 h) {
1580__BF16_DEVICE_STATIC__ __hip_bfloat16
hexp(
const __hip_bfloat16 h) {
1588__BF16_DEVICE_STATIC__ __hip_bfloat16
hexp10(
const __hip_bfloat16 h) {
1596__BF16_DEVICE_STATIC__ __hip_bfloat16
hexp2(
const __hip_bfloat16 h) {
1604__BF16_DEVICE_STATIC__ __hip_bfloat16
hfloor(
const __hip_bfloat16 h) {
1612__BF16_DEVICE_STATIC__ __hip_bfloat16
hlog(
const __hip_bfloat16 h) {
1620__BF16_DEVICE_STATIC__ __hip_bfloat16
hlog10(
const __hip_bfloat16 h) {
1628__BF16_DEVICE_STATIC__ __hip_bfloat16
hlog2(
const __hip_bfloat16 h) {
1636__BF16_DEVICE_STATIC__ __hip_bfloat16
hrcp(
const __hip_bfloat16 h) {
1644__BF16_DEVICE_STATIC__ __hip_bfloat16
hrint(
const __hip_bfloat16 h) {
1652__BF16_DEVICE_STATIC__ __hip_bfloat16
hrsqrt(
const __hip_bfloat16 h) {
1660__BF16_DEVICE_STATIC__ __hip_bfloat16
hsin(
const __hip_bfloat16 h) {
1668__BF16_DEVICE_STATIC__ __hip_bfloat16
hsqrt(
const __hip_bfloat16 h) {
1676__BF16_DEVICE_STATIC__ __hip_bfloat16
htrunc(
const __hip_bfloat16 h) {
1684__BF16_DEVICE_STATIC__ __hip_bfloat162
h2ceil(
const __hip_bfloat162 h) {
1685 __hip_bfloat162_raw hr = h;
1686 return __hip_bfloat162(
hceil(__hip_bfloat16_raw{hr.x}),
hceil(__hip_bfloat16_raw{hr.y}));
1693__BF16_DEVICE_STATIC__ __hip_bfloat162
h2cos(
const __hip_bfloat162 h) {
1694 __hip_bfloat162_raw hr = h;
1695 return __hip_bfloat162(
hcos(__hip_bfloat16_raw{hr.x}),
hcos(__hip_bfloat16_raw{hr.y}));
1702__BF16_DEVICE_STATIC__ __hip_bfloat162
h2exp(
const __hip_bfloat162 h) {
1703 __hip_bfloat162_raw hr = h;
1704 return __hip_bfloat162(
hexp(__hip_bfloat16_raw{hr.x}),
hexp(__hip_bfloat16_raw{hr.y}));
1711__BF16_DEVICE_STATIC__ __hip_bfloat162
h2exp10(
const __hip_bfloat162 h) {
1712 __hip_bfloat162_raw hr = h;
1713 return __hip_bfloat162(
hexp10(__hip_bfloat16_raw{hr.x}),
hexp10(__hip_bfloat16_raw{hr.y}));
1720__BF16_DEVICE_STATIC__ __hip_bfloat162
h2exp2(
const __hip_bfloat162 h) {
1721 __hip_bfloat162_raw hr = h;
1722 return __hip_bfloat162(
hexp2(__hip_bfloat16_raw{hr.x}),
hexp2(__hip_bfloat16_raw{hr.y}));
1729__BF16_DEVICE_STATIC__ __hip_bfloat162
h2floor(
const __hip_bfloat162 h) {
1730 __hip_bfloat162_raw hr = h;
1731 return __hip_bfloat162(
hfloor(__hip_bfloat16_raw{hr.x}),
hfloor(__hip_bfloat16_raw{hr.y}));
1738__BF16_DEVICE_STATIC__ __hip_bfloat162
h2log(
const __hip_bfloat162 h) {
1739 __hip_bfloat162_raw hr = h;
1740 return __hip_bfloat162(
hlog(__hip_bfloat16_raw{hr.x}),
hlog(__hip_bfloat16_raw{hr.y}));
1747__BF16_DEVICE_STATIC__ __hip_bfloat162
h2log10(
const __hip_bfloat162 h) {
1748 __hip_bfloat162_raw hr = h;
1749 return __hip_bfloat162(
hlog10(__hip_bfloat16_raw{hr.x}),
hlog10(__hip_bfloat16_raw{hr.y}));
1756__BF16_DEVICE_STATIC__ __hip_bfloat162
h2log2(
const __hip_bfloat162 h) {
1757 __hip_bfloat162_raw hr = h;
1758 return __hip_bfloat162(
hlog2(__hip_bfloat16_raw{hr.x}),
hlog2(__hip_bfloat16_raw{hr.y}));
1765__BF16_DEVICE_STATIC__ __hip_bfloat162
h2rcp(
const __hip_bfloat162 h) {
1766 __hip_bfloat162_raw hr = h;
1767 return __hip_bfloat162(
hrcp(__hip_bfloat16_raw{hr.x}),
hrcp(__hip_bfloat16_raw{hr.y}));
1774__BF16_DEVICE_STATIC__ __hip_bfloat162
h2rint(
const __hip_bfloat162 h) {
1775 __hip_bfloat162_raw hr = h;
1776 return __hip_bfloat162(
hrint(__hip_bfloat16_raw{hr.x}),
hrint(__hip_bfloat16_raw{hr.y}));
1783__BF16_DEVICE_STATIC__ __hip_bfloat162
h2rsqrt(
const __hip_bfloat162 h) {
1784 __hip_bfloat162_raw hr = h;
1785 return __hip_bfloat162(
hrsqrt(__hip_bfloat16_raw{hr.x}),
hrsqrt(__hip_bfloat16_raw{hr.y}));
1792__BF16_DEVICE_STATIC__ __hip_bfloat162
h2sin(
const __hip_bfloat162 h) {
1793 __hip_bfloat162_raw hr = h;
1794 return __hip_bfloat162(
hsin(__hip_bfloat16_raw{hr.x}),
hsin(__hip_bfloat16_raw{hr.y}));
1801__BF16_DEVICE_STATIC__ __hip_bfloat162
h2sqrt(
const __hip_bfloat162 h) {
1802 __hip_bfloat162_raw hr = h;
1803 return __hip_bfloat162(
hsqrt(__hip_bfloat16_raw{hr.x}),
hsqrt(__hip_bfloat16_raw{hr.y}));
1810__BF16_DEVICE_STATIC__ __hip_bfloat162
h2trunc(
const __hip_bfloat162 h) {
1811 __hip_bfloat162_raw hr = h;
1812 return __hip_bfloat162(
htrunc(__hip_bfloat16_raw{hr.x}),
htrunc(__hip_bfloat16_raw{hr.y}));
Contains declarations for types and functions in device library. Uses int64_t and uint64_t instead of...
__BF16_HOST_DEVICE_STATIC__ __hip_bfloat16 __hsub(const __hip_bfloat16 a, const __hip_bfloat16 b)
Subtracts two bfloat16 values.
Definition amd_hip_bf16.h:681
__BF16_HOST_DEVICE_STATIC__ __hip_bfloat16 & operator-=(__hip_bfloat16 &l, const __hip_bfloat16 &r)
Operator to subtract-assign two __hip_bfloat16 numbers.
Definition amd_hip_bf16.h:912
__BF16_HOST_DEVICE_STATIC__ __hip_bfloat16 operator+(const __hip_bfloat16 &l)
Operator to unary+ on a __hip_bfloat16 number.
Definition amd_hip_bf16.h:835
__BF16_HOST_DEVICE_STATIC__ __hip_bfloat16 operator/(const __hip_bfloat16 &l, const __hip_bfloat16 &r)
Operator to divide two __hip_bfloat16 numbers.
Definition amd_hip_bf16.h:921
__BF16_HOST_DEVICE_STATIC__ __hip_bfloat16 operator-(const __hip_bfloat16 &l)
Operator to negate a __hip_bfloat16 number.
Definition amd_hip_bf16.h:850
__BF16_HOST_DEVICE_STATIC__ __hip_bfloat16 __hneg(const __hip_bfloat16 a)
Negate a bfloat16 value.
Definition amd_hip_bf16.h:715
__BF16_HOST_DEVICE_STATIC__ __hip_bfloat16 __hadd(const __hip_bfloat16 a, const __hip_bfloat16 b)
Adds two bfloat16 values.
Definition amd_hip_bf16.h:673
__BF16_HOST_DEVICE_STATIC__ __hip_bfloat16 & operator/=(__hip_bfloat16 &l, const __hip_bfloat16 &r)
Operator to divide-assign two __hip_bfloat16 numbers.
Definition amd_hip_bf16.h:930
__BF16_HOST_DEVICE_STATIC__ __hip_bfloat16 operator*(const __hip_bfloat16 &l, const __hip_bfloat16 &r)
Operator to multiply two __hip_bfloat16 numbers.
Definition amd_hip_bf16.h:817
__BF16_DEVICE_STATIC__ __hip_bfloat16 __hfma(const __hip_bfloat16 a, const __hip_bfloat16 b, const __hip_bfloat16 c)
Performs FMA of given bfloat16 values.
Definition amd_hip_bf16.h:697
__BF16_HOST_DEVICE_STATIC__ __hip_bfloat16 & operator*=(__hip_bfloat16 &l, const __hip_bfloat16 &r)
Operator to multiply-assign two __hip_bfloat16 numbers.
Definition amd_hip_bf16.h:826
__BF16_HOST_DEVICE_STATIC__ __hip_bfloat16 __hmul(const __hip_bfloat16 a, const __hip_bfloat16 b)
Multiplies two bfloat16 values.
Definition amd_hip_bf16.h:707
__BF16_HOST_DEVICE_STATIC__ __hip_bfloat16 operator++(__hip_bfloat16 &l, const int)
Operator to post increment a __hip_bfloat16 number.
Definition amd_hip_bf16.h:865
__BF16_HOST_DEVICE_STATIC__ __hip_bfloat16 & operator+=(__hip_bfloat16 &l, const __hip_bfloat16 &r)
Operator to add-assign two __hip_bfloat16 numbers.
Definition amd_hip_bf16.h:903
__BF16_HOST_DEVICE_STATIC__ __hip_bfloat16 __habs(const __hip_bfloat16 a)
Returns absolute of a bfloat16.
Definition amd_hip_bf16.h:725
__BF16_HOST_DEVICE_STATIC__ __hip_bfloat16 operator--(__hip_bfloat16 &l, const int)
Operator to post decrement a __hip_bfloat16 number.
Definition amd_hip_bf16.h:884
__BF16_HOST_DEVICE_STATIC__ __hip_bfloat16 __hdiv(const __hip_bfloat16 a, const __hip_bfloat16 b)
Divides two bfloat16 values.
Definition amd_hip_bf16.h:689
__BF16_HOST_DEVICE_STATIC__ bool __heq(const __hip_bfloat16 a, const __hip_bfloat16 b)
Compare two bfloat162 values.
Definition amd_hip_bf16.h:1067
__BF16_HOST_DEVICE_STATIC__ bool __hgt(const __hip_bfloat16 a, const __hip_bfloat16 b)
Compare two bfloat162 values - greater than.
Definition amd_hip_bf16.h:1084
__BF16_HOST_DEVICE_STATIC__ bool __hne(const __hip_bfloat16 a, const __hip_bfloat16 b)
Compare two bfloat162 values - not equal.
Definition amd_hip_bf16.h:1116
__BF16_HOST_DEVICE_STATIC__ bool operator==(const __hip_bfloat16 &l, const __hip_bfloat16 &r)
Operator to perform an equal compare on two __hip_bfloat16 numbers.
Definition amd_hip_bf16.h:1463
__BF16_HOST_DEVICE_STATIC__ bool __hle(const __hip_bfloat16 a, const __hip_bfloat16 b)
Compare two bfloat162 values - less than equal.
Definition amd_hip_bf16.h:1172
__BF16_HOST_DEVICE_STATIC__ bool operator!=(const __hip_bfloat16 &l, const __hip_bfloat16 &r)
Operator to perform a not equal on two __hip_bfloat16 numbers.
Definition amd_hip_bf16.h:1471
__BF16_HOST_DEVICE_STATIC__ bool operator>(const __hip_bfloat16 &l, const __hip_bfloat16 &r)
Operator to perform a greater than on two __hip_bfloat16 numbers.
Definition amd_hip_bf16.h:1495
__BF16_HOST_DEVICE_STATIC__ __hip_bfloat16 __hmin(const __hip_bfloat16 a, const __hip_bfloat16 b)
Compare two bfloat162 values - return min.
Definition amd_hip_bf16.h:1144
__BF16_HOST_DEVICE_STATIC__ bool __hge(const __hip_bfloat16 a, const __hip_bfloat16 b)
Compare two bfloat162 values - greater than equal.
Definition amd_hip_bf16.h:1100
__BF16_HOST_DEVICE_STATIC__ bool __hleu(const __hip_bfloat16 a, const __hip_bfloat16 b)
Compare two bfloat162 values - unordered less than equal.
Definition amd_hip_bf16.h:1180
__BF16_HOST_DEVICE_STATIC__ __hip_bfloat16 __hmax(const __hip_bfloat16 a, const __hip_bfloat16 b)
Compare two bfloat162 values - return max.
Definition amd_hip_bf16.h:1132
__BF16_HOST_DEVICE_STATIC__ bool operator<=(const __hip_bfloat16 &l, const __hip_bfloat16 &r)
Operator to perform a less than equal on two __hip_bfloat16 numbers.
Definition amd_hip_bf16.h:1487
__BF16_HOST_DEVICE_STATIC__ int __hisinf(const __hip_bfloat16 a)
Checks if number is inf.
Definition amd_hip_bf16.h:1188
__BF16_HOST_DEVICE_STATIC__ bool __hneu(const __hip_bfloat16 a, const __hip_bfloat16 b)
Compare two bfloat162 values - unordered not equal.
Definition amd_hip_bf16.h:1124
__BF16_HOST_DEVICE_STATIC__ bool __hgtu(const __hip_bfloat16 a, const __hip_bfloat16 b)
Compare two bfloat162 values - unordered greater than.
Definition amd_hip_bf16.h:1092
__BF16_HOST_DEVICE_STATIC__ bool operator<(const __hip_bfloat16 &l, const __hip_bfloat16 &r)
Operator to perform a less than on two __hip_bfloat16 numbers.
Definition amd_hip_bf16.h:1479
__BF16_HOST_DEVICE_STATIC__ bool __hltu(const __hip_bfloat16 a, const __hip_bfloat16 b)
Compare two bfloat162 values - unordered less than.
Definition amd_hip_bf16.h:1164
__BF16_HOST_DEVICE_STATIC__ bool __hgeu(const __hip_bfloat16 a, const __hip_bfloat16 b)
Compare two bfloat162 values - unordered greater than equal.
Definition amd_hip_bf16.h:1108
__BF16_HOST_DEVICE_STATIC__ bool __hlt(const __hip_bfloat16 a, const __hip_bfloat16 b)
Compare two bfloat162 values - less than operator.
Definition amd_hip_bf16.h:1156
__BF16_HOST_DEVICE_STATIC__ bool operator>=(const __hip_bfloat16 &l, const __hip_bfloat16 &r)
Operator to perform a greater than equal on two __hip_bfloat16 numbers.
Definition amd_hip_bf16.h:1503
__BF16_HOST_DEVICE_STATIC__ bool __hisnan(const __hip_bfloat16 a)
Checks if number is nan.
Definition amd_hip_bf16.h:1197
__BF16_HOST_DEVICE_STATIC__ bool __hequ(const __hip_bfloat16 a, const __hip_bfloat16 b)
Compare two bfloat162 values - unordered equal.
Definition amd_hip_bf16.h:1075
__BF16_HOST_DEVICE_STATIC__ bool __hbgeu2(const __hip_bfloat162 a, const __hip_bfloat162 b)
Check for a >= b - unordered.
Definition amd_hip_bf16.h:1239
__BF16_HOST_DEVICE_STATIC__ bool __hbgt2(const __hip_bfloat162 a, const __hip_bfloat162 b)
Check for a > b.
Definition amd_hip_bf16.h:1250
__BF16_HOST_DEVICE_STATIC__ __hip_bfloat162 __hmax2(const __hip_bfloat162 a, const __hip_bfloat162 b)
Returns max of two elements.
Definition amd_hip_bf16.h:1424
__BF16_HOST_DEVICE_STATIC__ bool __hble2(const __hip_bfloat162 a, const __hip_bfloat162 b)
Check for a <= b.
Definition amd_hip_bf16.h:1272
__BF16_HOST_DEVICE_STATIC__ bool __hblt2(const __hip_bfloat162 a, const __hip_bfloat162 b)
Check for a < b.
Definition amd_hip_bf16.h:1294
__BF16_HOST_DEVICE_STATIC__ __hip_bfloat162 __hmin2(const __hip_bfloat162 a, const __hip_bfloat162 b)
Returns min of two elements.
Definition amd_hip_bf16.h:1436
__BF16_HOST_DEVICE_STATIC__ bool __hbleu2(const __hip_bfloat162 a, const __hip_bfloat162 b)
Check for a <= b - unordered.
Definition amd_hip_bf16.h:1283
__BF16_HOST_DEVICE_STATIC__ __hip_bfloat162 __hne2(const __hip_bfloat162 a, const __hip_bfloat162 b)
Checks for not equal to.
Definition amd_hip_bf16.h:1448
__BF16_HOST_DEVICE_STATIC__ __hip_bfloat162 __hge2(const __hip_bfloat162 a, const __hip_bfloat162 b)
Check for a >= b, returns 1.0 if greater than equal, otherwise 0.0.
Definition amd_hip_bf16.h:1354
__BF16_HOST_DEVICE_STATIC__ bool __hbne2(const __hip_bfloat162 a, const __hip_bfloat162 b)
Check for a != b.
Definition amd_hip_bf16.h:1316
__BF16_HOST_DEVICE_STATIC__ __hip_bfloat162 __hlt2(const __hip_bfloat162 a, const __hip_bfloat162 b)
Check for a < b, returns 1.0 if greater than equal, otherwise 0.0.
Definition amd_hip_bf16.h:1409
__BF16_HOST_DEVICE_STATIC__ bool __hbltu2(const __hip_bfloat162 a, const __hip_bfloat162 b)
Check for a < b - unordered.
Definition amd_hip_bf16.h:1305
__BF16_HOST_DEVICE_STATIC__ bool __hbequ2(const __hip_bfloat162 a, const __hip_bfloat162 b)
Checks if two numbers are equal - unordered.
Definition amd_hip_bf16.h:1217
__BF16_HOST_DEVICE_STATIC__ bool __hbeq2(const __hip_bfloat162 a, const __hip_bfloat162 b)
Checks if two numbers are equal.
Definition amd_hip_bf16.h:1206
__BF16_HOST_DEVICE_STATIC__ __hip_bfloat162 __hle2(const __hip_bfloat162 a, const __hip_bfloat162 b)
Check for a <= b, returns 1.0 if greater than equal, otherwise 0.0.
Definition amd_hip_bf16.h:1394
__BF16_HOST_DEVICE_STATIC__ bool __hbneu2(const __hip_bfloat162 a, const __hip_bfloat162 b)
Check for a != b.
Definition amd_hip_bf16.h:1328
__BF16_HOST_DEVICE_STATIC__ bool __hbgtu2(const __hip_bfloat162 a, const __hip_bfloat162 b)
Check for a > b - unordered.
Definition amd_hip_bf16.h:1261
__BF16_HOST_DEVICE_STATIC__ bool __hbge2(const __hip_bfloat162 a, const __hip_bfloat162 b)
Check for a >= b.
Definition amd_hip_bf16.h:1228
__BF16_HOST_DEVICE_STATIC__ __hip_bfloat162 __heq2(const __hip_bfloat162 a, const __hip_bfloat162 b)
Check for a != b, returns 1.0 if equal, otherwise 0.0.
Definition amd_hip_bf16.h:1339
__BF16_HOST_DEVICE_STATIC__ __hip_bfloat162 __hgt2(const __hip_bfloat162 a, const __hip_bfloat162 b)
Check for a > b, returns 1.0 if greater than equal, otherwise 0.0.
Definition amd_hip_bf16.h:1369
__BF16_HOST_DEVICE_STATIC__ __hip_bfloat162 __hisnan2(const __hip_bfloat162 a)
Check for a is NaN, returns 1.0 if NaN, otherwise 0.0.
Definition amd_hip_bf16.h:1384
__BF16_HOST_DEVICE_STATIC__ __hip_bfloat162 __habs2(const __hip_bfloat162 a)
Returns absolute of a bfloat162.
Definition amd_hip_bf16.h:749
__BF16_HOST_DEVICE_STATIC__ __hip_bfloat162 __hsub2(const __hip_bfloat162 a, const __hip_bfloat162 b)
Subtracts two bfloat162 values.
Definition amd_hip_bf16.h:805
__BF16_HOST_DEVICE_STATIC__ __hip_bfloat162 __hmul2(const __hip_bfloat162 a, const __hip_bfloat162 b)
Multiplies two bfloat162 values.
Definition amd_hip_bf16.h:784
__BF16_DEVICE_STATIC__ __hip_bfloat162 __hfma2(const __hip_bfloat162 a, const __hip_bfloat162 b, const __hip_bfloat162 c)
Performs FMA of given bfloat162 values.
Definition amd_hip_bf16.h:770
__BF16_HOST_DEVICE_STATIC__ __hip_bfloat162 __hadd2(const __hip_bfloat162 a, const __hip_bfloat162 b)
Adds two bfloat162 values.
Definition amd_hip_bf16.h:758
__BF16_HOST_DEVICE_STATIC__ __hip_bfloat162 __hneg2(const __hip_bfloat162 a)
Converts a bfloat162 into negative.
Definition amd_hip_bf16.h:796
__BF16_HOST_DEVICE_STATIC__ __hip_bfloat162 __h2div(const __hip_bfloat162 a, const __hip_bfloat162 b)
Divides bfloat162 values.
Definition amd_hip_bf16.h:735
__BF16_HOST_DEVICE_STATIC__ float __bfloat162float(__hip_bfloat16 a)
Converts bfloat16 to float.
Definition amd_hip_bf16.h:493
__BF16_HOST_DEVICE_STATIC__ __hip_bfloat16 __float2bfloat16(float f)
Converts float to bfloat16.
Definition amd_hip_bf16.h:502
__BF16_HOST_DEVICE_STATIC__ __hip_bfloat162 __bfloat162bfloat162(const __hip_bfloat16 a)
Moves bfloat16 value to bfloat162.
Definition amd_hip_bf16.h:520
__BF16_HOST_DEVICE_STATIC__ unsigned short int __bfloat16_as_ushort(const __hip_bfloat16 h)
Reinterprets bits in a __hip_bfloat16 as an unsigned signed short integer.
Definition amd_hip_bf16.h:537
__BF16_HOST_DEVICE_STATIC__ __hip_bfloat16 __ushort_as_bfloat16(const unsigned short int a)
Reinterprets unsigned short int into a bfloat16.
Definition amd_hip_bf16.h:665
__BF16_HOST_DEVICE_STATIC__ __hip_bfloat16 __low2bfloat16(const __hip_bfloat162 a)
Returns low 16 bits of __hip_bfloat162.
Definition amd_hip_bf16.h:610
__BF16_HOST_DEVICE_STATIC__ float2 __bfloat1622float2(const __hip_bfloat162 a)
Converts and moves bfloat162 to float2.
Definition amd_hip_bf16.h:511
__BF16_HOST_DEVICE_STATIC__ __hip_bfloat162 __halves2bfloat162(const __hip_bfloat16 a, const __hip_bfloat16 b)
Combine two __hip_bfloat16 to __hip_bfloat162.
Definition amd_hip_bf16.h:563
__BF16_HOST_DEVICE_STATIC__ short int __bfloat16_as_short(const __hip_bfloat16 h)
Reinterprets bits in a __hip_bfloat16 as a signed short integer.
Definition amd_hip_bf16.h:528
__BF16_HOST_DEVICE_STATIC__ __hip_bfloat16 __double2bfloat16(const double a)
Convert double to __hip_bfloat16.
Definition amd_hip_bf16.h:546
__BF16_HOST_DEVICE_STATIC__ float __low2float(const __hip_bfloat162 a)
Converts low 16 bits of __hip_bfloat162 to float and returns the result.
Definition amd_hip_bf16.h:628
__BF16_HOST_DEVICE_STATIC__ float __high2float(const __hip_bfloat162 a)
Converts high 16 bits of __hip_bfloat162 to float and returns the result.
Definition amd_hip_bf16.h:590
__BF16_HOST_DEVICE_STATIC__ __hip_bfloat162 __low2bfloat162(const __hip_bfloat162 a)
Returns low 16 bits of __hip_bfloat162.
Definition amd_hip_bf16.h:619
__BF16_HOST_DEVICE_STATIC__ __hip_bfloat162 __float22bfloat162_rn(const float2 a)
Convert float2 to __hip_bfloat162.
Definition amd_hip_bf16.h:555
__BF16_HOST_DEVICE_STATIC__ __hip_bfloat162 __highs2bfloat162(const __hip_bfloat162 a, const __hip_bfloat162 b)
Extracts high 16 bits from each and combines them.
Definition amd_hip_bf16.h:599
__BF16_HOST_DEVICE_STATIC__ __hip_bfloat162 __lows2bfloat162(const __hip_bfloat162 a, const __hip_bfloat162 b)
Extracts low 16 bits from each and combines them.
Definition amd_hip_bf16.h:646
__BF16_HOST_DEVICE_STATIC__ __hip_bfloat16 __high2bfloat16(const __hip_bfloat162 a)
Returns high 16 bits of __hip_bfloat162.
Definition amd_hip_bf16.h:572
__BF16_HOST_DEVICE_STATIC__ __hip_bfloat162 __high2bfloat162(const __hip_bfloat162 a)
Returns high 16 bits of __hip_bfloat162.
Definition amd_hip_bf16.h:581
__BF16_HOST_DEVICE_STATIC__ __hip_bfloat16 __short_as_bfloat16(const short int a)
Reinterprets short int into a bfloat16.
Definition amd_hip_bf16.h:657
__BF16_HOST_DEVICE_STATIC__ __hip_bfloat162 __lowhigh2highlow(const __hip_bfloat162 a)
Swaps both halves.
Definition amd_hip_bf16.h:637
__BF16_DEVICE_STATIC__ __hip_bfloat16 hexp10(const __hip_bfloat16 h)
Calculate exponential 10 of bfloat16.
Definition amd_hip_bf16.h:1588
__BF16_DEVICE_STATIC__ __hip_bfloat16 hlog(const __hip_bfloat16 h)
Calculate natural log of bfloat16.
Definition amd_hip_bf16.h:1612
__BF16_DEVICE_STATIC__ __hip_bfloat16 hexp2(const __hip_bfloat16 h)
Calculate exponential 2 of bfloat16.
Definition amd_hip_bf16.h:1596
__BF16_DEVICE_STATIC__ __hip_bfloat16 hceil(const __hip_bfloat16 h)
Calculate ceil of bfloat16.
Definition amd_hip_bf16.h:1564
__BF16_DEVICE_STATIC__ __hip_bfloat16 hrcp(const __hip_bfloat16 h)
Calculate reciprocal.
Definition amd_hip_bf16.h:1636
__BF16_DEVICE_STATIC__ __hip_bfloat16 hsqrt(const __hip_bfloat16 h)
Calculate sqrt of bfloat16.
Definition amd_hip_bf16.h:1668
__BF16_DEVICE_STATIC__ __hip_bfloat16 hlog10(const __hip_bfloat16 h)
Calculate log 10 of bfloat16.
Definition amd_hip_bf16.h:1620
__BF16_DEVICE_STATIC__ __hip_bfloat16 hsin(const __hip_bfloat16 h)
Calculate sin of bfloat16.
Definition amd_hip_bf16.h:1660
__BF16_DEVICE_STATIC__ __hip_bfloat16 hfloor(const __hip_bfloat16 h)
Calculate floor of bfloat16.
Definition amd_hip_bf16.h:1604
__BF16_DEVICE_STATIC__ __hip_bfloat16 hrint(const __hip_bfloat16 h)
Round to nearest int.
Definition amd_hip_bf16.h:1644
__BF16_DEVICE_STATIC__ __hip_bfloat16 htrunc(const __hip_bfloat16 h)
Calculate truncate of bfloat16.
Definition amd_hip_bf16.h:1676
__BF16_DEVICE_STATIC__ __hip_bfloat16 hrsqrt(const __hip_bfloat16 h)
Reciprocal square root.
Definition amd_hip_bf16.h:1652
__BF16_DEVICE_STATIC__ __hip_bfloat16 hcos(const __hip_bfloat16 h)
Calculate cosine of bfloat16.
Definition amd_hip_bf16.h:1572
__BF16_DEVICE_STATIC__ __hip_bfloat16 hlog2(const __hip_bfloat16 h)
Calculate log 2 of bfloat16.
Definition amd_hip_bf16.h:1628
__BF16_DEVICE_STATIC__ __hip_bfloat16 hexp(const __hip_bfloat16 h)
Calculate exponential of bfloat16.
Definition amd_hip_bf16.h:1580
__BF16_DEVICE_STATIC__ __hip_bfloat162 h2trunc(const __hip_bfloat162 h)
Calculate truncate of bfloat162.
Definition amd_hip_bf16.h:1810
__BF16_DEVICE_STATIC__ __hip_bfloat162 h2rcp(const __hip_bfloat162 h)
Calculate vector reciprocal.
Definition amd_hip_bf16.h:1765
__BF16_DEVICE_STATIC__ __hip_bfloat162 h2log(const __hip_bfloat162 h)
Calculate natural log of bfloat162.
Definition amd_hip_bf16.h:1738
__BF16_DEVICE_STATIC__ __hip_bfloat162 h2exp(const __hip_bfloat162 h)
Calculate exponential of bfloat162.
Definition amd_hip_bf16.h:1702
__BF16_DEVICE_STATIC__ __hip_bfloat162 h2cos(const __hip_bfloat162 h)
Calculate cosine of bfloat162.
Definition amd_hip_bf16.h:1693
__BF16_DEVICE_STATIC__ __hip_bfloat162 h2sin(const __hip_bfloat162 h)
Calculate sin of bfloat162.
Definition amd_hip_bf16.h:1792
__BF16_DEVICE_STATIC__ __hip_bfloat162 h2log2(const __hip_bfloat162 h)
Calculate log 2 of bfloat162.
Definition amd_hip_bf16.h:1756
__BF16_DEVICE_STATIC__ __hip_bfloat162 h2ceil(const __hip_bfloat162 h)
Calculate ceil of bfloat162.
Definition amd_hip_bf16.h:1684
__BF16_DEVICE_STATIC__ __hip_bfloat162 h2floor(const __hip_bfloat162 h)
Calculate floor of bfloat162.
Definition amd_hip_bf16.h:1729
__BF16_DEVICE_STATIC__ __hip_bfloat162 h2exp10(const __hip_bfloat162 h)
Calculate exponential 10 of bfloat162.
Definition amd_hip_bf16.h:1711
__BF16_DEVICE_STATIC__ __hip_bfloat162 h2exp2(const __hip_bfloat162 h)
Calculate exponential 2 of bfloat162.
Definition amd_hip_bf16.h:1720
__BF16_DEVICE_STATIC__ __hip_bfloat162 h2log10(const __hip_bfloat162 h)
Calculate log 10 of bfloat162.
Definition amd_hip_bf16.h:1747
__BF16_DEVICE_STATIC__ __hip_bfloat162 h2rsqrt(const __hip_bfloat162 h)
Calculate vector reciprocal square root.
Definition amd_hip_bf16.h:1783
__BF16_DEVICE_STATIC__ __hip_bfloat162 h2rint(const __hip_bfloat162 h)
Calculate vector round to nearest int.
Definition amd_hip_bf16.h:1774
__BF16_DEVICE_STATIC__ __hip_bfloat162 h2sqrt(const __hip_bfloat162 h)
Calculate sqrt of bfloat162.
Definition amd_hip_bf16.h:1801
_Float16 __2f16 __attribute__((ext_vector_type(2)))
Definition hip_fp16_math_fwd.h:57
Definition amd_hip_vector_types.h:2035