triton-windows 3.2.0.post18__cp39-cp39-win_amd64.whl → 3.2.0.post21__cp39-cp39-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of triton-windows might be problematic. Click here for more details.
- triton/_C/libtriton.pyd +0 -0
- triton/backends/amd/driver.py +6 -1
- triton/backends/nvidia/compiler.py +1 -3
- triton/backends/nvidia/driver.c +1 -0
- triton/backends/nvidia/driver.py +8 -3
- triton/runtime/autotuner.py +2 -2
- triton/runtime/build.py +14 -6
- triton/runtime/tcc/lib/python310.def +1610 -0
- triton/runtime/tcc/lib/python311.def +1633 -0
- triton/runtime/tcc/lib/python312.def +1703 -0
- triton/runtime/tcc/lib/python313.def +1651 -0
- triton/runtime/tcc/lib/python313t.def +1656 -0
- triton/runtime/tcc/lib/python39.def +1644 -0
- triton/runtime/tcc/lib/python3t.def +905 -0
- triton/windows_utils.py +11 -4
- {triton_windows-3.2.0.post18.dist-info → triton_windows-3.2.0.post21.dist-info}/METADATA +1 -1
- {triton_windows-3.2.0.post18.dist-info → triton_windows-3.2.0.post21.dist-info}/RECORD +19 -104
- {triton_windows-3.2.0.post18.dist-info → triton_windows-3.2.0.post21.dist-info}/WHEEL +1 -1
- triton/backends/amd/include/hip/amd_detail/amd_channel_descriptor.h +0 -358
- triton/backends/amd/include/hip/amd_detail/amd_device_functions.h +0 -1031
- triton/backends/amd/include/hip/amd_detail/amd_hip_atomic.h +0 -1612
- triton/backends/amd/include/hip/amd_detail/amd_hip_bf16.h +0 -1337
- triton/backends/amd/include/hip/amd_detail/amd_hip_bfloat16.h +0 -293
- triton/backends/amd/include/hip/amd_detail/amd_hip_common.h +0 -32
- triton/backends/amd/include/hip/amd_detail/amd_hip_complex.h +0 -174
- triton/backends/amd/include/hip/amd_detail/amd_hip_cooperative_groups.h +0 -829
- triton/backends/amd/include/hip/amd_detail/amd_hip_fp16.h +0 -1809
- triton/backends/amd/include/hip/amd_detail/amd_hip_gl_interop.h +0 -108
- triton/backends/amd/include/hip/amd_detail/amd_hip_math_constants.h +0 -124
- triton/backends/amd/include/hip/amd_detail/amd_hip_runtime.h +0 -405
- triton/backends/amd/include/hip/amd_detail/amd_hip_runtime_pt_api.h +0 -196
- triton/backends/amd/include/hip/amd_detail/amd_hip_unsafe_atomics.h +0 -565
- triton/backends/amd/include/hip/amd_detail/amd_hip_vector_types.h +0 -2226
- triton/backends/amd/include/hip/amd_detail/amd_math_functions.h +0 -104
- triton/backends/amd/include/hip/amd_detail/amd_surface_functions.h +0 -244
- triton/backends/amd/include/hip/amd_detail/amd_warp_functions.h +0 -494
- triton/backends/amd/include/hip/amd_detail/concepts.hpp +0 -30
- triton/backends/amd/include/hip/amd_detail/device_library_decls.h +0 -133
- triton/backends/amd/include/hip/amd_detail/functional_grid_launch.hpp +0 -218
- triton/backends/amd/include/hip/amd_detail/grid_launch.h +0 -67
- triton/backends/amd/include/hip/amd_detail/grid_launch.hpp +0 -50
- triton/backends/amd/include/hip/amd_detail/grid_launch_GGL.hpp +0 -26
- triton/backends/amd/include/hip/amd_detail/helpers.hpp +0 -137
- triton/backends/amd/include/hip/amd_detail/hip_api_trace.hpp +0 -1350
- triton/backends/amd/include/hip/amd_detail/hip_assert.h +0 -101
- triton/backends/amd/include/hip/amd_detail/hip_cooperative_groups_helper.h +0 -242
- triton/backends/amd/include/hip/amd_detail/hip_fp16_gcc.h +0 -254
- triton/backends/amd/include/hip/amd_detail/hip_fp16_math_fwd.h +0 -96
- triton/backends/amd/include/hip/amd_detail/hip_ldg.h +0 -100
- triton/backends/amd/include/hip/amd_detail/hip_prof_str.h +0 -10169
- triton/backends/amd/include/hip/amd_detail/hip_runtime_prof.h +0 -77
- triton/backends/amd/include/hip/amd_detail/host_defines.h +0 -180
- triton/backends/amd/include/hip/amd_detail/hsa_helpers.hpp +0 -102
- triton/backends/amd/include/hip/amd_detail/macro_based_grid_launch.hpp +0 -798
- triton/backends/amd/include/hip/amd_detail/math_fwd.h +0 -698
- triton/backends/amd/include/hip/amd_detail/ockl_image.h +0 -177
- triton/backends/amd/include/hip/amd_detail/program_state.hpp +0 -107
- triton/backends/amd/include/hip/amd_detail/texture_fetch_functions.h +0 -491
- triton/backends/amd/include/hip/amd_detail/texture_indirect_functions.h +0 -478
- triton/backends/amd/include/hip/channel_descriptor.h +0 -39
- triton/backends/amd/include/hip/device_functions.h +0 -38
- triton/backends/amd/include/hip/driver_types.h +0 -468
- triton/backends/amd/include/hip/hip_bf16.h +0 -36
- triton/backends/amd/include/hip/hip_bfloat16.h +0 -44
- triton/backends/amd/include/hip/hip_common.h +0 -100
- triton/backends/amd/include/hip/hip_complex.h +0 -38
- triton/backends/amd/include/hip/hip_cooperative_groups.h +0 -46
- triton/backends/amd/include/hip/hip_deprecated.h +0 -95
- triton/backends/amd/include/hip/hip_ext.h +0 -159
- triton/backends/amd/include/hip/hip_fp16.h +0 -36
- triton/backends/amd/include/hip/hip_gl_interop.h +0 -32
- triton/backends/amd/include/hip/hip_hcc.h +0 -24
- triton/backends/amd/include/hip/hip_math_constants.h +0 -36
- triton/backends/amd/include/hip/hip_profile.h +0 -27
- triton/backends/amd/include/hip/hip_runtime.h +0 -75
- triton/backends/amd/include/hip/hip_runtime_api.h +0 -8919
- triton/backends/amd/include/hip/hip_texture_types.h +0 -29
- triton/backends/amd/include/hip/hip_vector_types.h +0 -41
- triton/backends/amd/include/hip/hip_version.h +0 -17
- triton/backends/amd/include/hip/hiprtc.h +0 -421
- triton/backends/amd/include/hip/library_types.h +0 -78
- triton/backends/amd/include/hip/math_functions.h +0 -42
- triton/backends/amd/include/hip/surface_types.h +0 -63
- triton/backends/amd/include/hip/texture_types.h +0 -194
- triton/backends/amd/include/hsa/Brig.h +0 -1131
- triton/backends/amd/include/hsa/amd_hsa_common.h +0 -91
- triton/backends/amd/include/hsa/amd_hsa_elf.h +0 -436
- triton/backends/amd/include/hsa/amd_hsa_kernel_code.h +0 -269
- triton/backends/amd/include/hsa/amd_hsa_queue.h +0 -109
- triton/backends/amd/include/hsa/amd_hsa_signal.h +0 -80
- triton/backends/amd/include/hsa/hsa.h +0 -5729
- triton/backends/amd/include/hsa/hsa_amd_tool.h +0 -91
- triton/backends/amd/include/hsa/hsa_api_trace.h +0 -566
- triton/backends/amd/include/hsa/hsa_ext_amd.h +0 -3090
- triton/backends/amd/include/hsa/hsa_ext_finalize.h +0 -531
- triton/backends/amd/include/hsa/hsa_ext_image.h +0 -1454
- triton/backends/amd/include/hsa/hsa_ven_amd_aqlprofile.h +0 -488
- triton/backends/amd/include/hsa/hsa_ven_amd_loader.h +0 -667
- triton/backends/amd/include/roctracer/ext/prof_protocol.h +0 -107
- triton/backends/amd/include/roctracer/hip_ostream_ops.h +0 -4435
- triton/backends/amd/include/roctracer/hsa_ostream_ops.h +0 -1467
- triton/backends/amd/include/roctracer/hsa_prof_str.h +0 -3027
- triton/backends/amd/include/roctracer/roctracer.h +0 -779
- triton/backends/amd/include/roctracer/roctracer_ext.h +0 -81
- triton/backends/amd/include/roctracer/roctracer_hcc.h +0 -24
- triton/backends/amd/include/roctracer/roctracer_hip.h +0 -37
- triton/backends/amd/include/roctracer/roctracer_hsa.h +0 -112
- triton/backends/amd/include/roctracer/roctracer_plugin.h +0 -137
- triton/backends/amd/include/roctracer/roctracer_roctx.h +0 -67
- triton/backends/amd/include/roctracer/roctx.h +0 -229
- {triton_windows-3.2.0.post18.dist-info → triton_windows-3.2.0.post21.dist-info}/top_level.txt +0 -0
|
@@ -1,1337 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MIT License
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2019 - 2023 Advanced Micro Devices, Inc. All rights reserved.
|
|
5
|
-
*
|
|
6
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
-
* in the Software without restriction, including without limitation the rights
|
|
9
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
-
* furnished to do so, subject to the following conditions:
|
|
12
|
-
*
|
|
13
|
-
* The above copyright notice and this permission notice shall be included in
|
|
14
|
-
* all copies or substantial portions of the Software.
|
|
15
|
-
*
|
|
16
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
-
* SOFTWARE.
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* \file
|
|
27
|
-
* \brief hip_bf16.h provides struct for __hip_bfloat16 types
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* \defgroup HIP_INTRINSIC_BFLOAT16 bfloat16 Precision Intrinsics
|
|
32
|
-
* This section describes hip_bfloat16 precision intrinsic functions.
|
|
33
|
-
* To use these functions, include the header file \p hip_bf16.h in your program.
|
|
34
|
-
*/
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* \defgroup HIP_INTRINSIC_BFLOAT16_ARITH Bfloat16 Arithmetic Functions
|
|
38
|
-
* \ingroup HIP_INTRINSIC_BFLOAT16
|
|
39
|
-
* To use these functions, include the header file \p hip_bf16.h in your program.
|
|
40
|
-
*/
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* \defgroup HIP_INTRINSIC_BFLOAT16_COMP Bfloat16 Comparision Functions
|
|
44
|
-
* \ingroup HIP_INTRINSIC_BFLOAT16
|
|
45
|
-
* To use these functions, include the header file \p hip_bf16.h in your program.
|
|
46
|
-
*/
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* \defgroup HIP_INTRINSIC_BFLOAT162_COMP Bfloat162 Comparision Functions
|
|
50
|
-
* \ingroup HIP_INTRINSIC_BFLOAT16
|
|
51
|
-
* To use these functions, include the header file \p hip_bf16.h in your program.
|
|
52
|
-
*/
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* \defgroup HIP_INTRINSIC_BFLOAT162_ARITH Bfloat162 Arithmetic Functions
|
|
56
|
-
* \ingroup HIP_INTRINSIC_BFLOAT16
|
|
57
|
-
* To use these functions, include the header file \p hip_bf16.h in your program.
|
|
58
|
-
*/
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* \defgroup HIP_INTRINSIC_BFLOAT16_CONV Bfloat16 Conversion Functions
|
|
62
|
-
* \ingroup HIP_INTRINSIC_BFLOAT16
|
|
63
|
-
* To use these functions, include the header file \p hip_bf16.h in your program.
|
|
64
|
-
*/
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* \defgroup HIP_INTRINSIC_BFLOAT162_CONV Bfloat162 Conversion Functions
|
|
68
|
-
* \ingroup HIP_INTRINSIC_BFLOAT16
|
|
69
|
-
* To use these functions, include the header file \p hip_bf16.h in your program.
|
|
70
|
-
*/
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* \defgroup HIP_INTRINSIC_BFLOAT16_MATH Bfloat16 Math Functions
|
|
74
|
-
* \ingroup HIP_INTRINSIC_BFLOAT16
|
|
75
|
-
* To use these functions, include the header file \p hip_bf16.h in your program.
|
|
76
|
-
*/
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* \defgroup HIP_INTRINSIC_BFLOAT162_MATH Bfloat162 Math Functions
|
|
80
|
-
* \ingroup HIP_INTRINSIC_BFLOAT16
|
|
81
|
-
* To use these functions, include the header file \p hip_bf16.h in your program.
|
|
82
|
-
*/
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
#ifndef _HIP_INCLUDE_HIP_AMD_DETAIL_HIP_BF16_H_
|
|
86
|
-
#define _HIP_INCLUDE_HIP_AMD_DETAIL_HIP_BF16_H_
|
|
87
|
-
|
|
88
|
-
#if !defined(__HIPCC_RTC__)
|
|
89
|
-
#include <hip/amd_detail/amd_hip_common.h>
|
|
90
|
-
#endif // !defined(__HIPCC_RTC__)
|
|
91
|
-
|
|
92
|
-
#include "amd_hip_vector_types.h" // float2 etc
|
|
93
|
-
#include "device_library_decls.h" // ocml conversion functions
|
|
94
|
-
#include "math_fwd.h" // ocml device functions
|
|
95
|
-
|
|
96
|
-
#if defined(__HIPCC_RTC__)
|
|
97
|
-
#define __HOST_DEVICE__ __device__ static
|
|
98
|
-
#else
|
|
99
|
-
#include <algorithm>
|
|
100
|
-
#include <climits>
|
|
101
|
-
#include <cmath>
|
|
102
|
-
#define __HOST_DEVICE__ __host__ __device__ static inline
|
|
103
|
-
#endif
|
|
104
|
-
|
|
105
|
-
#define HIPRT_ONE_BF16 __float2bfloat16(1.0f)
|
|
106
|
-
#define HIPRT_ZERO_BF16 __float2bfloat16(0.0f)
|
|
107
|
-
#define HIPRT_INF_BF16 __ushort_as_bfloat16((unsigned short)0x7F80U)
|
|
108
|
-
#define HIPRT_MAX_NORMAL_BF16 __ushort_as_bfloat16((unsigned short)0x7F7FU)
|
|
109
|
-
#define HIPRT_MIN_DENORM_BF16 __ushort_as_bfloat16((unsigned short)0x0001U)
|
|
110
|
-
#define HIPRT_NAN_BF16 __ushort_as_bfloat16((unsigned short)0x7FFFU)
|
|
111
|
-
#define HIPRT_NEG_ZERO_BF16 __ushort_as_bfloat16((unsigned short)0x8000U)
|
|
112
|
-
|
|
113
|
-
// Since we are using unsigned short to represent data in bfloat16, it can be of different sizes on
|
|
114
|
-
// different machines. These naive checks should prevent some undefined behavior on systems which
|
|
115
|
-
// have different sizes for basic types.
|
|
116
|
-
#if !defined(__HIPCC_RTC__)
|
|
117
|
-
static_assert(CHAR_BIT == 8, "byte size should be of 8 bits");
|
|
118
|
-
#endif
|
|
119
|
-
static_assert(sizeof(unsigned short) == 2, "size of unsigned short should be 2 bytes");
|
|
120
|
-
|
|
121
|
-
/*! \brief Struct to represent a 16 bit brain floating point number. */
|
|
122
|
-
struct __hip_bfloat16 {
|
|
123
|
-
unsigned short data;
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
/*! \brief Struct to represent two 16 bit brain floating point numbers. */
|
|
127
|
-
struct __hip_bfloat162 {
|
|
128
|
-
__hip_bfloat16 x;
|
|
129
|
-
__hip_bfloat16 y;
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* \ingroup HIP_INTRINSIC_BFLOAT16_CONV
|
|
134
|
-
* \brief Converts bfloat16 to float
|
|
135
|
-
*/
|
|
136
|
-
__HOST_DEVICE__ inline float __bfloat162float(__hip_bfloat16 a) {
|
|
137
|
-
unsigned int uval = 0;
|
|
138
|
-
uval = a.data << 16;
|
|
139
|
-
union {
|
|
140
|
-
unsigned int u32;
|
|
141
|
-
float fp32;
|
|
142
|
-
} u = {uval};
|
|
143
|
-
return u.fp32;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* \ingroup HIP_INTRINSIC_BFLOAT16_CONV
|
|
148
|
-
* \brief Converts float to bfloat16
|
|
149
|
-
*/
|
|
150
|
-
__HOST_DEVICE__ __hip_bfloat16 __float2bfloat16(float f) {
|
|
151
|
-
__hip_bfloat16 ret;
|
|
152
|
-
union {
|
|
153
|
-
float fp32;
|
|
154
|
-
unsigned int u32;
|
|
155
|
-
} u = {f};
|
|
156
|
-
if (~u.u32 & 0x7f800000) {
|
|
157
|
-
// When the exponent bits are not all 1s, then the value is zero, normal,
|
|
158
|
-
// or subnormal. We round the bfloat16 mantissa up by adding 0x7FFF, plus
|
|
159
|
-
// 1 if the least significant bit of the bfloat16 mantissa is 1 (odd).
|
|
160
|
-
// This causes the bfloat16's mantissa to be incremented by 1 if the 16
|
|
161
|
-
// least significant bits of the float mantissa are greater than 0x8000,
|
|
162
|
-
// or if they are equal to 0x8000 and the least significant bit of the
|
|
163
|
-
// bfloat16 mantissa is 1 (odd). This causes it to be rounded to even when
|
|
164
|
-
// the lower 16 bits are exactly 0x8000. If the bfloat16 mantissa already
|
|
165
|
-
// has the value 0x7f, then incrementing it causes it to become 0x00 and
|
|
166
|
-
// the exponent is incremented by one, which is the next higher FP value
|
|
167
|
-
// to the unrounded bfloat16 value. When the bfloat16 value is subnormal
|
|
168
|
-
// with an exponent of 0x00 and a mantissa of 0x7F, it may be rounded up
|
|
169
|
-
// to a normal value with an exponent of 0x01 and a mantissa of 0x00.
|
|
170
|
-
// When the bfloat16 value has an exponent of 0xFE and a mantissa of 0x7F,
|
|
171
|
-
// incrementing it causes it to become an exponent of 0xFF and a mantissa
|
|
172
|
-
// of 0x00, which is Inf, the next higher value to the unrounded value.
|
|
173
|
-
u.u32 += 0x7fff + ((u.u32 >> 16) & 1); // Round to nearest, round to even
|
|
174
|
-
} else if (u.u32 & 0xffff) {
|
|
175
|
-
// When all of the exponent bits are 1, the value is Inf or NaN.
|
|
176
|
-
// Inf is indicated by a zero mantissa. NaN is indicated by any nonzero
|
|
177
|
-
// mantissa bit. Quiet NaN is indicated by the most significant mantissa
|
|
178
|
-
// bit being 1. Signaling NaN is indicated by the most significant
|
|
179
|
-
// mantissa bit being 0 but some other bit(s) being 1. If any of the
|
|
180
|
-
// lower 16 bits of the mantissa are 1, we set the least significant bit
|
|
181
|
-
// of the bfloat16 mantissa, in order to preserve signaling NaN in case
|
|
182
|
-
// the bloat16's mantissa bits are all 0.
|
|
183
|
-
u.u32 |= 0x10000; // Preserve signaling NaN
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
ret.data = (u.u32 >> 16);
|
|
187
|
-
return ret;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
/**
|
|
191
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_CONV
|
|
192
|
-
* \brief Converts and moves bfloat162 to float2
|
|
193
|
-
*/
|
|
194
|
-
__HOST_DEVICE__ float2 __bfloat1622float2(const __hip_bfloat162 a) {
|
|
195
|
-
return float2{__bfloat162float(a.x), __bfloat162float(a.y)};
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
/**
|
|
199
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_CONV
|
|
200
|
-
* \brief Moves bfloat16 value to bfloat162
|
|
201
|
-
*/
|
|
202
|
-
__HOST_DEVICE__ __hip_bfloat162 __bfloat162bfloat162(const __hip_bfloat16 a) {
|
|
203
|
-
return __hip_bfloat162{a, a};
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_CONV
|
|
208
|
-
* \brief Reinterprets bits in a __hip_bfloat16 as a signed short integer
|
|
209
|
-
*/
|
|
210
|
-
__HOST_DEVICE__ short int __bfloat16_as_short(const __hip_bfloat16 h) { return (short)h.data; }
|
|
211
|
-
|
|
212
|
-
/**
|
|
213
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_CONV
|
|
214
|
-
* \brief Reinterprets bits in a __hip_bfloat16 as an unsigned signed short integer
|
|
215
|
-
*/
|
|
216
|
-
__HOST_DEVICE__ unsigned short int __bfloat16_as_ushort(const __hip_bfloat16 h) { return h.data; }
|
|
217
|
-
|
|
218
|
-
/**
|
|
219
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_CONV
|
|
220
|
-
* \brief Convert double to __hip_bfloat16
|
|
221
|
-
*/
|
|
222
|
-
__HOST_DEVICE__ __hip_bfloat16 __double2bfloat16(const double a) {
|
|
223
|
-
return __float2bfloat16((float)a);
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
/**
|
|
227
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_CONV
|
|
228
|
-
* \brief Convert float2 to __hip_bfloat162
|
|
229
|
-
*/
|
|
230
|
-
__HOST_DEVICE__ __hip_bfloat162 __float22bfloat162_rn(const float2 a) {
|
|
231
|
-
return __hip_bfloat162{__float2bfloat16(a.x), __float2bfloat16(a.y)};
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
/**
|
|
235
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_CONV
|
|
236
|
-
* \brief Combine two __hip_bfloat16 to __hip_bfloat162
|
|
237
|
-
*/
|
|
238
|
-
__HOST_DEVICE__ __hip_bfloat162 __halves2bfloat162(const __hip_bfloat16 a, const __hip_bfloat16 b) {
|
|
239
|
-
return __hip_bfloat162{a, b};
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
/**
|
|
243
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_CONV
|
|
244
|
-
* \brief Returns high 16 bits of __hip_bfloat162
|
|
245
|
-
*/
|
|
246
|
-
__HOST_DEVICE__ __hip_bfloat16 __high2bfloat16(const __hip_bfloat162 a) { return a.y; }
|
|
247
|
-
|
|
248
|
-
/**
|
|
249
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_CONV
|
|
250
|
-
* \brief Returns high 16 bits of __hip_bfloat162
|
|
251
|
-
*/
|
|
252
|
-
__HOST_DEVICE__ __hip_bfloat162 __high2bfloat162(const __hip_bfloat162 a) {
|
|
253
|
-
return __hip_bfloat162{a.y, a.y};
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
/**
|
|
257
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_CONV
|
|
258
|
-
* \brief Converts high 16 bits of __hip_bfloat162 to float and returns the result
|
|
259
|
-
*/
|
|
260
|
-
__HOST_DEVICE__ float __high2float(const __hip_bfloat162 a) { return __bfloat162float(a.y); }
|
|
261
|
-
|
|
262
|
-
/**
|
|
263
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_CONV
|
|
264
|
-
* \brief Extracts high 16 bits from each and combines them
|
|
265
|
-
*/
|
|
266
|
-
__HOST_DEVICE__ __hip_bfloat162 __highs2bfloat162(const __hip_bfloat162 a,
|
|
267
|
-
const __hip_bfloat162 b) {
|
|
268
|
-
return __hip_bfloat162{a.y, b.y};
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
/**
|
|
272
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_CONV
|
|
273
|
-
* \brief Returns low 16 bits of __hip_bfloat162
|
|
274
|
-
*/
|
|
275
|
-
__HOST_DEVICE__ __hip_bfloat16 __low2bfloat16(const __hip_bfloat162 a) { return a.x; }
|
|
276
|
-
|
|
277
|
-
/**
|
|
278
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_CONV
|
|
279
|
-
* \brief Returns low 16 bits of __hip_bfloat162
|
|
280
|
-
*/
|
|
281
|
-
__HOST_DEVICE__ __hip_bfloat162 __low2bfloat162(const __hip_bfloat162 a) {
|
|
282
|
-
return __hip_bfloat162{a.x, a.x};
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
/**
|
|
286
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_CONV
|
|
287
|
-
* \brief Converts low 16 bits of __hip_bfloat162 to float and returns the result
|
|
288
|
-
*/
|
|
289
|
-
__HOST_DEVICE__ float __low2float(const __hip_bfloat162 a) { return __bfloat162float(a.x); }
|
|
290
|
-
|
|
291
|
-
/**
|
|
292
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_CONV
|
|
293
|
-
* \brief Swaps both halves
|
|
294
|
-
*/
|
|
295
|
-
__HOST_DEVICE__ __hip_bfloat162 __lowhigh2highlow(const __hip_bfloat162 a) {
|
|
296
|
-
return __hip_bfloat162{a.y, a.x};
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
/**
|
|
300
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_CONV
|
|
301
|
-
* \brief Extracts low 16 bits from each and combines them
|
|
302
|
-
*/
|
|
303
|
-
__HOST_DEVICE__ __hip_bfloat162 __lows2bfloat162(const __hip_bfloat162 a, const __hip_bfloat162 b) {
|
|
304
|
-
return __hip_bfloat162{a.x, b.x};
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
/**
|
|
308
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_CONV
|
|
309
|
-
* \brief Reinterprets short int into a bfloat16
|
|
310
|
-
*/
|
|
311
|
-
__HOST_DEVICE__ __hip_bfloat16 __short_as_bfloat16(const short int a) {
|
|
312
|
-
return __hip_bfloat16{(unsigned short)a};
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
/**
|
|
316
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_CONV
|
|
317
|
-
* \brief Reinterprets unsigned short int into a bfloat16
|
|
318
|
-
*/
|
|
319
|
-
__HOST_DEVICE__ __hip_bfloat16 __ushort_as_bfloat16(const unsigned short int a) {
|
|
320
|
-
return __hip_bfloat16{a};
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
/**
|
|
325
|
-
* \ingroup HIP_INTRINSIC_BFLOAT16_ARITH
|
|
326
|
-
* \brief Adds two bfloat16 values
|
|
327
|
-
*/
|
|
328
|
-
__HOST_DEVICE__ __hip_bfloat16 __hadd(const __hip_bfloat16 a, const __hip_bfloat16 b) {
|
|
329
|
-
return __float2bfloat16(__bfloat162float(a) + __bfloat162float(b));
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
/**
|
|
333
|
-
* \ingroup HIP_INTRINSIC_BFLOAT16_ARITH
|
|
334
|
-
* \brief Subtracts two bfloat16 values
|
|
335
|
-
*/
|
|
336
|
-
__HOST_DEVICE__ __hip_bfloat16 __hsub(const __hip_bfloat16 a, const __hip_bfloat16 b) {
|
|
337
|
-
return __float2bfloat16(__bfloat162float(a) - __bfloat162float(b));
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
/**
|
|
341
|
-
* \ingroup HIP_INTRINSIC_BFLOAT16_ARITH
|
|
342
|
-
* \brief Divides two bfloat16 values
|
|
343
|
-
*/
|
|
344
|
-
__HOST_DEVICE__ __hip_bfloat16 __hdiv(const __hip_bfloat16 a, const __hip_bfloat16 b) {
|
|
345
|
-
return __float2bfloat16(__bfloat162float(a) / __bfloat162float(b));
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
/**
|
|
349
|
-
* \ingroup HIP_INTRINSIC_BFLOAT16_ARITH
|
|
350
|
-
* \brief Performs FMA of given bfloat16 values
|
|
351
|
-
*/
|
|
352
|
-
__device__ __hip_bfloat16 __hfma(const __hip_bfloat16 a, const __hip_bfloat16 b,
|
|
353
|
-
const __hip_bfloat16 c) {
|
|
354
|
-
return __float2bfloat16(
|
|
355
|
-
__ocml_fma_f32(__bfloat162float(a), __bfloat162float(b), __bfloat162float(c)));
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
/**
|
|
359
|
-
* \ingroup HIP_INTRINSIC_BFLOAT16_ARITH
|
|
360
|
-
* \brief Multiplies two bfloat16 values
|
|
361
|
-
*/
|
|
362
|
-
__HOST_DEVICE__ __hip_bfloat16 __hmul(const __hip_bfloat16 a, const __hip_bfloat16 b) {
|
|
363
|
-
return __float2bfloat16(__bfloat162float(a) * __bfloat162float(b));
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
/**
|
|
367
|
-
* \ingroup HIP_INTRINSIC_BFLOAT16_ARITH
|
|
368
|
-
* \brief Negate a bfloat16 value
|
|
369
|
-
*/
|
|
370
|
-
__HOST_DEVICE__ __hip_bfloat16 __hneg(const __hip_bfloat16 a) {
|
|
371
|
-
auto ret = a;
|
|
372
|
-
ret.data ^= 0x8000;
|
|
373
|
-
return ret;
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
/**
|
|
377
|
-
* \ingroup HIP_INTRINSIC_BFLOAT16_ARITH
|
|
378
|
-
* \brief Returns absolute of a bfloat16
|
|
379
|
-
*/
|
|
380
|
-
__HOST_DEVICE__ __hip_bfloat16 __habs(const __hip_bfloat16 a) {
|
|
381
|
-
auto ret = a;
|
|
382
|
-
ret.data &= 0x7FFF;
|
|
383
|
-
return ret;
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
/**
|
|
387
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_ARITH
|
|
388
|
-
* \brief Divides bfloat162 values
|
|
389
|
-
*/
|
|
390
|
-
__HOST_DEVICE__ __hip_bfloat162 __h2div(const __hip_bfloat162 a, const __hip_bfloat162 b) {
|
|
391
|
-
return __hip_bfloat162{__float2bfloat16(__bfloat162float(a.x) / __bfloat162float(b.x)),
|
|
392
|
-
__float2bfloat16(__bfloat162float(a.y) / __bfloat162float(b.y))};
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
/**
|
|
396
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_ARITH
|
|
397
|
-
* \brief Returns absolute of a bfloat162
|
|
398
|
-
*/
|
|
399
|
-
__HOST_DEVICE__ __hip_bfloat162 __habs2(const __hip_bfloat162 a) {
|
|
400
|
-
return __hip_bfloat162{__habs(a.x), __habs(a.y)};
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
/**
|
|
404
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_ARITH
|
|
405
|
-
* \brief Adds two bfloat162 values
|
|
406
|
-
*/
|
|
407
|
-
__HOST_DEVICE__ __hip_bfloat162 __hadd2(const __hip_bfloat162 a, const __hip_bfloat162 b) {
|
|
408
|
-
return __hip_bfloat162{__hadd(a.x, b.x), __hadd(a.y, b.y)};
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
/**
|
|
412
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_ARITH
|
|
413
|
-
* \brief Performs FMA of given bfloat162 values
|
|
414
|
-
*/
|
|
415
|
-
__device__ __hip_bfloat162 __hfma2(const __hip_bfloat162 a, const __hip_bfloat162 b,
|
|
416
|
-
const __hip_bfloat162 c) {
|
|
417
|
-
return __hip_bfloat162{__hfma(a.x, b.x, c.x), __hfma(a.y, b.y, c.y)};
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
/**
|
|
421
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_ARITH
|
|
422
|
-
* \brief Multiplies two bfloat162 values
|
|
423
|
-
*/
|
|
424
|
-
__HOST_DEVICE__ __hip_bfloat162 __hmul2(const __hip_bfloat162 a, const __hip_bfloat162 b) {
|
|
425
|
-
return __hip_bfloat162{__hmul(a.x, b.x), __hmul(a.y, b.y)};
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
/**
|
|
429
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_ARITH
|
|
430
|
-
* \brief Converts a bfloat162 into negative
|
|
431
|
-
*/
|
|
432
|
-
__HOST_DEVICE__ __hip_bfloat162 __hneg2(const __hip_bfloat162 a) {
|
|
433
|
-
return __hip_bfloat162{__hneg(a.x), __hneg(a.y)};
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
/**
|
|
437
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_ARITH
|
|
438
|
-
* \brief Subtracts two bfloat162 values
|
|
439
|
-
*/
|
|
440
|
-
__HOST_DEVICE__ __hip_bfloat162 __hsub2(const __hip_bfloat162 a, const __hip_bfloat162 b) {
|
|
441
|
-
return __hip_bfloat162{__hsub(a.x, b.x), __hsub(a.y, b.y)};
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
/**
|
|
445
|
-
* \ingroup HIP_INTRINSIC_BFLOAT16_ARITH
|
|
446
|
-
* \brief Operator to multiply two __hip_bfloat16 numbers
|
|
447
|
-
*/
|
|
448
|
-
__HOST_DEVICE__ __hip_bfloat16 operator*(const __hip_bfloat16& l, const __hip_bfloat16& r) {
|
|
449
|
-
return __hmul(l, r);
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
/**
|
|
453
|
-
* \ingroup HIP_INTRINSIC_BFLOAT16_ARITH
|
|
454
|
-
* \brief Operator to multiply-assign two __hip_bfloat16 numbers
|
|
455
|
-
*/
|
|
456
|
-
__HOST_DEVICE__ __hip_bfloat16& operator*=(__hip_bfloat16& l, const __hip_bfloat16& r) {
|
|
457
|
-
l = __hmul(l, r);
|
|
458
|
-
return l;
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
/**
|
|
462
|
-
* \ingroup HIP_INTRINSIC_BFLOAT16_ARITH
|
|
463
|
-
* \brief Operator to unary+ on a __hip_bfloat16 number
|
|
464
|
-
*/
|
|
465
|
-
__HOST_DEVICE__ __hip_bfloat16 operator+(const __hip_bfloat16& l) { return l; }
|
|
466
|
-
|
|
467
|
-
/**
|
|
468
|
-
* \ingroup HIP_INTRINSIC_BFLOAT16_ARITH
|
|
469
|
-
* \brief Operator to add two __hip_bfloat16 numbers
|
|
470
|
-
*/
|
|
471
|
-
__HOST_DEVICE__ __hip_bfloat16 operator+(const __hip_bfloat16& l, const __hip_bfloat16& r) {
|
|
472
|
-
return __hadd(l, r);
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
/**
|
|
476
|
-
* \ingroup HIP_INTRINSIC_BFLOAT16_ARITH
|
|
477
|
-
* \brief Operator to negate a __hip_bfloat16 number
|
|
478
|
-
*/
|
|
479
|
-
__HOST_DEVICE__ __hip_bfloat16 operator-(const __hip_bfloat16& l) { return __hneg(l); }
|
|
480
|
-
|
|
481
|
-
/**
|
|
482
|
-
* \ingroup HIP_INTRINSIC_BFLOAT16_ARITH
|
|
483
|
-
* \brief Operator to subtract two __hip_bfloat16 numbers
|
|
484
|
-
*/
|
|
485
|
-
__HOST_DEVICE__ __hip_bfloat16 operator-(const __hip_bfloat16& l, const __hip_bfloat16& r) {
|
|
486
|
-
return __hsub(l, r);
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
/**
|
|
490
|
-
* \ingroup HIP_INTRINSIC_BFLOAT16_ARITH
|
|
491
|
-
* \brief Operator to post increment a __hip_bfloat16 number
|
|
492
|
-
*/
|
|
493
|
-
__HOST_DEVICE__ __hip_bfloat16 operator++(__hip_bfloat16& l, const int) {
|
|
494
|
-
auto ret = l;
|
|
495
|
-
l = __hadd(l, HIPRT_ONE_BF16);
|
|
496
|
-
return ret;
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
/**
|
|
500
|
-
* \ingroup HIP_INTRINSIC_BFLOAT16_ARITH
|
|
501
|
-
* \brief Operator to pre increment a __hip_bfloat16 number
|
|
502
|
-
*/
|
|
503
|
-
__HOST_DEVICE__ __hip_bfloat16& operator++(__hip_bfloat16& l) {
|
|
504
|
-
l = __hadd(l, HIPRT_ONE_BF16);
|
|
505
|
-
return l;
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
/**
|
|
509
|
-
* \ingroup HIP_INTRINSIC_BFLOAT16_ARITH
|
|
510
|
-
* \brief Operator to post decrement a __hip_bfloat16 number
|
|
511
|
-
*/
|
|
512
|
-
__HOST_DEVICE__ __hip_bfloat16 operator--(__hip_bfloat16& l, const int) {
|
|
513
|
-
auto ret = l;
|
|
514
|
-
l = __hsub(l, HIPRT_ONE_BF16);
|
|
515
|
-
return ret;
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
/**
|
|
519
|
-
* \ingroup HIP_INTRINSIC_BFLOAT16_ARITH
|
|
520
|
-
* \brief Operator to pre decrement a __hip_bfloat16 number
|
|
521
|
-
*/
|
|
522
|
-
__HOST_DEVICE__ __hip_bfloat16& operator--(__hip_bfloat16& l) {
|
|
523
|
-
l = __hsub(l, HIPRT_ONE_BF16);
|
|
524
|
-
return l;
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
/**
|
|
528
|
-
* \ingroup HIP_INTRINSIC_BFLOAT16_ARITH
|
|
529
|
-
* \brief Operator to add-assign two __hip_bfloat16 numbers
|
|
530
|
-
*/
|
|
531
|
-
__HOST_DEVICE__ __hip_bfloat16& operator+=(__hip_bfloat16& l, const __hip_bfloat16& r) {
|
|
532
|
-
l = __hadd(l, r);
|
|
533
|
-
return l;
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
/**
|
|
537
|
-
* \ingroup HIP_INTRINSIC_BFLOAT16_ARITH
|
|
538
|
-
* \brief Operator to subtract-assign two __hip_bfloat16 numbers
|
|
539
|
-
*/
|
|
540
|
-
__HOST_DEVICE__ __hip_bfloat16& operator-=(__hip_bfloat16& l, const __hip_bfloat16& r) {
|
|
541
|
-
l = __hsub(l, r);
|
|
542
|
-
return l;
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
/**
|
|
546
|
-
* \ingroup HIP_INTRINSIC_BFLOAT16_ARITH
|
|
547
|
-
* \brief Operator to divide two __hip_bfloat16 numbers
|
|
548
|
-
*/
|
|
549
|
-
__HOST_DEVICE__ __hip_bfloat16 operator/(const __hip_bfloat16& l, const __hip_bfloat16& r) {
|
|
550
|
-
return __hdiv(l, r);
|
|
551
|
-
}
|
|
552
|
-
|
|
553
|
-
/**
|
|
554
|
-
* \ingroup HIP_INTRINSIC_BFLOAT16_ARITH
|
|
555
|
-
* \brief Operator to divide-assign two __hip_bfloat16 numbers
|
|
556
|
-
*/
|
|
557
|
-
__HOST_DEVICE__ __hip_bfloat16& operator/=(__hip_bfloat16& l, const __hip_bfloat16& r) {
|
|
558
|
-
l = __hdiv(l, r);
|
|
559
|
-
return l;
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
/**
|
|
563
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_ARITH
|
|
564
|
-
* \brief Operator to multiply two __hip_bfloat162 numbers
|
|
565
|
-
*/
|
|
566
|
-
__HOST_DEVICE__ __hip_bfloat162 operator*(const __hip_bfloat162& l, const __hip_bfloat162& r) {
|
|
567
|
-
return __hmul2(l, r);
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
/**
|
|
571
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_ARITH
|
|
572
|
-
* \brief Operator to multiply-assign two __hip_bfloat162 numbers
|
|
573
|
-
*/
|
|
574
|
-
__HOST_DEVICE__ __hip_bfloat162& operator*=(__hip_bfloat162& l, const __hip_bfloat162& r) {
|
|
575
|
-
l = __hmul2(l, r);
|
|
576
|
-
return l;
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
/**
|
|
580
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_ARITH
|
|
581
|
-
* \brief Operator to unary+ on a __hip_bfloat162 number
|
|
582
|
-
*/
|
|
583
|
-
__HOST_DEVICE__ __hip_bfloat162 operator+(const __hip_bfloat162& l) { return l; }
|
|
584
|
-
|
|
585
|
-
/**
|
|
586
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_ARITH
|
|
587
|
-
* \brief Operator to add two __hip_bfloat162 numbers
|
|
588
|
-
*/
|
|
589
|
-
__HOST_DEVICE__ __hip_bfloat162 operator+(const __hip_bfloat162& l, const __hip_bfloat162& r) {
|
|
590
|
-
return __hadd2(l, r);
|
|
591
|
-
}
|
|
592
|
-
|
|
593
|
-
/**
|
|
594
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_ARITH
|
|
595
|
-
* \brief Operator to negate a __hip_bfloat162 number
|
|
596
|
-
*/
|
|
597
|
-
__HOST_DEVICE__ __hip_bfloat162 operator-(const __hip_bfloat162& l) { return __hneg2(l); }
|
|
598
|
-
|
|
599
|
-
/**
|
|
600
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_ARITH
|
|
601
|
-
* \brief Operator to subtract two __hip_bfloat162 numbers
|
|
602
|
-
*/
|
|
603
|
-
__HOST_DEVICE__ __hip_bfloat162 operator-(const __hip_bfloat162& l, const __hip_bfloat162& r) {
|
|
604
|
-
return __hsub2(l, r);
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
/**
|
|
608
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_ARITH
|
|
609
|
-
* \brief Operator to post increment a __hip_bfloat162 number
|
|
610
|
-
*/
|
|
611
|
-
__HOST_DEVICE__ __hip_bfloat162 operator++(__hip_bfloat162& l, const int) {
|
|
612
|
-
auto ret = l;
|
|
613
|
-
l = __hadd2(l, {HIPRT_ONE_BF16, HIPRT_ONE_BF16});
|
|
614
|
-
return ret;
|
|
615
|
-
}
|
|
616
|
-
|
|
617
|
-
/**
|
|
618
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_ARITH
|
|
619
|
-
* \brief Operator to pre increment a __hip_bfloat162 number
|
|
620
|
-
*/
|
|
621
|
-
__HOST_DEVICE__ __hip_bfloat162& operator++(__hip_bfloat162& l) {
|
|
622
|
-
l = __hadd2(l, {HIPRT_ONE_BF16, HIPRT_ONE_BF16});
|
|
623
|
-
return l;
|
|
624
|
-
}
|
|
625
|
-
|
|
626
|
-
/**
|
|
627
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_ARITH
|
|
628
|
-
* \brief Operator to post decrement a __hip_bfloat162 number
|
|
629
|
-
*/
|
|
630
|
-
__HOST_DEVICE__ __hip_bfloat162 operator--(__hip_bfloat162& l, const int) {
|
|
631
|
-
auto ret = l;
|
|
632
|
-
l = __hsub2(l, {HIPRT_ONE_BF16, HIPRT_ONE_BF16});
|
|
633
|
-
return ret;
|
|
634
|
-
}
|
|
635
|
-
|
|
636
|
-
/**
|
|
637
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_ARITH
|
|
638
|
-
* \brief Operator to pre decrement a __hip_bfloat162 number
|
|
639
|
-
*/
|
|
640
|
-
__HOST_DEVICE__ __hip_bfloat162& operator--(__hip_bfloat162& l) {
|
|
641
|
-
l = __hsub2(l, {HIPRT_ONE_BF16, HIPRT_ONE_BF16});
|
|
642
|
-
return l;
|
|
643
|
-
}
|
|
644
|
-
|
|
645
|
-
/**
|
|
646
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_ARITH
|
|
647
|
-
* \brief Operator to add-assign two __hip_bfloat162 numbers
|
|
648
|
-
*/
|
|
649
|
-
__HOST_DEVICE__ __hip_bfloat162& operator+=(__hip_bfloat162& l, const __hip_bfloat162& r) {
|
|
650
|
-
l = __hadd2(l, r);
|
|
651
|
-
return l;
|
|
652
|
-
}
|
|
653
|
-
|
|
654
|
-
/**
|
|
655
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_ARITH
|
|
656
|
-
* \brief Operator to subtract-assign two __hip_bfloat162 numbers
|
|
657
|
-
*/
|
|
658
|
-
__HOST_DEVICE__ __hip_bfloat162& operator-=(__hip_bfloat162& l, const __hip_bfloat162& r) {
|
|
659
|
-
l = __hsub2(l, r);
|
|
660
|
-
return l;
|
|
661
|
-
}
|
|
662
|
-
|
|
663
|
-
/**
|
|
664
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_ARITH
|
|
665
|
-
* \brief Operator to divide two __hip_bfloat162 numbers
|
|
666
|
-
*/
|
|
667
|
-
__HOST_DEVICE__ __hip_bfloat162 operator/(const __hip_bfloat162& l, const __hip_bfloat162& r) {
|
|
668
|
-
return __h2div(l, r);
|
|
669
|
-
}
|
|
670
|
-
|
|
671
|
-
/**
|
|
672
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_ARITH
|
|
673
|
-
* \brief Operator to divide-assign two __hip_bfloat162 numbers
|
|
674
|
-
*/
|
|
675
|
-
__HOST_DEVICE__ __hip_bfloat162& operator/=(__hip_bfloat162& l, const __hip_bfloat162& r) {
|
|
676
|
-
l = __h2div(l, r);
|
|
677
|
-
return l;
|
|
678
|
-
}
|
|
679
|
-
|
|
680
|
-
/**
|
|
681
|
-
* \ingroup HIP_INTRINSIC_BFLOAT16_COMP
|
|
682
|
-
* \brief Compare two bfloat162 values
|
|
683
|
-
*/
|
|
684
|
-
__HOST_DEVICE__ bool __heq(const __hip_bfloat16 a, const __hip_bfloat16 b) {
|
|
685
|
-
return __bfloat162float(a) == __bfloat162float(b);
|
|
686
|
-
}
|
|
687
|
-
|
|
688
|
-
/**
|
|
689
|
-
* \ingroup HIP_INTRINSIC_BFLOAT16_COMP
|
|
690
|
-
* \brief Compare two bfloat162 values - unordered equal
|
|
691
|
-
*/
|
|
692
|
-
__HOST_DEVICE__ bool __hequ(const __hip_bfloat16 a, const __hip_bfloat16 b) {
|
|
693
|
-
return !(__bfloat162float(a) < __bfloat162float(b)) &&
|
|
694
|
-
!(__bfloat162float(a) > __bfloat162float(b));
|
|
695
|
-
}
|
|
696
|
-
|
|
697
|
-
/**
|
|
698
|
-
* \ingroup HIP_INTRINSIC_BFLOAT16_COMP
|
|
699
|
-
* \brief Compare two bfloat162 values - greater than
|
|
700
|
-
*/
|
|
701
|
-
__HOST_DEVICE__ bool __hgt(const __hip_bfloat16 a, const __hip_bfloat16 b) {
|
|
702
|
-
return __bfloat162float(a) > __bfloat162float(b);
|
|
703
|
-
}
|
|
704
|
-
|
|
705
|
-
/**
|
|
706
|
-
* \ingroup HIP_INTRINSIC_BFLOAT16_COMP
|
|
707
|
-
* \brief Compare two bfloat162 values - unordered greater than
|
|
708
|
-
*/
|
|
709
|
-
__HOST_DEVICE__ bool __hgtu(const __hip_bfloat16 a, const __hip_bfloat16 b) {
|
|
710
|
-
return !(__bfloat162float(a) <= __bfloat162float(b));
|
|
711
|
-
}
|
|
712
|
-
|
|
713
|
-
/**
|
|
714
|
-
* \ingroup HIP_INTRINSIC_BFLOAT16_COMP
|
|
715
|
-
* \brief Compare two bfloat162 values - greater than equal
|
|
716
|
-
*/
|
|
717
|
-
__HOST_DEVICE__ bool __hge(const __hip_bfloat16 a, const __hip_bfloat16 b) {
|
|
718
|
-
return __bfloat162float(a) >= __bfloat162float(b);
|
|
719
|
-
}
|
|
720
|
-
|
|
721
|
-
/**
|
|
722
|
-
* \ingroup HIP_INTRINSIC_BFLOAT16_COMP
|
|
723
|
-
* \brief Compare two bfloat162 values - unordered greater than equal
|
|
724
|
-
*/
|
|
725
|
-
__HOST_DEVICE__ bool __hgeu(const __hip_bfloat16 a, const __hip_bfloat16 b) {
|
|
726
|
-
return !(__bfloat162float(a) < __bfloat162float(b));
|
|
727
|
-
}
|
|
728
|
-
|
|
729
|
-
/**
|
|
730
|
-
* \ingroup HIP_INTRINSIC_BFLOAT16_COMP
|
|
731
|
-
* \brief Compare two bfloat162 values - not equal
|
|
732
|
-
*/
|
|
733
|
-
__HOST_DEVICE__ bool __hne(const __hip_bfloat16 a, const __hip_bfloat16 b) {
|
|
734
|
-
return __bfloat162float(a) != __bfloat162float(b);
|
|
735
|
-
}
|
|
736
|
-
|
|
737
|
-
/**
|
|
738
|
-
* \ingroup HIP_INTRINSIC_BFLOAT16_COMP
|
|
739
|
-
* \brief Compare two bfloat162 values - unordered not equal
|
|
740
|
-
*/
|
|
741
|
-
__HOST_DEVICE__ bool __hneu(const __hip_bfloat16 a, const __hip_bfloat16 b) {
|
|
742
|
-
return !(__bfloat162float(a) == __bfloat162float(b));
|
|
743
|
-
}
|
|
744
|
-
|
|
745
|
-
/**
|
|
746
|
-
* \ingroup HIP_INTRINSIC_BFLOAT16_COMP
|
|
747
|
-
* \brief Compare two bfloat162 values - return max
|
|
748
|
-
*/
|
|
749
|
-
__HOST_DEVICE__ __hip_bfloat16 __hmax(const __hip_bfloat16 a, const __hip_bfloat16 b) {
|
|
750
|
-
#if __HIP_DEVICE_COMPILE__
|
|
751
|
-
return __float2bfloat16(__ocml_fmax_f32(__bfloat162float(a), __bfloat162float(b)));
|
|
752
|
-
#else
|
|
753
|
-
return __float2bfloat16(std::max(__bfloat162float(a), __bfloat162float(b)));
|
|
754
|
-
#endif
|
|
755
|
-
}
|
|
756
|
-
|
|
757
|
-
/**
|
|
758
|
-
* \ingroup HIP_INTRINSIC_BFLOAT16_COMP
|
|
759
|
-
* \brief Compare two bfloat162 values - return min
|
|
760
|
-
*/
|
|
761
|
-
__HOST_DEVICE__ __hip_bfloat16 __hmin(const __hip_bfloat16 a, const __hip_bfloat16 b) {
|
|
762
|
-
#if __HIP_DEVICE_COMPILE__
|
|
763
|
-
return __float2bfloat16(__ocml_fmin_f32(__bfloat162float(a), __bfloat162float(b)));
|
|
764
|
-
#else
|
|
765
|
-
return __float2bfloat16(std::min(__bfloat162float(a), __bfloat162float(b)));
|
|
766
|
-
#endif
|
|
767
|
-
}
|
|
768
|
-
|
|
769
|
-
/**
|
|
770
|
-
* \ingroup HIP_INTRINSIC_BFLOAT16_COMP
|
|
771
|
-
* \brief Compare two bfloat162 values - less than operator
|
|
772
|
-
*/
|
|
773
|
-
__HOST_DEVICE__ bool __hlt(const __hip_bfloat16 a, const __hip_bfloat16 b) {
|
|
774
|
-
return __bfloat162float(a) < __bfloat162float(b);
|
|
775
|
-
}
|
|
776
|
-
|
|
777
|
-
/**
|
|
778
|
-
* \ingroup HIP_INTRINSIC_BFLOAT16_COMP
|
|
779
|
-
* \brief Compare two bfloat162 values - unordered less than
|
|
780
|
-
*/
|
|
781
|
-
__HOST_DEVICE__ bool __hltu(const __hip_bfloat16 a, const __hip_bfloat16 b) {
|
|
782
|
-
return !(__bfloat162float(a) >= __bfloat162float(b));
|
|
783
|
-
}
|
|
784
|
-
|
|
785
|
-
/**
|
|
786
|
-
* \ingroup HIP_INTRINSIC_BFLOAT16_COMP
|
|
787
|
-
* \brief Compare two bfloat162 values - less than equal
|
|
788
|
-
*/
|
|
789
|
-
__HOST_DEVICE__ bool __hle(const __hip_bfloat16 a, const __hip_bfloat16 b) {
|
|
790
|
-
return __bfloat162float(a) <= __bfloat162float(b);
|
|
791
|
-
}
|
|
792
|
-
|
|
793
|
-
/**
|
|
794
|
-
* \ingroup HIP_INTRINSIC_BFLOAT16_COMP
|
|
795
|
-
* \brief Compare two bfloat162 values - unordered less than equal
|
|
796
|
-
*/
|
|
797
|
-
__HOST_DEVICE__ bool __hleu(const __hip_bfloat16 a, const __hip_bfloat16 b) {
|
|
798
|
-
return !(__bfloat162float(a) > __bfloat162float(b));
|
|
799
|
-
}
|
|
800
|
-
|
|
801
|
-
/**
|
|
802
|
-
* \ingroup HIP_INTRINSIC_BFLOAT16_COMP
|
|
803
|
-
* \brief Checks if number is inf
|
|
804
|
-
*/
|
|
805
|
-
__HOST_DEVICE__ int __hisinf(const __hip_bfloat16 a) {
|
|
806
|
-
unsigned short sign = a.data & 0x8000U;
|
|
807
|
-
#if __HIP_DEVICE_COMPILE__
|
|
808
|
-
int res = __ocml_isinf_f32(__bfloat162float(a));
|
|
809
|
-
#else
|
|
810
|
-
int res = std::isinf(__bfloat162float(a)) ? 1 : 0;
|
|
811
|
-
#endif
|
|
812
|
-
return (res == 0) ? res : ((sign != 0U) ? -res : res);
|
|
813
|
-
}
|
|
814
|
-
|
|
815
|
-
/**
|
|
816
|
-
* \ingroup HIP_INTRINSIC_BFLOAT16_COMP
|
|
817
|
-
* \brief Checks if number is nan
|
|
818
|
-
*/
|
|
819
|
-
__HOST_DEVICE__ bool __hisnan(const __hip_bfloat16 a) {
|
|
820
|
-
#if __HIP_DEVICE_COMPILE__
|
|
821
|
-
return __ocml_isnan_f32(__bfloat162float(a));
|
|
822
|
-
#else
|
|
823
|
-
return std::isnan(__bfloat162float(a));
|
|
824
|
-
#endif
|
|
825
|
-
}
|
|
826
|
-
|
|
827
|
-
/**
|
|
828
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_COMP
|
|
829
|
-
* \brief Checks if two numbers are equal
|
|
830
|
-
*/
|
|
831
|
-
__HOST_DEVICE__ bool __hbeq2(const __hip_bfloat162 a, const __hip_bfloat162 b) {
|
|
832
|
-
return __heq(a.x, b.x) && __heq(a.y, b.y);
|
|
833
|
-
}
|
|
834
|
-
|
|
835
|
-
/**
|
|
836
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_COMP
|
|
837
|
-
* \brief Checks if two numbers are equal - unordered
|
|
838
|
-
*/
|
|
839
|
-
__HOST_DEVICE__ bool __hbequ2(const __hip_bfloat162 a, const __hip_bfloat162 b) {
|
|
840
|
-
return __hequ(a.x, b.x) && __hequ(a.y, b.y);
|
|
841
|
-
}
|
|
842
|
-
|
|
843
|
-
/**
|
|
844
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_COMP
|
|
845
|
-
* \brief Check for a >= b
|
|
846
|
-
*/
|
|
847
|
-
__HOST_DEVICE__ bool __hbge2(const __hip_bfloat162 a, const __hip_bfloat162 b) {
|
|
848
|
-
return __hge(a.x, b.x) && __hge(a.y, b.y);
|
|
849
|
-
}
|
|
850
|
-
|
|
851
|
-
/**
|
|
852
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_COMP
|
|
853
|
-
* \brief Check for a >= b - unordered
|
|
854
|
-
*/
|
|
855
|
-
__HOST_DEVICE__ bool __hbgeu2(const __hip_bfloat162 a, const __hip_bfloat162 b) {
|
|
856
|
-
return __hgeu(a.x, b.x) && __hgeu(a.y, b.y);
|
|
857
|
-
}
|
|
858
|
-
|
|
859
|
-
/**
|
|
860
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_COMP
|
|
861
|
-
* \brief Check for a > b
|
|
862
|
-
*/
|
|
863
|
-
__HOST_DEVICE__ bool __hbgt2(const __hip_bfloat162 a, const __hip_bfloat162 b) {
|
|
864
|
-
return __hgt(a.x, b.x) && __hgt(a.y, b.y);
|
|
865
|
-
}
|
|
866
|
-
|
|
867
|
-
/**
|
|
868
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_COMP
|
|
869
|
-
* \brief Check for a > b - unordered
|
|
870
|
-
*/
|
|
871
|
-
__HOST_DEVICE__ bool __hbgtu2(const __hip_bfloat162 a, const __hip_bfloat162 b) {
|
|
872
|
-
return __hgtu(a.x, b.x) && __hgtu(a.y, b.y);
|
|
873
|
-
}
|
|
874
|
-
|
|
875
|
-
/**
|
|
876
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_COMP
|
|
877
|
-
* \brief Check for a <= b
|
|
878
|
-
*/
|
|
879
|
-
__HOST_DEVICE__ bool __hble2(const __hip_bfloat162 a, const __hip_bfloat162 b) {
|
|
880
|
-
return __hle(a.x, b.x) && __hle(a.y, b.y);
|
|
881
|
-
}
|
|
882
|
-
|
|
883
|
-
/**
|
|
884
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_COMP
|
|
885
|
-
* \brief Check for a <= b - unordered
|
|
886
|
-
*/
|
|
887
|
-
__HOST_DEVICE__ bool __hbleu2(const __hip_bfloat162 a, const __hip_bfloat162 b) {
|
|
888
|
-
return __hleu(a.x, b.x) && __hleu(a.y, b.y);
|
|
889
|
-
}
|
|
890
|
-
|
|
891
|
-
/**
|
|
892
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_COMP
|
|
893
|
-
* \brief Check for a < b
|
|
894
|
-
*/
|
|
895
|
-
__HOST_DEVICE__ bool __hblt2(const __hip_bfloat162 a, const __hip_bfloat162 b) {
|
|
896
|
-
return __hlt(a.x, b.x) && __hlt(a.y, b.y);
|
|
897
|
-
}
|
|
898
|
-
|
|
899
|
-
/**
|
|
900
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_COMP
|
|
901
|
-
* \brief Check for a < b - unordered
|
|
902
|
-
*/
|
|
903
|
-
__HOST_DEVICE__ bool __hbltu2(const __hip_bfloat162 a, const __hip_bfloat162 b) {
|
|
904
|
-
return __hltu(a.x, b.x) && __hltu(a.y, b.y);
|
|
905
|
-
}
|
|
906
|
-
|
|
907
|
-
/**
|
|
908
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_COMP
|
|
909
|
-
* \brief Check for a != b
|
|
910
|
-
*/
|
|
911
|
-
__HOST_DEVICE__ bool __hbne2(const __hip_bfloat162 a, const __hip_bfloat162 b) {
|
|
912
|
-
return __hne(a.x, b.x) && __hne(a.y, b.y);
|
|
913
|
-
}
|
|
914
|
-
|
|
915
|
-
/**
|
|
916
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_COMP
|
|
917
|
-
* \brief Check for a != b
|
|
918
|
-
*/
|
|
919
|
-
__HOST_DEVICE__ bool __hbneu2(const __hip_bfloat162 a, const __hip_bfloat162 b) {
|
|
920
|
-
return __hneu(a.x, b.x) && __hneu(a.y, b.y);
|
|
921
|
-
}
|
|
922
|
-
|
|
923
|
-
/**
|
|
924
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_COMP
|
|
925
|
-
* \brief Check for a != b, returns 1.0 if equal, otherwise 0.0
|
|
926
|
-
*/
|
|
927
|
-
__HOST_DEVICE__ __hip_bfloat162 __heq2(const __hip_bfloat162 a, const __hip_bfloat162 b) {
|
|
928
|
-
return __hip_bfloat162{{__heq(a.x, b.x) ? HIPRT_ONE_BF16 : HIPRT_ZERO_BF16},
|
|
929
|
-
{__heq(a.y, b.y) ? HIPRT_ONE_BF16 : HIPRT_ZERO_BF16}};
|
|
930
|
-
}
|
|
931
|
-
|
|
932
|
-
/**
|
|
933
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_COMP
|
|
934
|
-
* \brief Check for a >= b, returns 1.0 if greater than equal, otherwise 0.0
|
|
935
|
-
*/
|
|
936
|
-
__HOST_DEVICE__ __hip_bfloat162 __hge2(const __hip_bfloat162 a, const __hip_bfloat162 b) {
|
|
937
|
-
return __hip_bfloat162{{__hge(a.x, b.x) ? HIPRT_ONE_BF16 : HIPRT_ZERO_BF16},
|
|
938
|
-
{__hge(a.y, b.y) ? HIPRT_ONE_BF16 : HIPRT_ZERO_BF16}};
|
|
939
|
-
}
|
|
940
|
-
|
|
941
|
-
/**
|
|
942
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_COMP
|
|
943
|
-
* \brief Check for a > b, returns 1.0 if greater than equal, otherwise 0.0
|
|
944
|
-
*/
|
|
945
|
-
__HOST_DEVICE__ __hip_bfloat162 __hgt2(const __hip_bfloat162 a, const __hip_bfloat162 b) {
|
|
946
|
-
return __hip_bfloat162{{__hgt(a.x, b.x) ? HIPRT_ONE_BF16 : HIPRT_ZERO_BF16},
|
|
947
|
-
{__hgt(a.y, b.y) ? HIPRT_ONE_BF16 : HIPRT_ONE_BF16}};
|
|
948
|
-
}
|
|
949
|
-
|
|
950
|
-
/**
|
|
951
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_COMP
|
|
952
|
-
* \brief Check for a is NaN, returns 1.0 if NaN, otherwise 0.0
|
|
953
|
-
*/
|
|
954
|
-
__HOST_DEVICE__ __hip_bfloat162 __hisnan2(const __hip_bfloat162 a) {
|
|
955
|
-
return __hip_bfloat162{{__hisnan(a.x) ? HIPRT_ONE_BF16 : HIPRT_ZERO_BF16},
|
|
956
|
-
{__hisnan(a.y) ? HIPRT_ONE_BF16 : HIPRT_ONE_BF16}};
|
|
957
|
-
}
|
|
958
|
-
|
|
959
|
-
/**
|
|
960
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_COMP
|
|
961
|
-
* \brief Check for a <= b, returns 1.0 if greater than equal, otherwise 0.0
|
|
962
|
-
*/
|
|
963
|
-
__HOST_DEVICE__ __hip_bfloat162 __hle2(const __hip_bfloat162 a, const __hip_bfloat162 b) {
|
|
964
|
-
return __hip_bfloat162{{__hle(a.x, b.x) ? HIPRT_ONE_BF16 : HIPRT_ZERO_BF16},
|
|
965
|
-
{__hle(a.y, b.y) ? HIPRT_ONE_BF16 : HIPRT_ZERO_BF16}};
|
|
966
|
-
}
|
|
967
|
-
|
|
968
|
-
/**
|
|
969
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_COMP
|
|
970
|
-
* \brief Check for a < b, returns 1.0 if greater than equal, otherwise 0.0
|
|
971
|
-
*/
|
|
972
|
-
__HOST_DEVICE__ __hip_bfloat162 __hlt2(const __hip_bfloat162 a, const __hip_bfloat162 b) {
|
|
973
|
-
return __hip_bfloat162{{__hlt(a.x, b.x) ? HIPRT_ONE_BF16 : HIPRT_ZERO_BF16},
|
|
974
|
-
{__hlt(a.y, b.y) ? HIPRT_ONE_BF16 : HIPRT_ZERO_BF16}};
|
|
975
|
-
}
|
|
976
|
-
|
|
977
|
-
/**
|
|
978
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_COMP
|
|
979
|
-
* \brief Returns max of two elements
|
|
980
|
-
*/
|
|
981
|
-
__HOST_DEVICE__ __hip_bfloat162 __hmax2(const __hip_bfloat162 a, const __hip_bfloat162 b) {
|
|
982
|
-
return __hip_bfloat162{__hmax(a.x, b.x), __hmax(a.y, b.y)};
|
|
983
|
-
}
|
|
984
|
-
|
|
985
|
-
/**
|
|
986
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_COMP
|
|
987
|
-
* \brief Returns min of two elements
|
|
988
|
-
*/
|
|
989
|
-
__HOST_DEVICE__ __hip_bfloat162 __hmin2(const __hip_bfloat162 a, const __hip_bfloat162 b) {
|
|
990
|
-
return __hip_bfloat162{__hmin(a.x, b.x), __hmin(a.y, b.y)};
|
|
991
|
-
}
|
|
992
|
-
|
|
993
|
-
/**
|
|
994
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_COMP
|
|
995
|
-
* \brief Checks for not equal to
|
|
996
|
-
*/
|
|
997
|
-
__HOST_DEVICE__ __hip_bfloat162 __hne2(const __hip_bfloat162 a, const __hip_bfloat162 b) {
|
|
998
|
-
return __hip_bfloat162{{__hne(a.x, b.x) ? HIPRT_ONE_BF16 : HIPRT_ZERO_BF16},
|
|
999
|
-
{__hne(a.y, b.y) ? HIPRT_ONE_BF16 : HIPRT_ZERO_BF16}};
|
|
1000
|
-
}
|
|
1001
|
-
|
|
1002
|
-
/**
|
|
1003
|
-
* \ingroup HIP_INTRINSIC_BFLOAT16_COMP
|
|
1004
|
-
* \brief Operator to perform an equal compare on two __hip_bfloat16 numbers
|
|
1005
|
-
*/
|
|
1006
|
-
__HOST_DEVICE__ bool operator==(const __hip_bfloat16& l, const __hip_bfloat16& r) {
|
|
1007
|
-
return __heq(l, r);
|
|
1008
|
-
}
|
|
1009
|
-
|
|
1010
|
-
/**
|
|
1011
|
-
* \ingroup HIP_INTRINSIC_BFLOAT16_COMP
|
|
1012
|
-
* \brief Operator to perform a not equal on two __hip_bfloat16 numbers
|
|
1013
|
-
*/
|
|
1014
|
-
__HOST_DEVICE__ bool operator!=(const __hip_bfloat16& l, const __hip_bfloat16& r) {
|
|
1015
|
-
return __hne(l, r);
|
|
1016
|
-
}
|
|
1017
|
-
|
|
1018
|
-
/**
|
|
1019
|
-
* \ingroup HIP_INTRINSIC_BFLOAT16_COMP
|
|
1020
|
-
* \brief Operator to perform a less than on two __hip_bfloat16 numbers
|
|
1021
|
-
*/
|
|
1022
|
-
__HOST_DEVICE__ bool operator<(const __hip_bfloat16& l, const __hip_bfloat16& r) {
|
|
1023
|
-
return __hlt(l, r);
|
|
1024
|
-
}
|
|
1025
|
-
|
|
1026
|
-
/**
|
|
1027
|
-
* \ingroup HIP_INTRINSIC_BFLOAT16_COMP
|
|
1028
|
-
* \brief Operator to perform a less than equal on two __hip_bfloat16 numbers
|
|
1029
|
-
*/
|
|
1030
|
-
__HOST_DEVICE__ bool operator<=(const __hip_bfloat16& l, const __hip_bfloat16& r) {
|
|
1031
|
-
return __hle(l, r);
|
|
1032
|
-
}
|
|
1033
|
-
|
|
1034
|
-
/**
|
|
1035
|
-
* \ingroup HIP_INTRINSIC_BFLOAT16_COMP
|
|
1036
|
-
* \brief Operator to perform a greater than on two __hip_bfloat16 numbers
|
|
1037
|
-
*/
|
|
1038
|
-
__HOST_DEVICE__ bool operator>(const __hip_bfloat16& l, const __hip_bfloat16& r) {
|
|
1039
|
-
return __hgt(l, r);
|
|
1040
|
-
}
|
|
1041
|
-
|
|
1042
|
-
/**
|
|
1043
|
-
* \ingroup HIP_INTRINSIC_BFLOAT16_COMP
|
|
1044
|
-
* \brief Operator to perform a greater than equal on two __hip_bfloat16 numbers
|
|
1045
|
-
*/
|
|
1046
|
-
__HOST_DEVICE__ bool operator>=(const __hip_bfloat16& l, const __hip_bfloat16& r) {
|
|
1047
|
-
return __hge(l, r);
|
|
1048
|
-
}
|
|
1049
|
-
|
|
1050
|
-
/**
|
|
1051
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_COMP
|
|
1052
|
-
* \brief Operator to perform an equal compare on two __hip_bfloat16 numbers
|
|
1053
|
-
*/
|
|
1054
|
-
__HOST_DEVICE__ bool operator==(const __hip_bfloat162& l, const __hip_bfloat162& r) {
|
|
1055
|
-
return __heq(l.x, r.x) && __heq(l.y, r.y);
|
|
1056
|
-
}
|
|
1057
|
-
|
|
1058
|
-
/**
|
|
1059
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_COMP
|
|
1060
|
-
* \brief Operator to perform a not equal on two __hip_bfloat16 numbers
|
|
1061
|
-
*/
|
|
1062
|
-
__HOST_DEVICE__ bool operator!=(const __hip_bfloat162& l, const __hip_bfloat162& r) {
|
|
1063
|
-
return __hne(l.x, r.x) || __hne(l.y, r.y);
|
|
1064
|
-
}
|
|
1065
|
-
|
|
1066
|
-
/**
|
|
1067
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_COMP
|
|
1068
|
-
* \brief Operator to perform a less than on two __hip_bfloat16 numbers
|
|
1069
|
-
*/
|
|
1070
|
-
__HOST_DEVICE__ bool operator<(const __hip_bfloat162& l, const __hip_bfloat162& r) {
|
|
1071
|
-
return __hlt(l.x, r.x) && __hlt(l.y, r.y);
|
|
1072
|
-
}
|
|
1073
|
-
|
|
1074
|
-
/**
|
|
1075
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_COMP
|
|
1076
|
-
* \brief Operator to perform a less than equal on two __hip_bfloat16 numbers
|
|
1077
|
-
*/
|
|
1078
|
-
__HOST_DEVICE__ bool operator<=(const __hip_bfloat162& l, const __hip_bfloat162& r) {
|
|
1079
|
-
return __hle(l.x, r.x) && __hle(l.y, r.y);
|
|
1080
|
-
}
|
|
1081
|
-
|
|
1082
|
-
/**
|
|
1083
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_COMP
|
|
1084
|
-
* \brief Operator to perform a greater than on two __hip_bfloat16 numbers
|
|
1085
|
-
*/
|
|
1086
|
-
__HOST_DEVICE__ bool operator>(const __hip_bfloat162& l, const __hip_bfloat162& r) {
|
|
1087
|
-
return __hgt(l.x, r.x) && __hgt(l.y, r.y);
|
|
1088
|
-
}
|
|
1089
|
-
|
|
1090
|
-
/**
|
|
1091
|
-
* \ingroup HIP_INTRINSIC_BFLOAT16_COMP
|
|
1092
|
-
* \brief Operator to perform a greater than equal on two __hip_bfloat16 numbers
|
|
1093
|
-
*/
|
|
1094
|
-
__HOST_DEVICE__ bool operator>=(const __hip_bfloat162& l, const __hip_bfloat162& r) {
|
|
1095
|
-
return __hge(l.x, r.x) && __hge(l.y, r.y);
|
|
1096
|
-
}
|
|
1097
|
-
|
|
1098
|
-
/**
|
|
1099
|
-
* \ingroup HIP_INTRINSIC_BFLOAT16_MATH
|
|
1100
|
-
* \brief Calculate ceil of bfloat16
|
|
1101
|
-
*/
|
|
1102
|
-
__device__ __hip_bfloat16 hceil(const __hip_bfloat16 h) {
|
|
1103
|
-
return __float2bfloat16(__ocml_ceil_f32(__bfloat162float(h)));
|
|
1104
|
-
}
|
|
1105
|
-
|
|
1106
|
-
/**
|
|
1107
|
-
* \ingroup HIP_INTRINSIC_BFLOAT16_MATH
|
|
1108
|
-
* \brief Calculate cosine of bfloat16
|
|
1109
|
-
*/
|
|
1110
|
-
__device__ __hip_bfloat16 hcos(const __hip_bfloat16 h) {
|
|
1111
|
-
return __float2bfloat16(__ocml_cos_f32(__bfloat162float(h)));
|
|
1112
|
-
}
|
|
1113
|
-
|
|
1114
|
-
/**
|
|
1115
|
-
* \ingroup HIP_INTRINSIC_BFLOAT16_MATH
|
|
1116
|
-
* \brief Calculate exponential of bfloat16
|
|
1117
|
-
*/
|
|
1118
|
-
__device__ __hip_bfloat16 hexp(const __hip_bfloat16 h) {
|
|
1119
|
-
return __float2bfloat16(__ocml_exp_f32(__bfloat162float(h)));
|
|
1120
|
-
}
|
|
1121
|
-
|
|
1122
|
-
/**
|
|
1123
|
-
* \ingroup HIP_INTRINSIC_BFLOAT16_MATH
|
|
1124
|
-
* \brief Calculate exponential 10 of bfloat16
|
|
1125
|
-
*/
|
|
1126
|
-
__device__ __hip_bfloat16 hexp10(const __hip_bfloat16 h) {
|
|
1127
|
-
return __float2bfloat16(__ocml_exp10_f32(__bfloat162float(h)));
|
|
1128
|
-
}
|
|
1129
|
-
|
|
1130
|
-
/**
|
|
1131
|
-
* \ingroup HIP_INTRINSIC_BFLOAT16_MATH
|
|
1132
|
-
* \brief Calculate exponential 2 of bfloat16
|
|
1133
|
-
*/
|
|
1134
|
-
__device__ __hip_bfloat16 hexp2(const __hip_bfloat16 h) {
|
|
1135
|
-
return __float2bfloat16(__ocml_exp2_f32(__bfloat162float(h)));
|
|
1136
|
-
}
|
|
1137
|
-
|
|
1138
|
-
/**
|
|
1139
|
-
* \ingroup HIP_INTRINSIC_BFLOAT16_MATH
|
|
1140
|
-
* \brief Calculate floor of bfloat16
|
|
1141
|
-
*/
|
|
1142
|
-
__device__ __hip_bfloat16 hfloor(const __hip_bfloat16 h) {
|
|
1143
|
-
return __float2bfloat16(__ocml_floor_f32(__bfloat162float(h)));
|
|
1144
|
-
}
|
|
1145
|
-
|
|
1146
|
-
/**
|
|
1147
|
-
* \ingroup HIP_INTRINSIC_BFLOAT16_MATH
|
|
1148
|
-
* \brief Calculate natural log of bfloat16
|
|
1149
|
-
*/
|
|
1150
|
-
__device__ __hip_bfloat16 hlog(const __hip_bfloat16 h) {
|
|
1151
|
-
return __float2bfloat16(__ocml_log_f32(__bfloat162float(h)));
|
|
1152
|
-
}
|
|
1153
|
-
|
|
1154
|
-
/**
|
|
1155
|
-
* \ingroup HIP_INTRINSIC_BFLOAT16_MATH
|
|
1156
|
-
* \brief Calculate log 10 of bfloat16
|
|
1157
|
-
*/
|
|
1158
|
-
__device__ __hip_bfloat16 hlog10(const __hip_bfloat16 h) {
|
|
1159
|
-
return __float2bfloat16(__ocml_log10_f32(__bfloat162float(h)));
|
|
1160
|
-
}
|
|
1161
|
-
|
|
1162
|
-
/**
|
|
1163
|
-
* \ingroup HIP_INTRINSIC_BFLOAT16_MATH
|
|
1164
|
-
* \brief Calculate log 2 of bfloat16
|
|
1165
|
-
*/
|
|
1166
|
-
__device__ __hip_bfloat16 hlog2(const __hip_bfloat16 h) {
|
|
1167
|
-
return __float2bfloat16(__ocml_log2_f32(__bfloat162float(h)));
|
|
1168
|
-
}
|
|
1169
|
-
|
|
1170
|
-
/**
|
|
1171
|
-
* \ingroup HIP_INTRINSIC_BFLOAT16_MATH
|
|
1172
|
-
* \brief Calculate reciprocal
|
|
1173
|
-
*/
|
|
1174
|
-
__device__ __hip_bfloat16 hrcp(const __hip_bfloat16 h) {
|
|
1175
|
-
return __float2bfloat16(1.0f / (__bfloat162float(h)));
|
|
1176
|
-
}
|
|
1177
|
-
|
|
1178
|
-
/**
|
|
1179
|
-
* \ingroup HIP_INTRINSIC_BFLOAT16_MATH
|
|
1180
|
-
* \brief Round to nearest int
|
|
1181
|
-
*/
|
|
1182
|
-
__device__ __hip_bfloat16 hrint(const __hip_bfloat16 h) {
|
|
1183
|
-
return __float2bfloat16(__ocml_rint_f32(__bfloat162float(h)));
|
|
1184
|
-
}
|
|
1185
|
-
|
|
1186
|
-
/**
|
|
1187
|
-
* \ingroup HIP_INTRINSIC_BFLOAT16_MATH
|
|
1188
|
-
* \brief Reciprocal square root
|
|
1189
|
-
*/
|
|
1190
|
-
__device__ __hip_bfloat16 hrsqrt(const __hip_bfloat16 h) {
|
|
1191
|
-
return __float2bfloat16(__ocml_rsqrt_f32(__bfloat162float(h)));
|
|
1192
|
-
}
|
|
1193
|
-
|
|
1194
|
-
/**
|
|
1195
|
-
* \ingroup HIP_INTRINSIC_BFLOAT16_MATH
|
|
1196
|
-
* \brief Calculate sin of bfloat16
|
|
1197
|
-
*/
|
|
1198
|
-
__device__ __hip_bfloat16 hsin(const __hip_bfloat16 h) {
|
|
1199
|
-
return __float2bfloat16(__ocml_sin_f32(__bfloat162float(h)));
|
|
1200
|
-
}
|
|
1201
|
-
|
|
1202
|
-
/**
|
|
1203
|
-
* \ingroup HIP_INTRINSIC_BFLOAT16_MATH
|
|
1204
|
-
* \brief Calculate sqrt of bfloat16
|
|
1205
|
-
*/
|
|
1206
|
-
__device__ __hip_bfloat16 hsqrt(const __hip_bfloat16 h) {
|
|
1207
|
-
return __float2bfloat16(__ocml_sqrt_f32(__bfloat162float(h)));
|
|
1208
|
-
}
|
|
1209
|
-
|
|
1210
|
-
/**
|
|
1211
|
-
* \ingroup HIP_INTRINSIC_BFLOAT16_MATH
|
|
1212
|
-
* \brief Calculate truncate of bfloat16
|
|
1213
|
-
*/
|
|
1214
|
-
__device__ __hip_bfloat16 htrunc(const __hip_bfloat16 h) {
|
|
1215
|
-
return __float2bfloat16(__ocml_trunc_f32(__bfloat162float(h)));
|
|
1216
|
-
}
|
|
1217
|
-
|
|
1218
|
-
/**
|
|
1219
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_MATH
|
|
1220
|
-
* \brief Calculate ceil of bfloat162
|
|
1221
|
-
*/
|
|
1222
|
-
__device__ __hip_bfloat162 h2ceil(const __hip_bfloat162 h) {
|
|
1223
|
-
return __hip_bfloat162{hceil(h.x), hceil(h.y)};
|
|
1224
|
-
}
|
|
1225
|
-
|
|
1226
|
-
/**
|
|
1227
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_MATH
|
|
1228
|
-
* \brief Calculate cosine of bfloat162
|
|
1229
|
-
*/
|
|
1230
|
-
__device__ __hip_bfloat162 h2cos(const __hip_bfloat162 h) {
|
|
1231
|
-
return __hip_bfloat162{hcos(h.x), hcos(h.y)};
|
|
1232
|
-
}
|
|
1233
|
-
|
|
1234
|
-
/**
|
|
1235
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_MATH
|
|
1236
|
-
* \brief Calculate exponential of bfloat162
|
|
1237
|
-
*/
|
|
1238
|
-
__device__ __hip_bfloat162 h2exp(const __hip_bfloat162 h) {
|
|
1239
|
-
return __hip_bfloat162{hexp(h.x), hexp(h.y)};
|
|
1240
|
-
}
|
|
1241
|
-
|
|
1242
|
-
/**
|
|
1243
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_MATH
|
|
1244
|
-
* \brief Calculate exponential 10 of bfloat162
|
|
1245
|
-
*/
|
|
1246
|
-
__device__ __hip_bfloat162 h2exp10(const __hip_bfloat162 h) {
|
|
1247
|
-
return __hip_bfloat162{hexp10(h.x), hexp10(h.y)};
|
|
1248
|
-
}
|
|
1249
|
-
|
|
1250
|
-
/**
|
|
1251
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_MATH
|
|
1252
|
-
* \brief Calculate exponential 2 of bfloat162
|
|
1253
|
-
*/
|
|
1254
|
-
__device__ __hip_bfloat162 h2exp2(const __hip_bfloat162 h) {
|
|
1255
|
-
return __hip_bfloat162{hexp2(h.x), hexp2(h.y)};
|
|
1256
|
-
}
|
|
1257
|
-
|
|
1258
|
-
/**
|
|
1259
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_MATH
|
|
1260
|
-
* \brief Calculate floor of bfloat162
|
|
1261
|
-
*/
|
|
1262
|
-
__device__ __hip_bfloat162 h2floor(const __hip_bfloat162 h) {
|
|
1263
|
-
return __hip_bfloat162{hfloor(h.x), hfloor(h.y)};
|
|
1264
|
-
}
|
|
1265
|
-
|
|
1266
|
-
/**
|
|
1267
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_MATH
|
|
1268
|
-
* \brief Calculate natural log of bfloat162
|
|
1269
|
-
*/
|
|
1270
|
-
__device__ __hip_bfloat162 h2log(const __hip_bfloat162 h) {
|
|
1271
|
-
return __hip_bfloat162{hlog(h.x), hlog(h.y)};
|
|
1272
|
-
}
|
|
1273
|
-
|
|
1274
|
-
/**
|
|
1275
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_MATH
|
|
1276
|
-
* \brief Calculate log 10 of bfloat162
|
|
1277
|
-
*/
|
|
1278
|
-
__device__ __hip_bfloat162 h2log10(const __hip_bfloat162 h) {
|
|
1279
|
-
return __hip_bfloat162{hlog10(h.x), hlog10(h.y)};
|
|
1280
|
-
}
|
|
1281
|
-
|
|
1282
|
-
/**
|
|
1283
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_MATH
|
|
1284
|
-
* \brief Calculate log 2 of bfloat162
|
|
1285
|
-
*/
|
|
1286
|
-
__device__ __hip_bfloat162 h2log2(const __hip_bfloat162 h) {
|
|
1287
|
-
return __hip_bfloat162{hlog2(h.x), hlog2(h.y)};
|
|
1288
|
-
}
|
|
1289
|
-
|
|
1290
|
-
/**
|
|
1291
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_MATH
|
|
1292
|
-
* \brief Calculate vector reciprocal
|
|
1293
|
-
*/
|
|
1294
|
-
__device__ __hip_bfloat162 h2rcp(const __hip_bfloat162 h) {
|
|
1295
|
-
return __hip_bfloat162{hrcp(h.x), hrcp(h.y)};
|
|
1296
|
-
}
|
|
1297
|
-
|
|
1298
|
-
/**
|
|
1299
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_MATH
|
|
1300
|
-
* \brief Calculate vector round to nearest int
|
|
1301
|
-
*/
|
|
1302
|
-
__device__ __hip_bfloat162 h2rint(const __hip_bfloat162 h) {
|
|
1303
|
-
return __hip_bfloat162{hrint(h.x), hrint(h.y)};
|
|
1304
|
-
}
|
|
1305
|
-
|
|
1306
|
-
/**
|
|
1307
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_MATH
|
|
1308
|
-
* \brief Calculate vector reciprocal square root
|
|
1309
|
-
*/
|
|
1310
|
-
__device__ __hip_bfloat162 h2rsqrt(const __hip_bfloat162 h) {
|
|
1311
|
-
return __hip_bfloat162{hrsqrt(h.x), hrsqrt(h.y)};
|
|
1312
|
-
}
|
|
1313
|
-
|
|
1314
|
-
/**
|
|
1315
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_MATH
|
|
1316
|
-
* \brief Calculate sin of bfloat162
|
|
1317
|
-
*/
|
|
1318
|
-
__device__ __hip_bfloat162 h2sin(const __hip_bfloat162 h) {
|
|
1319
|
-
return __hip_bfloat162{hsin(h.x), hsin(h.y)};
|
|
1320
|
-
}
|
|
1321
|
-
|
|
1322
|
-
/**
|
|
1323
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_MATH
|
|
1324
|
-
* \brief Calculate sqrt of bfloat162
|
|
1325
|
-
*/
|
|
1326
|
-
__device__ __hip_bfloat162 h2sqrt(const __hip_bfloat162 h) {
|
|
1327
|
-
return __hip_bfloat162{hsqrt(h.x), hsqrt(h.y)};
|
|
1328
|
-
}
|
|
1329
|
-
|
|
1330
|
-
/**
|
|
1331
|
-
* \ingroup HIP_INTRINSIC_BFLOAT162_MATH
|
|
1332
|
-
* \brief Calculate truncate of bfloat162
|
|
1333
|
-
*/
|
|
1334
|
-
__device__ __hip_bfloat162 h2trunc(const __hip_bfloat162 h) {
|
|
1335
|
-
return __hip_bfloat162{htrunc(h.x), htrunc(h.y)};
|
|
1336
|
-
}
|
|
1337
|
-
#endif
|