Eigen::bfloat16_impl Namespace Reference

Classes

struct  __bfloat16_raw
 
struct  bfloat16_base
 
struct  numeric_limits_bfloat16_impl
 

Functions

bfloat16 abs (const bfloat16 &a)
 
bfloat16 acos (const bfloat16 &a)
 
bfloat16 acosh (const bfloat16 &a)
 
bfloat16 asin (const bfloat16 &a)
 
bfloat16 asinh (const bfloat16 &a)
 
bfloat16 atan (const bfloat16 &a)
 
bfloat16 atan2 (const bfloat16 &a, const bfloat16 &b)
 
bfloat16 atanh (const bfloat16 &a)
 
float bfloat16_to_float (__bfloat16_raw h)
 
bfloat16 ceil (const bfloat16 &a)
 
bfloat16 cos (const bfloat16 &a)
 
bfloat16 cosh (const bfloat16 &a)
 
bfloat16 exp (const bfloat16 &a)
 
bfloat16 expm1 (const bfloat16 &a)
 
template<bool AssumeArgumentIsNormalOrInfinityOrZero>
__bfloat16_raw float_to_bfloat16_rtne (float ff)
 
template<>
__bfloat16_raw float_to_bfloat16_rtne< false > (float ff)
 
template<>
__bfloat16_raw float_to_bfloat16_rtne< true > (float ff)
 
bfloat16 floor (const bfloat16 &a)
 
bfloat16 fmax (const bfloat16 &a, const bfloat16 &b)
 
bfloat16 fmin (const bfloat16 &a, const bfloat16 &b)
 
bfloat16 fmod (const bfloat16 &a, const bfloat16 &b)
 
bool() isfinite (const bfloat16 &a)
 
bool() isinf (const bfloat16 &a)
 
bool() isnan (const bfloat16 &a)
 
bfloat16 log (const bfloat16 &a)
 
bfloat16 log10 (const bfloat16 &a)
 
bfloat16 log1p (const bfloat16 &a)
 
bfloat16 log2 (const bfloat16 &a)
 
bfloat16() max (const bfloat16 &a, const bfloat16 &b)
 
bfloat16() min (const bfloat16 &a, const bfloat16 &b)
 
bool operator!= (const bfloat16 &a, const bfloat16 &b)
 
bfloat16 operator* (const bfloat16 &a, const bfloat16 &b)
 
bfloat16operator*= (bfloat16 &a, const bfloat16 &b)
 
bfloat16 operator+ (const bfloat16 &a, const bfloat16 &b)
 
bfloat16 operator+ (const bfloat16 &a, const int &b)
 
bfloat16 operator+ (const int &a, const bfloat16 &b)
 
bfloat16 operator++ (bfloat16 &a)
 
bfloat16 operator++ (bfloat16 &a, int)
 
bfloat16operator+= (bfloat16 &a, const bfloat16 &b)
 
bfloat16 operator- (const bfloat16 &a)
 
bfloat16 operator- (const bfloat16 &a, const bfloat16 &b)
 
bfloat16 operator-- (bfloat16 &a)
 
bfloat16 operator-- (bfloat16 &a, int)
 
bfloat16operator-= (bfloat16 &a, const bfloat16 &b)
 
bfloat16 operator/ (const bfloat16 &a, const bfloat16 &b)
 
bfloat16 operator/ (const bfloat16 &a, Index b)
 
bfloat16operator/= (bfloat16 &a, const bfloat16 &b)
 
bool operator< (const bfloat16 &a, const bfloat16 &b)
 
EIGEN_ALWAYS_INLINE std::ostream & operator<< (std::ostream &os, const bfloat16 &v)
 
bool operator<= (const bfloat16 &a, const bfloat16 &b)
 
bool operator== (const bfloat16 &a, const bfloat16 &b)
 
bool operator> (const bfloat16 &a, const bfloat16 &b)
 
bool operator>= (const bfloat16 &a, const bfloat16 &b)
 
bfloat16 pow (const bfloat16 &a, const bfloat16 &b)
 
EIGEN_CONSTEXPR numext::uint16_t raw_bfloat16_as_uint16 (const __bfloat16_raw &bf)
 
EIGEN_CONSTEXPR __bfloat16_raw raw_uint16_to_bfloat16 (numext::uint16_t value)
 
EIGEN_CONSTEXPR __bfloat16_raw raw_uint16_to_bfloat16 (unsigned short value)
 
bfloat16 rint (const bfloat16 &a)
 
bfloat16 round (const bfloat16 &a)
 
bfloat16 sin (const bfloat16 &a)
 
bfloat16 sinh (const bfloat16 &a)
 
bfloat16 sqrt (const bfloat16 &a)
 
bfloat16 tan (const bfloat16 &a)
 
bfloat16 tanh (const bfloat16 &a)
 
__bfloat16_raw truncate_to_bfloat16 (const float v)
 

Function Documentation

◆ abs()

bfloat16 Eigen::bfloat16_impl::abs ( const bfloat16 a)
inline

Definition at line 601 of file BFloat16.h.

601  {
602  numext::uint16_t x = numext::bit_cast<numext::uint16_t>(a) & 0x7FFF;
603  return numext::bit_cast<bfloat16>(x);
604 }
std::uint16_t uint16_t
Definition: Meta.h:37

◆ acos()

bfloat16 Eigen::bfloat16_impl::acos ( const bfloat16 a)
inline

Definition at line 644 of file BFloat16.h.

644  {
645  return bfloat16(::acosf(float(a)));
646 }

◆ acosh()

bfloat16 Eigen::bfloat16_impl::acosh ( const bfloat16 a)
inline

Definition at line 662 of file BFloat16.h.

662  {
663  return bfloat16(::acoshf(float(a)));
664 }

◆ asin()

bfloat16 Eigen::bfloat16_impl::asin ( const bfloat16 a)
inline

Definition at line 641 of file BFloat16.h.

641  {
642  return bfloat16(::asinf(float(a)));
643 }

◆ asinh()

bfloat16 Eigen::bfloat16_impl::asinh ( const bfloat16 a)
inline

Definition at line 659 of file BFloat16.h.

659  {
660  return bfloat16(::asinhf(float(a)));
661 }

◆ atan()

bfloat16 Eigen::bfloat16_impl::atan ( const bfloat16 a)
inline

Definition at line 647 of file BFloat16.h.

647  {
648  return bfloat16(::atanf(float(a)));
649 }

◆ atan2()

bfloat16 Eigen::bfloat16_impl::atan2 ( const bfloat16 a,
const bfloat16 b 
)
inline

Definition at line 629 of file BFloat16.h.

629  {
630  return bfloat16(::atan2f(float(a), float(b)));
631 }
Array< int, 3, 1 > b

◆ atanh()

bfloat16 Eigen::bfloat16_impl::atanh ( const bfloat16 a)
inline

Definition at line 665 of file BFloat16.h.

665  {
666  return bfloat16(::atanhf(float(a)));
667 }

◆ bfloat16_to_float()

float Eigen::bfloat16_impl::bfloat16_to_float ( __bfloat16_raw  h)
inline

Definition at line 571 of file BFloat16.h.

571  {
572 #if defined(EIGEN_USE_HIP_BF16)
573  return static_cast<float>(h);
574 #else
575  return numext::bit_cast<float>(static_cast<numext::uint32_t>(h.value) << 16);
576 #endif
577 }
std::uint32_t uint32_t
Definition: Meta.h:39

◆ ceil()

bfloat16 Eigen::bfloat16_impl::ceil ( const bfloat16 a)
inline

Definition at line 671 of file BFloat16.h.

671  {
672  return bfloat16(::ceilf(float(a)));
673 }

◆ cos()

bfloat16 Eigen::bfloat16_impl::cos ( const bfloat16 a)
inline

Definition at line 635 of file BFloat16.h.

635  {
636  return bfloat16(::cosf(float(a)));
637 }

◆ cosh()

bfloat16 Eigen::bfloat16_impl::cosh ( const bfloat16 a)
inline

Definition at line 653 of file BFloat16.h.

653  {
654  return bfloat16(::coshf(float(a)));
655 }

◆ exp()

bfloat16 Eigen::bfloat16_impl::exp ( const bfloat16 a)
inline

Definition at line 605 of file BFloat16.h.

605  {
606  return bfloat16(::expf(float(a)));
607 }

◆ expm1()

bfloat16 Eigen::bfloat16_impl::expm1 ( const bfloat16 a)
inline

Definition at line 608 of file BFloat16.h.

608  {
609  return bfloat16(numext::expm1(float(a)));
610 }
const Expm1ReturnType expm1() const

◆ float_to_bfloat16_rtne()

template<bool AssumeArgumentIsNormalOrInfinityOrZero>
__bfloat16_raw Eigen::bfloat16_impl::float_to_bfloat16_rtne ( float  ff)
inline

◆ float_to_bfloat16_rtne< false >()

template<>
__bfloat16_raw Eigen::bfloat16_impl::float_to_bfloat16_rtne< false > ( float  ff)
inline

Definition at line 381 of file BFloat16.h.

381  {
382 #if defined(EIGEN_USE_HIP_BF16)
383  return __bfloat16_raw(__bfloat16_raw::round_to_bfloat16(ff));
384 #else
385  __bfloat16_raw output;
386 
388  // If the value is a NaN, squash it to a qNaN with msb of fraction set,
389  // this makes sure after truncation we don't end up with an inf.
390  //
391  // qNaN magic: All exponent bits set + most significant bit of fraction
392  // set.
393  output.value = std::signbit(ff) ? 0xFFC0: 0x7FC0;
394  } else {
395  // Fast rounding algorithm that rounds a half value to nearest even. This
396  // reduces expected error when we convert a large number of floats. Here
397  // is how it works:
398  //
399  // Definitions:
400  // To convert a float 32 to bfloat16, a float 32 can be viewed as 32 bits
401  // with the following tags:
402  //
403  // Sign | Exp (8 bits) | Frac (23 bits)
404  // S EEEEEEEE FFFFFFLRTTTTTTTTTTTTTTT
405  //
406  // S: Sign bit.
407  // E: Exponent bits.
408  // F: First 6 bits of fraction.
409  // L: Least significant bit of resulting bfloat16 if we truncate away the
410  // rest of the float32. This is also the 7th bit of fraction
411  // R: Rounding bit, 8th bit of fraction.
412  // T: Sticky bits, rest of fraction, 15 bits.
413  //
414  // To round half to nearest even, there are 3 cases where we want to round
415  // down (simply truncate the result of the bits away, which consists of
416  // rounding bit and sticky bits) and two cases where we want to round up
417  // (truncate then add one to the result).
418  //
419  // The fast converting algorithm simply adds lsb (L) to 0x7fff (15 bits of
420  // 1s) as the rounding bias, adds the rounding bias to the input, then
421  // truncates the last 16 bits away.
422  //
423  // To understand how it works, we can analyze this algorithm case by case:
424  //
425  // 1. L = 0, R = 0:
426  // Expect: round down, this is less than half value.
427  //
428  // Algorithm:
429  // - Rounding bias: 0x7fff + 0 = 0x7fff
430  // - Adding rounding bias to input may create any carry, depending on
431  // whether there is any value set to 1 in T bits.
432  // - R may be set to 1 if there is a carry.
433  // - L remains 0.
434  // - Note that this case also handles Inf and -Inf, where all fraction
435  // bits, including L, R and Ts are all 0. The output remains Inf after
436  // this algorithm.
437  //
438  // 2. L = 1, R = 0:
439  // Expect: round down, this is less than half value.
440  //
441  // Algorithm:
442  // - Rounding bias: 0x7fff + 1 = 0x8000
443  // - Adding rounding bias to input doesn't change sticky bits but
444  // adds 1 to rounding bit.
445  // - L remains 1.
446  //
447  // 3. L = 0, R = 1, all of T are 0:
448  // Expect: round down, this is exactly at half, the result is already
449  // even (L=0).
450  //
451  // Algorithm:
452  // - Rounding bias: 0x7fff + 0 = 0x7fff
453  // - Adding rounding bias to input sets all sticky bits to 1, but
454  // doesn't create a carry.
455  // - R remains 1.
456  // - L remains 0.
457  //
458  // 4. L = 1, R = 1:
459  // Expect: round up, this is exactly at half, the result needs to be
460  // round to the next even number.
461  //
462  // Algorithm:
463  // - Rounding bias: 0x7fff + 1 = 0x8000
464  // - Adding rounding bias to input doesn't change sticky bits, but
465  // creates a carry from rounding bit.
466  // - The carry sets L to 0, creates another carry bit and propagate
467  // forward to F bits.
468  // - If all the F bits are 1, a carry then propagates to the exponent
469  // bits, which then creates the minimum value with the next exponent
470  // value. Note that we won't have the case where exponents are all 1,
471  // since that's either a NaN (handled in the other if condition) or inf
472  // (handled in case 1).
473  //
474  // 5. L = 0, R = 1, any of T is 1:
475  // Expect: round up, this is greater than half.
476  //
477  // Algorithm:
478  // - Rounding bias: 0x7fff + 0 = 0x7fff
479  // - Adding rounding bias to input creates a carry from sticky bits,
480  // sets rounding bit to 0, then create another carry.
481  // - The second carry sets L to 1.
482  //
483  // Examples:
484  //
485  // Exact half value that is already even:
486  // Input:
487  // Sign | Exp (8 bit) | Frac (first 7 bit) | Frac (last 16 bit)
488  // S E E E E E E E E F F F F F F L RTTTTTTTTTTTTTTT
489  // 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1000000000000000
490  //
491  // This falls into case 3. We truncate the rest of 16 bits and no
492  // carry is created into F and L:
493  //
494  // Output:
495  // Sign | Exp (8 bit) | Frac (first 7 bit)
496  // S E E E E E E E E F F F F F F L
497  // 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0
498  //
499  // Exact half value, round to next even number:
500  // Input:
501  // Sign | Exp (8 bit) | Frac (first 7 bit) | Frac (last 16 bit)
502  // S E E E E E E E E F F F F F F L RTTTTTTTTTTTTTTT
503  // 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1000000000000000
504  //
505  // This falls into case 4. We create a carry from R and T,
506  // which then propagates into L and F:
507  //
508  // Output:
509  // Sign | Exp (8 bit) | Frac (first 7 bit)
510  // S E E E E E E E E F F F F F F L
511  // 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0
512  //
513  //
514  // Max denormal value round to min normal value:
515  // Input:
516  // Sign | Exp (8 bit) | Frac (first 7 bit) | Frac (last 16 bit)
517  // S E E E E E E E E F F F F F F L RTTTTTTTTTTTTTTT
518  // 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1111111111111111
519  //
520  // This falls into case 4. We create a carry from R and T,
521  // propagate into L and F, which then propagates into exponent
522  // bits:
523  //
524  // Output:
525  // Sign | Exp (8 bit) | Frac (first 7 bit)
526  // S E E E E E E E E F F F F F F L
527  // 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0
528  //
529  // Max normal value round to Inf:
530  // Input:
531  // Sign | Exp (8 bit) | Frac (first 7 bit) | Frac (last 16 bit)
532  // S E E E E E E E E F F F F F F L RTTTTTTTTTTTTTTT
533  // 0 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1111111111111111
534  //
535  // This falls into case 4. We create a carry from R and T,
536  // propagate into L and F, which then propagates into exponent
537  // bits:
538  //
539  // Sign | Exp (8 bit) | Frac (first 7 bit)
540  // S E E E E E E E E F F F F F F L
541  // 0 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0
542 
543  // At this point, ff must be either a normal float, or +/-infinity.
544  output = float_to_bfloat16_rtne<true>(ff);
545  }
546  return output;
547 #endif
548 }
#define EIGEN_NOT_A_MACRO
Definition: Macros.h:804
__bfloat16_raw float_to_bfloat16_rtne< true >(float ff)
Definition: BFloat16.h:555
static constexpr EIGEN_ALWAYS_INLINE Scalar signbit(const Scalar &x)
EIGEN_ALWAYS_INLINE bool() isnan(const Eigen::bfloat16 &h)
Definition: BFloat16.h:778

◆ float_to_bfloat16_rtne< true >()

template<>
__bfloat16_raw Eigen::bfloat16_impl::float_to_bfloat16_rtne< true > ( float  ff)
inline

Definition at line 555 of file BFloat16.h.

555  {
556 #if defined(EIGEN_USE_HIP_BF16)
557  return __bfloat16_raw(__bfloat16_raw::round_to_bfloat16(ff));
558 #else
559  numext::uint32_t input = numext::bit_cast<numext::uint32_t>(ff);
560  __bfloat16_raw output;
561 
562  // Least significant bit of resulting bfloat.
563  numext::uint32_t lsb = (input >> 16) & 1;
564  numext::uint32_t rounding_bias = 0x7fff + lsb;
565  input += rounding_bias;
566  output.value = static_cast<numext::uint16_t>(input >> 16);
567  return output;
568 #endif
569 }

◆ floor()

bfloat16 Eigen::bfloat16_impl::floor ( const bfloat16 a)
inline

Definition at line 668 of file BFloat16.h.

668  {
669  return bfloat16(::floorf(float(a)));
670 }

◆ fmax()

bfloat16 Eigen::bfloat16_impl::fmax ( const bfloat16 a,
const bfloat16 b 
)
inline

Definition at line 702 of file BFloat16.h.

702  {
703  const float f1 = static_cast<float>(a);
704  const float f2 = static_cast<float>(b);
705  return bfloat16(::fmaxf(f1, f2));
706 }

◆ fmin()

bfloat16 Eigen::bfloat16_impl::fmin ( const bfloat16 a,
const bfloat16 b 
)
inline

Definition at line 696 of file BFloat16.h.

696  {
697  const float f1 = static_cast<float>(a);
698  const float f2 = static_cast<float>(b);
699  return bfloat16(::fminf(f1, f2));
700 }

◆ fmod()

bfloat16 Eigen::bfloat16_impl::fmod ( const bfloat16 a,
const bfloat16 b 
)
inline

Definition at line 680 of file BFloat16.h.

680  {
681  return bfloat16(::fmodf(float(a), float(b)));
682 }

◆ isfinite()

bool() Eigen::bfloat16_impl::isfinite ( const bfloat16 a)
inline

Definition at line 597 of file BFloat16.h.

597  {
598  return !(isinf EIGEN_NOT_A_MACRO (a)) && !(isnan EIGEN_NOT_A_MACRO (a));
599 }
EIGEN_ALWAYS_INLINE bool() isinf(const Eigen::bfloat16 &h)
Definition: BFloat16.h:784

◆ isinf()

bool() Eigen::bfloat16_impl::isinf ( const bfloat16 a)
inline

Definition at line 581 of file BFloat16.h.

581  {
583 #if defined(EIGEN_USE_HIP_BF16)
584  return (isinf)(a); // Uses HIP hip_bfloat16 isinf operator
585 #else
586  return (isinf)(float(a));
587 #endif
588 }
#define EIGEN_USING_STD(FUNC)
Definition: Macros.h:1080

◆ isnan()

bool() Eigen::bfloat16_impl::isnan ( const bfloat16 a)
inline

Definition at line 589 of file BFloat16.h.

589  {
591 #if defined(EIGEN_USE_HIP_BF16)
592  return (isnan)(a); // Uses HIP hip_bfloat16 isnan operator
593 #else
594  return (isnan)(float(a));
595 #endif
596 }

◆ log()

bfloat16 Eigen::bfloat16_impl::log ( const bfloat16 a)
inline

Definition at line 611 of file BFloat16.h.

611  {
612  return bfloat16(::logf(float(a)));
613 }

◆ log10()

bfloat16 Eigen::bfloat16_impl::log10 ( const bfloat16 a)
inline

Definition at line 617 of file BFloat16.h.

617  {
618  return bfloat16(::log10f(float(a)));
619 }

◆ log1p()

bfloat16 Eigen::bfloat16_impl::log1p ( const bfloat16 a)
inline

Definition at line 614 of file BFloat16.h.

614  {
615  return bfloat16(numext::log1p(float(a)));
616 }
const Log1pReturnType log1p() const

◆ log2()

bfloat16 Eigen::bfloat16_impl::log2 ( const bfloat16 a)
inline

Definition at line 620 of file BFloat16.h.

620  {
621  return bfloat16(static_cast<float>(EIGEN_LOG2E) * ::logf(float(a)));
622 }
#define EIGEN_LOG2E
Definition: MathFunctions.h:17

◆ max()

bfloat16() Eigen::bfloat16_impl::max ( const bfloat16 a,
const bfloat16 b 
)
inline

Definition at line 690 of file BFloat16.h.

690  {
691  const float f1 = static_cast<float>(a);
692  const float f2 = static_cast<float>(b);
693  return f1 < f2 ? b : a;
694 }

◆ min()

bfloat16() Eigen::bfloat16_impl::min ( const bfloat16 a,
const bfloat16 b 
)
inline

Definition at line 684 of file BFloat16.h.

684  {
685  const float f1 = static_cast<float>(a);
686  const float f2 = static_cast<float>(b);
687  return f2 < f1 ? b : a;
688 }

◆ operator!=()

bool Eigen::bfloat16_impl::operator!= ( const bfloat16 a,
const bfloat16 b 
)
inline

Definition at line 319 of file BFloat16.h.

319  {
320  return numext::not_equal_strict(float(a), float(b));
321 }
bool not_equal_strict(const X &x, const Y &y)
Definition: Meta.h:485

◆ operator*()

bfloat16 Eigen::bfloat16_impl::operator* ( const bfloat16 a,
const bfloat16 b 
)
inline

Definition at line 269 of file BFloat16.h.

269  {
270  return bfloat16(float(a) * float(b));
271 }

◆ operator*=()

bfloat16& Eigen::bfloat16_impl::operator*= ( bfloat16 a,
const bfloat16 b 
)
inline

Definition at line 286 of file BFloat16.h.

286  {
287  a = bfloat16(float(a) * float(b));
288  return a;
289 }

◆ operator+() [1/3]

bfloat16 Eigen::bfloat16_impl::operator+ ( const bfloat16 a,
const bfloat16 b 
)
inline

Definition at line 260 of file BFloat16.h.

260  {
261  return bfloat16(float(a) + float(b));
262 }

◆ operator+() [2/3]

bfloat16 Eigen::bfloat16_impl::operator+ ( const bfloat16 a,
const int &  b 
)
inline

Definition at line 263 of file BFloat16.h.

263  {
264  return bfloat16(float(a) + static_cast<float>(b));
265 }

◆ operator+() [3/3]

bfloat16 Eigen::bfloat16_impl::operator+ ( const int &  a,
const bfloat16 b 
)
inline

Definition at line 266 of file BFloat16.h.

266  {
267  return bfloat16(static_cast<float>(a) + float(b));
268 }

◆ operator++() [1/2]

bfloat16 Eigen::bfloat16_impl::operator++ ( bfloat16 a)
inline

Definition at line 298 of file BFloat16.h.

298  {
299  a += bfloat16(1);
300  return a;
301 }

◆ operator++() [2/2]

bfloat16 Eigen::bfloat16_impl::operator++ ( bfloat16 a,
int   
)
inline

Definition at line 306 of file BFloat16.h.

306  {
307  bfloat16 original_value = a;
308  ++a;
309  return original_value;
310 }

◆ operator+=()

bfloat16& Eigen::bfloat16_impl::operator+= ( bfloat16 a,
const bfloat16 b 
)
inline

Definition at line 282 of file BFloat16.h.

282  {
283  a = bfloat16(float(a) + float(b));
284  return a;
285 }

◆ operator-() [1/2]

bfloat16 Eigen::bfloat16_impl::operator- ( const bfloat16 a)
inline

Definition at line 278 of file BFloat16.h.

278  {
279  numext::uint16_t x = numext::bit_cast<uint16_t>(a) ^ 0x8000;
280  return numext::bit_cast<bfloat16>(x);
281 }

◆ operator-() [2/2]

bfloat16 Eigen::bfloat16_impl::operator- ( const bfloat16 a,
const bfloat16 b 
)
inline

Definition at line 272 of file BFloat16.h.

272  {
273  return bfloat16(float(a) - float(b));
274 }

◆ operator--() [1/2]

bfloat16 Eigen::bfloat16_impl::operator-- ( bfloat16 a)
inline

Definition at line 302 of file BFloat16.h.

302  {
303  a -= bfloat16(1);
304  return a;
305 }

◆ operator--() [2/2]

bfloat16 Eigen::bfloat16_impl::operator-- ( bfloat16 a,
int   
)
inline

Definition at line 311 of file BFloat16.h.

311  {
312  bfloat16 original_value = a;
313  --a;
314  return original_value;
315 }

◆ operator-=()

bfloat16& Eigen::bfloat16_impl::operator-= ( bfloat16 a,
const bfloat16 b 
)
inline

Definition at line 290 of file BFloat16.h.

290  {
291  a = bfloat16(float(a) - float(b));
292  return a;
293 }

◆ operator/() [1/2]

bfloat16 Eigen::bfloat16_impl::operator/ ( const bfloat16 a,
const bfloat16 b 
)
inline

Definition at line 275 of file BFloat16.h.

275  {
276  return bfloat16(float(a) / float(b));
277 }

◆ operator/() [2/2]

bfloat16 Eigen::bfloat16_impl::operator/ ( const bfloat16 a,
Index  b 
)
inline

Definition at line 342 of file BFloat16.h.

342  {
343  return bfloat16(static_cast<float>(a) / static_cast<float>(b));
344 }

◆ operator/=()

bfloat16& Eigen::bfloat16_impl::operator/= ( bfloat16 a,
const bfloat16 b 
)
inline

Definition at line 294 of file BFloat16.h.

294  {
295  a = bfloat16(float(a) / float(b));
296  return a;
297 }

◆ operator<()

bool Eigen::bfloat16_impl::operator< ( const bfloat16 a,
const bfloat16 b 
)
inline

Definition at line 322 of file BFloat16.h.

322  {
323  return float(a) < float(b);
324 }

◆ operator<<()

EIGEN_ALWAYS_INLINE std::ostream& Eigen::bfloat16_impl::operator<< ( std::ostream &  os,
const bfloat16 v 
)

Definition at line 709 of file BFloat16.h.

709  {
710  os << static_cast<float>(v);
711  return os;
712 }
Array< int, Dynamic, 1 > v

◆ operator<=()

bool Eigen::bfloat16_impl::operator<= ( const bfloat16 a,
const bfloat16 b 
)
inline

Definition at line 325 of file BFloat16.h.

325  {
326  return float(a) <= float(b);
327 }

◆ operator==()

bool Eigen::bfloat16_impl::operator== ( const bfloat16 a,
const bfloat16 b 
)
inline

Definition at line 316 of file BFloat16.h.

316  {
317  return numext::equal_strict(float(a),float(b));
318 }
bool equal_strict(const X &x, const Y &y)
Definition: Meta.h:460

◆ operator>()

bool Eigen::bfloat16_impl::operator> ( const bfloat16 a,
const bfloat16 b 
)
inline

Definition at line 328 of file BFloat16.h.

328  {
329  return float(a) > float(b);
330 }

◆ operator>=()

bool Eigen::bfloat16_impl::operator>= ( const bfloat16 a,
const bfloat16 b 
)
inline

Definition at line 331 of file BFloat16.h.

331  {
332  return float(a) >= float(b);
333 }

◆ pow()

bfloat16 Eigen::bfloat16_impl::pow ( const bfloat16 a,
const bfloat16 b 
)
inline

Definition at line 626 of file BFloat16.h.

626  {
627  return bfloat16(::powf(float(a), float(b)));
628 }

◆ raw_bfloat16_as_uint16()

EIGEN_CONSTEXPR numext::uint16_t Eigen::bfloat16_impl::raw_bfloat16_as_uint16 ( const __bfloat16_raw bf)
inline

Definition at line 370 of file BFloat16.h.

370  {
371 #if defined(EIGEN_USE_HIP_BF16)
372  return bf.data;
373 #else
374  return bf.value;
375 #endif
376 }

◆ raw_uint16_to_bfloat16() [1/2]

EIGEN_CONSTEXPR __bfloat16_raw Eigen::bfloat16_impl::raw_uint16_to_bfloat16 ( numext::uint16_t  value)
inline

Definition at line 360 of file BFloat16.h.

360  {
361 #if defined(EIGEN_USE_HIP_BF16)
362  __bfloat16_raw bf;
363  bf.data = value;
364  return bf;
365 #else
366  return __bfloat16_raw(value);
367 #endif
368 }

◆ raw_uint16_to_bfloat16() [2/2]

EIGEN_CONSTEXPR __bfloat16_raw Eigen::bfloat16_impl::raw_uint16_to_bfloat16 ( unsigned short  value)
inline

◆ rint()

bfloat16 Eigen::bfloat16_impl::rint ( const bfloat16 a)
inline

Definition at line 674 of file BFloat16.h.

674  {
675  return bfloat16(::rintf(float(a)));
676 }

◆ round()

bfloat16 Eigen::bfloat16_impl::round ( const bfloat16 a)
inline

Definition at line 677 of file BFloat16.h.

677  {
678  return bfloat16(::roundf(float(a)));
679 }

◆ sin()

bfloat16 Eigen::bfloat16_impl::sin ( const bfloat16 a)
inline

Definition at line 632 of file BFloat16.h.

632  {
633  return bfloat16(::sinf(float(a)));
634 }

◆ sinh()

bfloat16 Eigen::bfloat16_impl::sinh ( const bfloat16 a)
inline

Definition at line 650 of file BFloat16.h.

650  {
651  return bfloat16(::sinhf(float(a)));
652 }

◆ sqrt()

bfloat16 Eigen::bfloat16_impl::sqrt ( const bfloat16 a)
inline

Definition at line 623 of file BFloat16.h.

623  {
624  return bfloat16(::sqrtf(float(a)));
625 }

◆ tan()

bfloat16 Eigen::bfloat16_impl::tan ( const bfloat16 a)
inline

Definition at line 638 of file BFloat16.h.

638  {
639  return bfloat16(::tanf(float(a)));
640 }

◆ tanh()

bfloat16 Eigen::bfloat16_impl::tanh ( const bfloat16 a)
inline

Definition at line 656 of file BFloat16.h.

656  {
657  return bfloat16(::tanhf(float(a)));
658 }

◆ truncate_to_bfloat16()

__bfloat16_raw Eigen::bfloat16_impl::truncate_to_bfloat16 ( const float  v)
inline

Definition at line 346 of file BFloat16.h.

346  {
347 #if defined(EIGEN_USE_HIP_BF16)
348  return __bfloat16_raw(__bfloat16_raw::round_to_bfloat16(v, __bfloat16_raw::truncate));
349 #else
350  __bfloat16_raw output;
352  output.value = std::signbit(v) ? 0xFFC0: 0x7FC0;
353  return output;
354  }
355  output.value = static_cast<numext::uint16_t>(numext::bit_cast<numext::uint32_t>(v) >> 16);
356  return output;
357 #endif
358 }