/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-composable-kernel/checkouts/develop/include/ck/utility/numeric_limits.hpp Source File

/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-composable-kernel/checkouts/develop/include/ck/utility/numeric_limits.hpp Source File#

Composable Kernel: /home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-composable-kernel/checkouts/develop/include/ck/utility/numeric_limits.hpp Source File
numeric_limits.hpp
Go to the documentation of this file.
1 // Copyright (c) Advanced Micro Devices, Inc., or its affiliates.
2 // SPDX-License-Identifier: MIT
3 
4 #pragma once
6 
7 namespace ck {
8 
9 #if defined(__HIPCC_RTC__) || defined(CK_CODE_GEN_RTC)
10 template <typename T>
11 struct NumericLimits;
12 
13 template <>
14 struct NumericLimits<int32_t>
15 {
16  __host__ __device__ static constexpr int32_t Lowest() noexcept { return -2147483647 - 1; }
17 
18  __host__ __device__ static constexpr int32_t Min() noexcept { return -2147483647 - 1; }
19 
20  __host__ __device__ static constexpr int32_t Max() noexcept { return 2147483647; }
21 
22  __host__ __device__ static constexpr int32_t Infinity() noexcept { return 0; }
23 
24  __host__ __device__ static constexpr int32_t QuietNaN() { return 0; }
25 };
26 template <>
27 struct NumericLimits<int16_t>
28 {
29  __host__ __device__ static constexpr int16_t Lowest() noexcept { return -32768; }
30 
31  __host__ __device__ static constexpr int16_t Min() noexcept { return -32768; }
32 
33  __host__ __device__ static constexpr int16_t Max() noexcept { return 32767; }
34 
35  __host__ __device__ static constexpr int16_t Infinity() noexcept { return 0; }
36 
37  __host__ __device__ static constexpr int16_t QuietNaN() { return 0; }
38 };
39 
40 template <>
41 struct NumericLimits<int8_t>
42 {
43  __host__ __device__ static constexpr int8_t Lowest() noexcept { return -128; }
44 
45  __host__ __device__ static constexpr int8_t Min() noexcept { return -128; }
46 
47  __host__ __device__ static constexpr int8_t Max() noexcept { return 127; }
48 
49  __host__ __device__ static constexpr int8_t Infinity() noexcept { return 0; }
50 
51  __host__ __device__ static constexpr int8_t QuietNaN() { return 0; }
52 };
53 
54 template <>
55 struct NumericLimits<uint32_t>
56 {
57  __host__ __device__ static constexpr uint32_t Lowest() noexcept { return 0; }
58 
59  __host__ __device__ static constexpr uint32_t Min() noexcept { return 0; }
60 
61  __host__ __device__ static constexpr uint32_t Max() noexcept { return 4294967295U; }
62 
63  __host__ __device__ static constexpr uint32_t Infinity() noexcept { return 0; }
64 
65  __host__ __device__ static constexpr uint32_t QuietNaN() { return 0; }
66 };
67 
68 template <>
69 struct NumericLimits<uint16_t>
70 {
71  __host__ __device__ static constexpr uint16_t Lowest() noexcept { return 0; }
72 
73  __host__ __device__ static constexpr uint16_t Min() noexcept { return 0; }
74 
75  __host__ __device__ static constexpr uint16_t Max() noexcept { return 65535U; }
76 
77  __host__ __device__ static constexpr uint16_t Infinity() noexcept { return 0; }
78 
79  __host__ __device__ static constexpr uint16_t QuietNaN() { return 0; }
80 };
81 
82 template <>
83 struct NumericLimits<float>
84 {
85  static constexpr unsigned int binary_min = 0x00800000;
86  static constexpr unsigned int binary_max = 0x7F7FFFFF;
87  static constexpr unsigned int binary_lowest = 0xFF7FFFFF;
88  static constexpr unsigned int binary_qnan = 0xFFC00001;
89  static constexpr unsigned int binary_inf = 0x7F800000;
90 
91  __host__ __device__ static constexpr float Min() { return bit_cast<float>(binary_min); }
92 
93  __host__ __device__ static constexpr float Max() { return bit_cast<float>(binary_max); }
94 
95  __host__ __device__ static constexpr float Lowest() { return bit_cast<float>(binary_lowest); }
96 
97  __host__ __device__ static constexpr float QuietNaN() { return bit_cast<float>(binary_qnan); }
98 
99  __host__ __device__ static constexpr float Infinity() { return bit_cast<float>(binary_inf); }
100 };
101 
102 template <>
103 struct NumericLimits<half_t>
104 {
105  static constexpr unsigned short binary_min = 0x0400;
106  static constexpr unsigned short binary_max = 0x7BFF;
107  static constexpr unsigned short binary_lowest = 0xFBFF;
108  static constexpr unsigned short binary_qnan = 0x7FFF;
109 
110  __host__ __device__ static constexpr half_t Min() { return bit_cast<half_t>(binary_min); }
111 
112  __host__ __device__ static constexpr half_t Max() { return bit_cast<half_t>(binary_max); }
113 
114  __host__ __device__ static constexpr half_t Lowest() { return bit_cast<half_t>(binary_lowest); }
115 
116  __host__ __device__ static constexpr half_t QuietNaN() { return bit_cast<half_t>(binary_qnan); }
117 };
118 
119 #ifdef CK_EXPERIMENTAL_BIT_INT_EXTENSION_INT4
120 template <>
121 struct NumericLimits<int4_t>
122 {
123  __host__ __device__ static constexpr int4_t Min() { return int4_t(-8); }
124 
125  __host__ __device__ static constexpr int4_t Max() { return int4_t(7); }
126 
127  __host__ __device__ static constexpr int4_t Lowest() { return int4_t(-8); }
128 };
129 #endif // CK_EXPERIMENTAL_BIT_INT_EXTENSION_INT4
130 
131 template <>
132 struct NumericLimits<f8_fnuz_t>
133 {
134  // negative zero nan mode with exp bias = 8
135  static constexpr uint8_t binary_min = 0x08; // 0b00001000
136  static constexpr uint8_t binary_max = 0x7F; // 0b01111111
137  static constexpr uint8_t binary_lowest = 0xFF; // 0b11111111
138  static constexpr uint8_t binary_qnan = 0x80; // 0b10000000
139  // ieee mode with exp bias = 7
140  // static constexpr uint8_t binary_min = 0x08; // 0b00001000
141  // static constexpr uint8_t binary_max = 0x77; // 0b01110111
142  // static constexpr uint8_t binary_lowest = 0xF7; // 0b11110111
143  // static constexpr uint8_t binary_qnan = 0x79; // any sign, exp=1111, mant!=0
144 
145  __host__ __device__ static constexpr f8_fnuz_t Min() { return f8_fnuz_t(binary_min); }
146 
147  __host__ __device__ static constexpr f8_fnuz_t Max() { return f8_fnuz_t(binary_max); }
148 
149  __host__ __device__ static constexpr f8_fnuz_t Lowest() { return f8_fnuz_t(binary_lowest); }
150 
151  __host__ __device__ static constexpr f8_fnuz_t QuietNaN() { return f8_fnuz_t(binary_qnan); }
152 };
153 
154 template <>
155 struct NumericLimits<bf8_fnuz_t>
156 {
157  // negative zero nan mode with exp bias = 16
158  static constexpr uint8_t binary_min = 0x04; // 0b00000100
159  static constexpr uint8_t binary_max = 0x7F; // 0b01111111
160  static constexpr uint8_t binary_lowest = 0xFF; // 0b11111111
161  static constexpr uint8_t binary_qnan = 0x80; // 0b10000000
162  // ieee mode with exp bias = 15
163  // static constexpr uint8_t binary_min = 0x04; // 0b00000100
164  // static constexpr uint8_t binary_max = 0x7B; // 0b01111011
165  // static constexpr uint8_t binary_lowest = 0xFB; // 0b11111011
166  // static constexpr uint8_t binary_qnan = 0x79; // any sign, exp=1111, mant!=
167 
168  __host__ __device__ static constexpr bf8_fnuz_t Min() { return bf8_fnuz_t(binary_min); }
169 
170  __host__ __device__ static constexpr bf8_fnuz_t Max() { return bf8_fnuz_t(binary_max); }
171 
172  __host__ __device__ static constexpr bf8_fnuz_t Lowest() { return bf8_fnuz_t(binary_lowest); }
173 
174  __host__ __device__ static constexpr bf8_fnuz_t QuietNaN() { return bf8_fnuz_t(binary_qnan); }
175 };
176 
177 template <>
178 struct NumericLimits<f8_ocp_t>
179 {
180  static constexpr uint8_t binary_min = 0x08; // 0b00001000 = 2^-6
181  static constexpr uint8_t binary_max = 0x7E; // 0b01111110 = 448
182  static constexpr uint8_t binary_lowest = 0xFE; // 0b11111110 = -448
183  static constexpr uint8_t binary_qnan = 0x7F; // 0b01111111
184 
185  __host__ __device__ static constexpr f8_ocp_t Min() { return bit_cast<f8_ocp_t>(binary_min); }
186 
187  __host__ __device__ static constexpr f8_ocp_t Max() { return bit_cast<f8_ocp_t>(binary_max); }
188 
189  __host__ __device__ static constexpr f8_ocp_t Lowest()
190  {
191  return bit_cast<f8_ocp_t>(binary_lowest);
192  }
193 
194  __host__ __device__ static constexpr f8_ocp_t QuietNaN()
195  {
196  return bit_cast<f8_ocp_t>(binary_qnan);
197  }
198 };
199 
200 template <>
201 struct NumericLimits<bf8_ocp_t>
202 {
203  static constexpr uint8_t binary_min = 0x04; // 0b00000100 = 2^-14
204  static constexpr uint8_t binary_max = 0x7B; // 0b01111011 = 57344
205  static constexpr uint8_t binary_lowest = 0xFB; // 0b11111011 = -57344
206  static constexpr uint8_t binary_qnan = 0x7D; // 0b01111101
207 
208  __host__ __device__ static constexpr bf8_ocp_t Min() { return bit_cast<bf8_ocp_t>(binary_min); }
209 
210  __host__ __device__ static constexpr bf8_ocp_t Max() { return bit_cast<bf8_ocp_t>(binary_max); }
211 
212  __host__ __device__ static constexpr bf8_ocp_t Lowest()
213  {
214  return bit_cast<bf8_ocp_t>(binary_lowest);
215  }
216 
217  __host__ __device__ static constexpr bf8_ocp_t QuietNaN()
218  {
219  return bit_cast<bf8_ocp_t>(binary_qnan);
220  }
221 };
222 
223 template <>
224 struct NumericLimits<f4_t>
225 {
226  static constexpr uint8_t binary_min_normal = 0x2; // 0b0010
227  static constexpr uint8_t binary_max_normal = 0x7; // 0b0111
228  static constexpr uint8_t binary_lowest_normal = 0xF; // 0b1111
229  static constexpr uint8_t binary_min_subnorm = 0x1; // 0b0001
230  static constexpr uint8_t binary_max_subnorm = 0x1; // 0b0001
231 
232  static constexpr float data_max_normal_number = 6;
233  static constexpr float data_min_subnormal_number = 0.5;
234 
235  __host__ __device__ static constexpr f4_t Min() { return f4_t(binary_min_normal); }
236  __host__ __device__ static constexpr f4_t Max() { return f4_t(binary_max_normal); }
237  __host__ __device__ static constexpr f4_t Lowest() { return f4_t(binary_lowest_normal); }
238  __host__ __device__ static constexpr f4_t MinSubnorm() { return f4_t(binary_min_subnorm); }
239  __host__ __device__ static constexpr f4_t MaxSubnorm() { return f4_t(binary_max_subnorm); }
240 
241  __host__ __device__ static constexpr float DataMaxNorm() { return data_max_normal_number; }
242  __host__ __device__ static constexpr float DataMinSubnorm()
243  {
244  return data_min_subnormal_number;
245  }
246 };
247 
248 template <>
249 struct NumericLimits<f6_t>
250 {
251  static constexpr uint8_t binary_min_normal = 0x08; // 0b001000
252  static constexpr uint8_t binary_max_normal = 0x1F; // 0b011111
253  static constexpr uint8_t binary_lowest_normal = 0x3F; // 0b111111
254  static constexpr uint8_t binary_min_subnorm = 0x01; // 0b000001
255  static constexpr uint8_t binary_max_subnorm = 0x07; // 0b000111
256 
257  static constexpr float data_max_normal_number = 7.5;
258  static constexpr float data_min_subnormal_number = 0.125;
259 
260  __host__ __device__ static constexpr f6_t Min() { return f6_t(binary_min_normal & 0b111111); }
261  __host__ __device__ static constexpr f6_t Max() { return f6_t(binary_max_normal & 0b111111); }
262  __host__ __device__ static constexpr f6_t Lowest()
263  {
264  return f6_t(binary_lowest_normal & 0b111111);
265  }
266  __host__ __device__ static constexpr f6_t MinSubnorm()
267  {
268  return f6_t(binary_min_subnorm & 0b111111);
269  }
270  __host__ __device__ static constexpr f6_t MaxSubnorm()
271  {
272  return f6_t(binary_max_subnorm & 0b111111);
273  }
274 
275  __host__ __device__ static constexpr float DataMaxNorm() { return data_max_normal_number; }
276  __host__ __device__ static constexpr float DataMinSubnorm()
277  {
278  return data_min_subnormal_number;
279  }
280 };
281 
282 template <>
283 struct NumericLimits<bf6_t>
284 {
285  static constexpr uint8_t binary_min_normal = 0x08; // 0b001000
286  static constexpr uint8_t binary_max_normal = 0x1F; // 0b011111
287  static constexpr uint8_t binary_lowest_normal = 0x3F; // 0b111111
288  static constexpr uint8_t binary_min_subnorm = 0x01; // 0b000001
289  static constexpr uint8_t binary_max_subnorm = 0x03; // 0b000011
290 
291  static constexpr float data_max_normal_number = 28;
292  static constexpr float data_min_subnormal_number = 0.0625;
293 
294  __host__ __device__ static constexpr bf6_t Min() { return bf6_t(binary_min_normal); }
295  __host__ __device__ static constexpr bf6_t Max() { return bf6_t(binary_max_normal); }
296  __host__ __device__ static constexpr bf6_t Lowest() { return bf6_t(binary_lowest_normal); }
297  __host__ __device__ static constexpr bf6_t MinSubnorm() { return bf6_t(binary_min_subnorm); }
298  __host__ __device__ static constexpr bf6_t MaxSubnorm() { return bf6_t(binary_max_subnorm); }
299 
300  __host__ __device__ static constexpr float DataMaxNorm() { return data_max_normal_number; }
301  __host__ __device__ static constexpr float DataMinSubnorm()
302  {
303  return data_min_subnormal_number;
304  }
305 };
306 
307 #else
308 template <typename T>
310 {
311  __host__ __device__ static constexpr T Min() { return std::numeric_limits<T>::min(); }
312  __host__ __device__ static constexpr T Max() { return std::numeric_limits<T>::max(); }
313  __host__ __device__ static constexpr T Lowest() { return std::numeric_limits<T>::lowest(); }
314  __host__ __device__ static constexpr T QuietNaN()
315  {
316  return std::numeric_limits<T>::quiet_NaN();
317  }
318  __host__ __device__ static constexpr T Infinity() { return std::numeric_limits<T>::infinity(); }
319 };
320 
321 template <>
323 {
324  static constexpr unsigned short binary_min = 0x0400;
325  static constexpr unsigned short binary_max = 0x7BFF;
326  static constexpr unsigned short binary_lowest = 0xFBFF;
327  static constexpr unsigned short binary_qnan = 0x7FFF;
328 
329  __host__ __device__ static constexpr half_t Min() { return bit_cast<half_t>(binary_min); }
330 
331  __host__ __device__ static constexpr half_t Max() { return bit_cast<half_t>(binary_max); }
332 
333  __host__ __device__ static constexpr half_t Lowest() { return bit_cast<half_t>(binary_lowest); }
334 
335  __host__ __device__ static constexpr half_t QuietNaN() { return bit_cast<half_t>(binary_qnan); }
336 };
337 
338 #ifdef CK_EXPERIMENTAL_BIT_INT_EXTENSION_INT4
339 template <>
340 struct NumericLimits<int4_t>
341 {
342  __host__ __device__ static constexpr int4_t Min() { return int4_t(-8); }
343 
344  __host__ __device__ static constexpr int4_t Max() { return int4_t(7); }
345 
346  __host__ __device__ static constexpr int4_t Lowest() { return int4_t(-8); }
347 };
348 #endif // CK_EXPERIMENTAL_BIT_INT_EXTENSION_INT4
349 
350 template <>
352 {
353  // negative zero nan mode with exp bias = 8
354  static constexpr uint8_t binary_min = 0x08; // 0b00001000
355  static constexpr uint8_t binary_max = 0x7F; // 0b01111111
356  static constexpr uint8_t binary_lowest = 0xFF; // 0b11111111
357  static constexpr uint8_t binary_qnan = 0x80; // 0b10000000
358  // ieee mode with exp bias = 7
359  // static constexpr uint8_t binary_min = 0x08; // 0b00001000
360  // static constexpr uint8_t binary_max = 0x77; // 0b01110111
361  // static constexpr uint8_t binary_lowest = 0xF7; // 0b11110111
362  // static constexpr uint8_t binary_qnan = 0x79; // any sign, exp=1111, mant!=0
363 
364  __host__ __device__ static constexpr f8_fnuz_t Min() { return f8_fnuz_t(binary_min); }
365 
366  __host__ __device__ static constexpr f8_fnuz_t Max() { return f8_fnuz_t(binary_max); }
367 
368  __host__ __device__ static constexpr f8_fnuz_t Lowest() { return f8_fnuz_t(binary_lowest); }
369 
370  __host__ __device__ static constexpr f8_fnuz_t QuietNaN() { return f8_fnuz_t(binary_qnan); }
371 };
372 
373 template <>
375 {
376  // negative zero nan mode with exp bias = 16
377  static constexpr uint8_t binary_min = 0x04; // 0b00000100
378  static constexpr uint8_t binary_max = 0x7F; // 0b01111111
379  static constexpr uint8_t binary_lowest = 0xFF; // 0b11111111
380  static constexpr uint8_t binary_qnan = 0x80; // 0b10000000
381  // ieee mode with exp bias = 15
382  // static constexpr uint8_t binary_min = 0x04; // 0b00000100
383  // static constexpr uint8_t binary_max = 0x7B; // 0b01111011
384  // static constexpr uint8_t binary_lowest = 0xFB; // 0b11111011
385  // static constexpr uint8_t binary_qnan = 0x79; // any sign, exp=1111, mant!=
386 
387  __host__ __device__ static constexpr bf8_fnuz_t Min() { return bf8_fnuz_t(binary_min); }
388 
389  __host__ __device__ static constexpr bf8_fnuz_t Max() { return bf8_fnuz_t(binary_max); }
390 
391  __host__ __device__ static constexpr bf8_fnuz_t Lowest() { return bf8_fnuz_t(binary_lowest); }
392 
393  __host__ __device__ static constexpr bf8_fnuz_t QuietNaN() { return bf8_fnuz_t(binary_qnan); }
394 };
395 
396 template <>
398 {
399  static constexpr uint8_t binary_min = 0x08; // 0b00001000 = 2^-6
400  static constexpr uint8_t binary_max = 0x7E; // 0b01111110 = 448
401  static constexpr uint8_t binary_lowest = 0xFE; // 0b11111110 = -448
402  static constexpr uint8_t binary_qnan = 0x7F; // 0b01111111
403 
404  __host__ __device__ static constexpr f8_ocp_t Min() { return bit_cast<f8_ocp_t>(binary_min); }
405 
406  __host__ __device__ static constexpr f8_ocp_t Max() { return bit_cast<f8_ocp_t>(binary_max); }
407 
408  __host__ __device__ static constexpr f8_ocp_t Lowest()
409  {
410  return bit_cast<f8_ocp_t>(binary_lowest);
411  }
412 
413  __host__ __device__ static constexpr f8_ocp_t QuietNaN()
414  {
415  return bit_cast<f8_ocp_t>(binary_qnan);
416  }
417 };
418 
419 template <>
421 {
422  static constexpr uint8_t binary_min = 0x04; // 0b00000100 = 2^-14
423  static constexpr uint8_t binary_max = 0x7B; // 0b01111011 = 57344
424  static constexpr uint8_t binary_lowest = 0xFB; // 0b11111011 = -57344
425  static constexpr uint8_t binary_qnan = 0x7D; // 0b01111101
426 
427  __host__ __device__ static constexpr bf8_ocp_t Min() { return bit_cast<bf8_ocp_t>(binary_min); }
428 
429  __host__ __device__ static constexpr bf8_ocp_t Max() { return bit_cast<bf8_ocp_t>(binary_max); }
430 
431  __host__ __device__ static constexpr bf8_ocp_t Lowest()
432  {
433  return bit_cast<bf8_ocp_t>(binary_lowest);
434  }
435 
436  __host__ __device__ static constexpr bf8_ocp_t QuietNaN()
437  {
438  return bit_cast<bf8_ocp_t>(binary_qnan);
439  }
440 };
441 
442 template <>
444 {
445  static constexpr uint8_t binary_min_normal = 0x2; // 0b0010
446  static constexpr uint8_t binary_max_normal = 0x7; // 0b0111
447  static constexpr uint8_t binary_lowest_normal = 0xF; // 0b1111
448  static constexpr uint8_t binary_min_subnorm = 0x1; // 0b0001
449  static constexpr uint8_t binary_max_subnorm = 0x1; // 0b0001
450 
451  static constexpr float data_max_normal_number = 6;
452  static constexpr float data_min_subnormal_number = 0.5;
453 
454  __host__ __device__ static constexpr f4_t Min() { return f4_t(binary_min_normal); }
455  __host__ __device__ static constexpr f4_t Max() { return f4_t(binary_max_normal); }
456  __host__ __device__ static constexpr f4_t Lowest() { return f4_t(binary_lowest_normal); }
457  __host__ __device__ static constexpr f4_t MinSubnorm() { return f4_t(binary_min_subnorm); }
458  __host__ __device__ static constexpr f4_t MaxSubnorm() { return f4_t(binary_max_subnorm); }
459 
460  __host__ __device__ static constexpr float DataMaxNorm() { return data_max_normal_number; }
461  __host__ __device__ static constexpr float DataMinSubnorm()
462  {
463  return data_min_subnormal_number;
464  }
465 };
466 
467 template <>
469 {
470  static constexpr uint8_t binary_min_normal = 0x08; // 0b001000
471  static constexpr uint8_t binary_max_normal = 0x1F; // 0b011111
472  static constexpr uint8_t binary_lowest_normal = 0x3F; // 0b111111
473  static constexpr uint8_t binary_min_subnorm = 0x01; // 0b000001
474  static constexpr uint8_t binary_max_subnorm = 0x07; // 0b000111
475 
476  static constexpr float data_max_normal_number = 7.5;
477  static constexpr float data_min_subnormal_number = 0.125;
478 
479  __host__ __device__ static constexpr f6_t Min() { return f6_t(binary_min_normal & 0b111111); }
480  __host__ __device__ static constexpr f6_t Max() { return f6_t(binary_max_normal & 0b111111); }
481  __host__ __device__ static constexpr f6_t Lowest()
482  {
483  return f6_t(binary_lowest_normal & 0b111111);
484  }
485  __host__ __device__ static constexpr f6_t MinSubnorm()
486  {
487  return f6_t(binary_min_subnorm & 0b111111);
488  }
489  __host__ __device__ static constexpr f6_t MaxSubnorm()
490  {
491  return f6_t(binary_max_subnorm & 0b111111);
492  }
493 
494  __host__ __device__ static constexpr float DataMaxNorm() { return data_max_normal_number; }
495  __host__ __device__ static constexpr float DataMinSubnorm()
496  {
497  return data_min_subnormal_number;
498  }
499 };
500 
501 template <>
503 {
504  static constexpr uint8_t binary_min_normal = 0x08; // 0b001000
505  static constexpr uint8_t binary_max_normal = 0x1F; // 0b011111
506  static constexpr uint8_t binary_lowest_normal = 0x3F; // 0b111111
507  static constexpr uint8_t binary_min_subnorm = 0x01; // 0b000001
508  static constexpr uint8_t binary_max_subnorm = 0x03; // 0b000011
509 
510  static constexpr float data_max_normal_number = 28;
511  static constexpr float data_min_subnormal_number = 0.0625;
512 
513  __host__ __device__ static constexpr bf6_t Min() { return bf6_t(binary_min_normal); }
514  __host__ __device__ static constexpr bf6_t Max() { return bf6_t(binary_max_normal); }
515  __host__ __device__ static constexpr bf6_t Lowest() { return bf6_t(binary_lowest_normal); }
516  __host__ __device__ static constexpr bf6_t MinSubnorm() { return bf6_t(binary_min_subnorm); }
517  __host__ __device__ static constexpr bf6_t MaxSubnorm() { return bf6_t(binary_max_subnorm); }
518 
519  __host__ __device__ static constexpr float DataMaxNorm() { return data_max_normal_number; }
520  __host__ __device__ static constexpr float DataMinSubnorm()
521  {
522  return data_min_subnormal_number;
523  }
524 };
525 
526 template <>
528 {
529  static constexpr e8m0_bexp_t binary_min = 0x00; // 0b00000000
530  static constexpr e8m0_bexp_t binary_max = 0xFE; // 0b11111110
531  static constexpr e8m0_bexp_t binary_qnan = 0xFF; // 0b11111111
532  static constexpr e8m0_bexp_t binary_1 = 0x7F; // 0b01111111
533  static constexpr e8m0_bexp_t binary_2 = 0x80; // 0b10000000
534  static constexpr e8m0_bexp_t binary_3 = 0x82; // 0b10000010
535  static constexpr e8m0_bexp_t binary_135 = 0x87; // 0b10000111
536  static constexpr e8m0_bexp_t binary_142 = 0x8E; // 0b10001110
537 
538  __host__ __device__ static constexpr e8m0_bexp_t Min() { return e8m0_bexp_t(binary_min); }
539  __host__ __device__ static constexpr e8m0_bexp_t Max() { return e8m0_bexp_t(binary_max); }
540  __host__ __device__ static constexpr e8m0_bexp_t QuietNaN() { return e8m0_bexp_t(binary_qnan); }
541  __host__ __device__ static constexpr e8m0_bexp_t Binary_1() { return e8m0_bexp_t(binary_1); }
542  __host__ __device__ static constexpr e8m0_bexp_t Binary_2() { return e8m0_bexp_t(binary_2); }
543  __host__ __device__ static constexpr e8m0_bexp_t Binary_3() { return e8m0_bexp_t(binary_3); }
544  __host__ __device__ static constexpr e8m0_bexp_t Binary_135()
545  {
546  return e8m0_bexp_t(binary_135);
547  }
548  __host__ __device__ static constexpr e8m0_bexp_t Binary_142()
549  {
550  return e8m0_bexp_t(binary_142);
551  }
552 };
553 #endif
554 
555 } // namespace ck
__host__ constexpr __device__ T max(T x)
Definition: math.hpp:84
__host__ constexpr __device__ T min(T x)
Definition: math.hpp:116
Definition: ck.hpp:270
unsigned _BitInt(4) f4_t
Definition: data_type.hpp:33
_BitInt(6) f6_t
Definition: data_type.hpp:34
_Float16 half_t
Definition: data_type.hpp:31
_BitInt(4) int4_t
Definition: data_type.hpp:32
unsigned _BitInt(6) bf6_t
Definition: data_type.hpp:35
signed short int16_t
Definition: stdint.h:122
unsigned short uint16_t
Definition: stdint.h:125
unsigned int uint32_t
Definition: stdint.h:126
signed int int32_t
Definition: stdint.h:123
unsigned char uint8_t
Definition: stdint.h:124
signed char int8_t
Definition: stdint.h:121
__host__ static constexpr __device__ float DataMaxNorm()
Definition: numeric_limits.hpp:519
__host__ static constexpr __device__ bf6_t MinSubnorm()
Definition: numeric_limits.hpp:516
__host__ static constexpr __device__ float DataMinSubnorm()
Definition: numeric_limits.hpp:520
__host__ static constexpr __device__ bf6_t MaxSubnorm()
Definition: numeric_limits.hpp:517
__host__ static constexpr __device__ bf6_t Max()
Definition: numeric_limits.hpp:514
__host__ static constexpr __device__ bf6_t Lowest()
Definition: numeric_limits.hpp:515
__host__ static constexpr __device__ bf6_t Min()
Definition: numeric_limits.hpp:513
__host__ static constexpr __device__ bf8_fnuz_t QuietNaN()
Definition: numeric_limits.hpp:393
__host__ static constexpr __device__ bf8_fnuz_t Min()
Definition: numeric_limits.hpp:387
__host__ static constexpr __device__ bf8_fnuz_t Lowest()
Definition: numeric_limits.hpp:391
__host__ static constexpr __device__ bf8_fnuz_t Max()
Definition: numeric_limits.hpp:389
__host__ static constexpr __device__ bf8_ocp_t Min()
Definition: numeric_limits.hpp:427
__host__ static constexpr __device__ bf8_ocp_t Lowest()
Definition: numeric_limits.hpp:431
__host__ static constexpr __device__ bf8_ocp_t Max()
Definition: numeric_limits.hpp:429
__host__ static constexpr __device__ bf8_ocp_t QuietNaN()
Definition: numeric_limits.hpp:436
__host__ static constexpr __device__ e8m0_bexp_t Binary_2()
Definition: numeric_limits.hpp:542
__host__ static constexpr __device__ e8m0_bexp_t Binary_142()
Definition: numeric_limits.hpp:548
__host__ static constexpr __device__ e8m0_bexp_t Max()
Definition: numeric_limits.hpp:539
__host__ static constexpr __device__ e8m0_bexp_t QuietNaN()
Definition: numeric_limits.hpp:540
__host__ static constexpr __device__ e8m0_bexp_t Binary_135()
Definition: numeric_limits.hpp:544
__host__ static constexpr __device__ e8m0_bexp_t Min()
Definition: numeric_limits.hpp:538
__host__ static constexpr __device__ e8m0_bexp_t Binary_1()
Definition: numeric_limits.hpp:541
__host__ static constexpr __device__ e8m0_bexp_t Binary_3()
Definition: numeric_limits.hpp:543
__host__ static constexpr __device__ float DataMinSubnorm()
Definition: numeric_limits.hpp:461
__host__ static constexpr __device__ f4_t Min()
Definition: numeric_limits.hpp:454
__host__ static constexpr __device__ f4_t Lowest()
Definition: numeric_limits.hpp:456
__host__ static constexpr __device__ float DataMaxNorm()
Definition: numeric_limits.hpp:460
__host__ static constexpr __device__ f4_t Max()
Definition: numeric_limits.hpp:455
__host__ static constexpr __device__ f4_t MaxSubnorm()
Definition: numeric_limits.hpp:458
__host__ static constexpr __device__ f4_t MinSubnorm()
Definition: numeric_limits.hpp:457
__host__ static constexpr __device__ float DataMaxNorm()
Definition: numeric_limits.hpp:494
__host__ static constexpr __device__ f6_t MinSubnorm()
Definition: numeric_limits.hpp:485
__host__ static constexpr __device__ f6_t MaxSubnorm()
Definition: numeric_limits.hpp:489
__host__ static constexpr __device__ f6_t Min()
Definition: numeric_limits.hpp:479
__host__ static constexpr __device__ f6_t Max()
Definition: numeric_limits.hpp:480
__host__ static constexpr __device__ f6_t Lowest()
Definition: numeric_limits.hpp:481
__host__ static constexpr __device__ float DataMinSubnorm()
Definition: numeric_limits.hpp:495
__host__ static constexpr __device__ f8_fnuz_t QuietNaN()
Definition: numeric_limits.hpp:370
__host__ static constexpr __device__ f8_fnuz_t Min()
Definition: numeric_limits.hpp:364
__host__ static constexpr __device__ f8_fnuz_t Max()
Definition: numeric_limits.hpp:366
__host__ static constexpr __device__ f8_fnuz_t Lowest()
Definition: numeric_limits.hpp:368
__host__ static constexpr __device__ f8_ocp_t Min()
Definition: numeric_limits.hpp:404
__host__ static constexpr __device__ f8_ocp_t Max()
Definition: numeric_limits.hpp:406
__host__ static constexpr __device__ f8_ocp_t QuietNaN()
Definition: numeric_limits.hpp:413
__host__ static constexpr __device__ f8_ocp_t Lowest()
Definition: numeric_limits.hpp:408
__host__ static constexpr __device__ half_t Max()
Definition: numeric_limits.hpp:331
__host__ static constexpr __device__ half_t Lowest()
Definition: numeric_limits.hpp:333
__host__ static constexpr __device__ half_t Min()
Definition: numeric_limits.hpp:329
__host__ static constexpr __device__ half_t QuietNaN()
Definition: numeric_limits.hpp:335
Definition: numeric_limits.hpp:310
__host__ static constexpr __device__ T Lowest()
Definition: numeric_limits.hpp:313
__host__ static constexpr __device__ T Infinity()
Definition: numeric_limits.hpp:318
__host__ static constexpr __device__ T QuietNaN()
Definition: numeric_limits.hpp:314
__host__ static constexpr __device__ T Min()
Definition: numeric_limits.hpp:311
__host__ static constexpr __device__ T Max()
Definition: numeric_limits.hpp:312
Definition: amd_ck_fp8.hpp:49
Definition: amd_ck_fp8.hpp:369
Unsigned representation of a conventional biased Float32 exponent.
Definition: e8m0.hpp:26
Definition: amd_ck_fp8.hpp:36
Definition: amd_ck_fp8.hpp:323