Skip to content

Commit 15a92ee

Browse files
committed
Fix compilation error with __hneg(bfloat16) and __habs(bfloat16) on HIP 6.4
1 parent cb04a8f commit 15a92ee

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

include/kernel_float/bf16.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,15 @@ KERNEL_FLOAT_BF16_UNARY_FUN(negate, ::__hneg, ::__hneg2)
106106
// For CUDA, we can just use the regular bfloat16 functions (see above).
107107
#elif KERNEL_FLOAT_IS_HIP
108108
KERNEL_FLOAT_INLINE __hip_bfloat16 hip_habs(const __hip_bfloat16 a) {
109-
__hip_bfloat16 res = a;
110-
res.data &= 0x7FFF;
111-
return res;
109+
unsigned short int res = __bfloat16_as_ushort(a);
110+
res &= 0x7FFF;
111+
return __ushort_as_bfloat16();
112112
}
113113

114114
KERNEL_FLOAT_INLINE __hip_bfloat16 hip_hneg(const __hip_bfloat16 a) {
115-
__hip_bfloat16 res = a;
116-
res.data ^= 0x8000;
117-
return res;
115+
unsigned short int res = __bfloat16_as_ushort(a);
116+
res ^= 0x8000;
117+
return __ushort_as_bfloat16(res);
118118
}
119119

120120
KERNEL_FLOAT_INLINE __hip_bfloat162 hip_habs2(const __hip_bfloat162 a) {
@@ -272,8 +272,8 @@ KERNEL_FLOAT_BF16_CAST(unsigned long long, __ull2bfloat16_rn(input), __bfloat162
272272
#elif KERNEL_FLOAT_IS_HIP
273273
KERNEL_FLOAT_BF16_CAST(
274274
bool,
275-
__hip_bfloat16 {input ? (unsigned short)0 : (unsigned short)0x3C00},
276-
(__hip_bfloat16(input).data & 0x7FFF) != 0);
275+
__ushort_as_bfloat16(input ? (unsigned short)0 : (unsigned short)0x3C00),
276+
(__bfloat16_as_ushort(input) & 0x7FFF) != 0);
277277
#endif
278278

279279
KERNEL_FLOAT_VECTOR_ALIAS(bfloat16x, bfloat16_t)

single_include/kernel_float.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

1717
//================================================================================
1818
// this file has been auto-generated, do not modify its contents!
19-
// date: 2025-01-27 16:26:28.827757
20-
// git hash: 09dc82096e4c013a079f0e315da1ccce17453c93
19+
// date: 2025-07-17 14:58:12.821069
20+
// git hash: cb04a8f36c97ea0e0ff0648316f82b6125214c83
2121
//================================================================================
2222

2323
#ifndef KERNEL_FLOAT_MACROS_H
@@ -4403,15 +4403,15 @@ KERNEL_FLOAT_BF16_UNARY_FUN(negate, ::__hneg, ::__hneg2)
44034403
// For CUDA, we can just use the regular bfloat16 functions (see above).
44044404
#elif KERNEL_FLOAT_IS_HIP
44054405
KERNEL_FLOAT_INLINE __hip_bfloat16 hip_habs(const __hip_bfloat16 a) {
4406-
__hip_bfloat16 res = a;
4407-
res.data &= 0x7FFF;
4408-
return res;
4406+
unsigned short int res = __bfloat16_as_ushort(a);
4407+
res &= 0x7FFF;
4408+
return __ushort_as_bfloat16();
44094409
}
44104410

44114411
KERNEL_FLOAT_INLINE __hip_bfloat16 hip_hneg(const __hip_bfloat16 a) {
4412-
__hip_bfloat16 res = a;
4413-
res.data ^= 0x8000;
4414-
return res;
4412+
unsigned short int res = __bfloat16_as_ushort(a);
4413+
res ^= 0x8000;
4414+
return __ushort_as_bfloat16(res);
44154415
}
44164416

44174417
KERNEL_FLOAT_INLINE __hip_bfloat162 hip_habs2(const __hip_bfloat162 a) {
@@ -4569,8 +4569,8 @@ KERNEL_FLOAT_BF16_CAST(unsigned long long, __ull2bfloat16_rn(input), __bfloat162
45694569
#elif KERNEL_FLOAT_IS_HIP
45704570
KERNEL_FLOAT_BF16_CAST(
45714571
bool,
4572-
__hip_bfloat16 {input ? (unsigned short)0 : (unsigned short)0x3C00},
4573-
(__hip_bfloat16(input).data & 0x7FFF) != 0);
4572+
__ushort_as_bfloat16(input ? (unsigned short)0 : (unsigned short)0x3C00),
4573+
(__bfloat16_as_ushort(input) & 0x7FFF) != 0);
45744574
#endif
45754575

45764576
KERNEL_FLOAT_VECTOR_ALIAS(bfloat16x, bfloat16_t)
@@ -5842,7 +5842,7 @@ struct tiling_iterator {
58425842
KERNEL_FLOAT_INLINE
58435843
tiling_iterator operator++(int) {
58445844
tiling_iterator old = *this;
5845-
this ++;
5845+
(*this)++;
58465846
return old;
58475847
}
58485848

0 commit comments

Comments
 (0)