Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
Eigen::half_impl Namespace Reference

Classes

struct  __half_raw
 
union  float32_bits
 
struct  half_base
 

Functions

EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC __half_raw raw_uint16_to_half (unsigned short x)
 
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC __half_raw float_to_half_rtne (float ff)
 
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC float half_to_float (__half_raw h)
 
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half operator+ (const half &a, const half &b)
 
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half operator* (const half &a, const half &b)
 
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half operator- (const half &a, const half &b)
 
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half operator/ (const half &a, const half &b)
 
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half operator- (const half &a)
 
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC halfoperator+= (half &a, const half &b)
 
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC halfoperator*= (half &a, const half &b)
 
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC halfoperator-= (half &a, const half &b)
 
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC halfoperator/= (half &a, const half &b)
 
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool operator== (const half &a, const half &b)
 
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool operator!= (const half &a, const half &b)
 
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool operator< (const half &a, const half &b)
 
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool operator<= (const half &a, const half &b)
 
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool operator> (const half &a, const half &b)
 
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool operator>= (const half &a, const half &b)
 
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half operator/ (const half &a, Index b)
 
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool() isinf (const half &a)
 
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool() isnan (const half &a)
 
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool() isfinite (const half &a)
 
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half abs (const half &a)
 
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half exp (const half &a)
 
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half log (const half &a)
 
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half log1p (const half &a)
 
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half log10 (const half &a)
 
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half sqrt (const half &a)
 
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half pow (const half &a, const half &b)
 
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half sin (const half &a)
 
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half cos (const half &a)
 
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half tan (const half &a)
 
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half tanh (const half &a)
 
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half floor (const half &a)
 
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half ceil (const half &a)
 
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half() min (const half &a, const half &b)
 
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half() max (const half &a, const half &b)
 
EIGEN_ALWAYS_INLINE std::ostream & operator<< (std::ostream &os, const half &v)
 

Class Documentation

◆ Eigen::half_impl::float32_bits

union Eigen::half_impl::float32_bits
Class Members
float f
unsigned int u

Function Documentation

◆ abs()

EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half Eigen::half_impl::abs ( const half a)
445 {
446 half result;
447 result.x = a.x & 0x7FFF;
448 return result;
449}
unsigned short x
Definition Half.h:57
Definition Half.h:80

References abs(), and Eigen::half_impl::__half_raw::x.

Referenced by abs().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ceil()

EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half Eigen::half_impl::ceil ( const half a)
499 {
500#if EIGEN_CUDACC_VER >= 80000 && defined EIGEN_CUDA_ARCH && EIGEN_CUDA_ARCH >= 300
501 return half(hceil(a));
502#else
503 return half(::ceilf(float(a)));
504#endif
505}

◆ cos()

EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half Eigen::half_impl::cos ( const half a)
483 {
484 return half(::cosf(float(a)));
485}

◆ exp()

EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half Eigen::half_impl::exp ( const half a)
450 {
451#if EIGEN_CUDACC_VER >= 80000 && defined EIGEN_CUDA_ARCH && EIGEN_CUDA_ARCH >= 530
452 return half(hexp(a));
453#else
454 return half(::expf(float(a)));
455#endif
456}

◆ float_to_half_rtne()

EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC __half_raw Eigen::half_impl::float_to_half_rtne ( float  ff)
344 {
345#if defined(EIGEN_HAS_CUDA_FP16) && defined(EIGEN_CUDA_ARCH) && EIGEN_CUDA_ARCH >= 300
346 __half tmp_ff = __float2half(ff);
347 return *(__half_raw*)&tmp_ff;
348
349#elif defined(EIGEN_HAS_FP16_C)
350 __half_raw h;
351 h.x = _cvtss_sh(ff, 0);
352 return h;
353
354#else
355 float32_bits f; f.f = ff;
356
357 const float32_bits f32infty = { 255 << 23 };
358 const float32_bits f16max = { (127 + 16) << 23 };
359 const float32_bits denorm_magic = { ((127 - 15) + (23 - 10) + 1) << 23 };
360 unsigned int sign_mask = 0x80000000u;
361 __half_raw o;
362 o.x = static_cast<unsigned short>(0x0u);
363
364 unsigned int sign = f.u & sign_mask;
365 f.u ^= sign;
366
367 // NOTE all the integer compares in this function can be safely
368 // compiled into signed compares since all operands are below
369 // 0x80000000. Important if you want fast straight SSE2 code
370 // (since there's no unsigned PCMPGTD).
371
372 if (f.u >= f16max.u) { // result is Inf or NaN (all exponent bits set)
373 o.x = (f.u > f32infty.u) ? 0x7e00 : 0x7c00; // NaN->qNaN and Inf->Inf
374 } else { // (De)normalized number or zero
375 if (f.u < (113 << 23)) { // resulting FP16 is subnormal or zero
376 // use a magic value to align our 10 mantissa bits at the bottom of
377 // the float. as long as FP addition is round-to-nearest-even this
378 // just works.
379 f.f += denorm_magic.f;
380
381 // and one integer subtract of the bias later, we have our final float!
382 o.x = static_cast<unsigned short>(f.u - denorm_magic.u);
383 } else {
384 unsigned int mant_odd = (f.u >> 13) & 1; // resulting mantissa is odd
385
386 // update exponent, rounding bias part 1
387 f.u += ((unsigned int)(15 - 127) << 23) + 0xfff;
388 // rounding bias part 2
389 f.u += mant_odd;
390 // take the bits!
391 o.x = static_cast<unsigned short>(f.u >> 13);
392 }
393 }
394
395 o.x |= static_cast<unsigned short>(sign >> 16);
396 return o;
397#endif
398}
EIGEN_DEVICE_FUNC const SignReturnType sign() const
Definition ArrayCwiseUnaryOps.h:184
float f
Definition Half.h:341
unsigned int u
Definition Half.h:340
Definition Half.h:339
Definition Half.h:54

References Eigen::half_impl::float32_bits::f, sign(), Eigen::half_impl::float32_bits::u, and Eigen::half_impl::__half_raw::x.

+ Here is the call graph for this function:

◆ floor()

EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half Eigen::half_impl::floor ( const half a)
492 {
493#if EIGEN_CUDACC_VER >= 80000 && defined EIGEN_CUDA_ARCH && EIGEN_CUDA_ARCH >= 300
494 return half(hfloor(a));
495#else
496 return half(::floorf(float(a)));
497#endif
498}

◆ half_to_float()

EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC float Eigen::half_impl::half_to_float ( __half_raw  h)
400 {
401#if defined(EIGEN_HAS_CUDA_FP16) && defined(EIGEN_CUDA_ARCH) && EIGEN_CUDA_ARCH >= 300
402 return __half2float(h);
403
404#elif defined(EIGEN_HAS_FP16_C)
405 return _cvtsh_ss(h.x);
406
407#else
408 const float32_bits magic = { 113 << 23 };
409 const unsigned int shifted_exp = 0x7c00 << 13; // exponent mask after shift
410 float32_bits o;
411
412 o.u = (h.x & 0x7fff) << 13; // exponent/mantissa bits
413 unsigned int exp = shifted_exp & o.u; // just the exponent
414 o.u += (127 - 15) << 23; // exponent adjust
415
416 // handle exponent special cases
417 if (exp == shifted_exp) { // Inf/NaN?
418 o.u += (128 - 16) << 23; // extra exp adjust
419 } else if (exp == 0) { // Zero/Denormal?
420 o.u += 1 << 23; // extra exp adjust
421 o.f -= magic.f; // renormalize
422 }
423
424 o.u |= (h.x & 0x8000) << 16; // sign bit
425 return o.f;
426#endif
427}
EIGEN_DEVICE_FUNC const ExpReturnType exp() const
Definition ArrayCwiseUnaryOps.h:88

References exp(), Eigen::half_impl::float32_bits::f, Eigen::half_impl::float32_bits::u, and Eigen::half_impl::__half_raw::x.

Referenced by Eigen::half::EIGEN_EXPLICIT_CAST(), Eigen::half::EIGEN_EXPLICIT_CAST(), Eigen::half::EIGEN_EXPLICIT_CAST(), Eigen::half::EIGEN_EXPLICIT_CAST(), Eigen::half::EIGEN_EXPLICIT_CAST(), Eigen::half::EIGEN_EXPLICIT_CAST(), Eigen::half::EIGEN_EXPLICIT_CAST(), Eigen::half::EIGEN_EXPLICIT_CAST(), Eigen::half::EIGEN_EXPLICIT_CAST(), Eigen::half::EIGEN_EXPLICIT_CAST(), and Eigen::half::EIGEN_EXPLICIT_CAST().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isfinite()

EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool() Eigen::half_impl::isfinite ( const half a)
441 {
442 return !(isinf EIGEN_NOT_A_MACRO (a)) && !(isnan EIGEN_NOT_A_MACRO (a));
443}
#define EIGEN_NOT_A_MACRO
Definition Macros.h:327
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool() isinf(const half &a)
Definition Half.h:431

References EIGEN_NOT_A_MACRO, isinf(), and isnan().

+ Here is the call graph for this function:

◆ isinf()

EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool() Eigen::half_impl::isinf ( const half a)
431 {
432 return (a.x & 0x7fff) == 0x7c00;
433}

Referenced by isfinite().

+ Here is the caller graph for this function:

◆ isnan()

EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool() Eigen::half_impl::isnan ( const half a)
434 {
435#if defined(EIGEN_HAS_CUDA_FP16) && defined(EIGEN_CUDA_ARCH) && EIGEN_CUDA_ARCH >= 530
436 return __hisnan(a);
437#else
438 return (a.x & 0x7fff) > 0x7c00;
439#endif
440}

Referenced by isfinite().

+ Here is the caller graph for this function:

◆ log()

EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half Eigen::half_impl::log ( const half a)
457 {
458#if defined(EIGEN_HAS_CUDA_FP16) && EIGEN_CUDACC_VER >= 80000 && defined(EIGEN_CUDA_ARCH) && EIGEN_CUDA_ARCH >= 530
459 return half(::hlog(a));
460#else
461 return half(::logf(float(a)));
462#endif
463}

◆ log10()

EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half Eigen::half_impl::log10 ( const half a)
467 {
468 return half(::log10f(float(a)));
469}

◆ log1p()

EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half Eigen::half_impl::log1p ( const half a)
464 {
465 return half(numext::log1p(float(a)));
466}

◆ max()

EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half() Eigen::half_impl::max ( const half a,
const half b 
)
516 {
517#if defined(EIGEN_HAS_CUDA_FP16) && defined(EIGEN_CUDA_ARCH) && EIGEN_CUDA_ARCH >= 530
518 return __hlt(a, b) ? b : a;
519#else
520 const float f1 = static_cast<float>(a);
521 const float f2 = static_cast<float>(b);
522 return f1 < f2 ? b : a;
523#endif
524}

◆ min()

EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half() Eigen::half_impl::min ( const half a,
const half b 
)
507 {
508#if defined(EIGEN_HAS_CUDA_FP16) && defined(EIGEN_CUDA_ARCH) && EIGEN_CUDA_ARCH >= 530
509 return __hlt(b, a) ? b : a;
510#else
511 const float f1 = static_cast<float>(a);
512 const float f2 = static_cast<float>(b);
513 return f2 < f1 ? b : a;
514#endif
515}

◆ operator!=()

EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool Eigen::half_impl::operator!= ( const half a,
const half b 
)
304 {
305 return numext::not_equal_strict(float(a), float(b));
306}

References Eigen::numext::not_equal_strict().

+ Here is the call graph for this function:

◆ operator*()

EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half Eigen::half_impl::operator* ( const half a,
const half b 
)
271 {
272 return half(float(a) * float(b));
273}

◆ operator*=()

EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half & Eigen::half_impl::operator*= ( half a,
const half b 
)
289 {
290 a = half(float(a) * float(b));
291 return a;
292}

◆ operator+()

EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half Eigen::half_impl::operator+ ( const half a,
const half b 
)
268 {
269 return half(float(a) + float(b));
270}

◆ operator+=()

EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half & Eigen::half_impl::operator+= ( half a,
const half b 
)
285 {
286 a = half(float(a) + float(b));
287 return a;
288}

◆ operator-() [1/2]

EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half Eigen::half_impl::operator- ( const half a)
280 {
281 half result;
282 result.x = a.x ^ 0x8000;
283 return result;
284}

References Eigen::half_impl::__half_raw::x.

◆ operator-() [2/2]

EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half Eigen::half_impl::operator- ( const half a,
const half b 
)
274 {
275 return half(float(a) - float(b));
276}

◆ operator-=()

EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half & Eigen::half_impl::operator-= ( half a,
const half b 
)
293 {
294 a = half(float(a) - float(b));
295 return a;
296}

◆ operator/() [1/2]

EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half Eigen::half_impl::operator/ ( const half a,
const half b 
)
277 {
278 return half(float(a) / float(b));
279}

◆ operator/() [2/2]

EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half Eigen::half_impl::operator/ ( const half a,
Index  b 
)
324 {
325 return half(static_cast<float>(a) / static_cast<float>(b));
326}

◆ operator/=()

EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half & Eigen::half_impl::operator/= ( half a,
const half b 
)
297 {
298 a = half(float(a) / float(b));
299 return a;
300}

◆ operator<()

EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool Eigen::half_impl::operator< ( const half a,
const half b 
)
307 {
308 return float(a) < float(b);
309}

◆ operator<<()

EIGEN_ALWAYS_INLINE std::ostream & Eigen::half_impl::operator<< ( std::ostream &  os,
const half v 
)
526 {
527 os << static_cast<float>(v);
528 return os;
529}

◆ operator<=()

EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool Eigen::half_impl::operator<= ( const half a,
const half b 
)
310 {
311 return float(a) <= float(b);
312}

◆ operator==()

EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool Eigen::half_impl::operator== ( const half a,
const half b 
)
301 {
302 return numext::equal_strict(float(a),float(b));
303}

References Eigen::numext::equal_strict().

+ Here is the call graph for this function:

◆ operator>()

EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool Eigen::half_impl::operator> ( const half a,
const half b 
)
313 {
314 return float(a) > float(b);
315}

◆ operator>=()

EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool Eigen::half_impl::operator>= ( const half a,
const half b 
)
316 {
317 return float(a) >= float(b);
318}

◆ pow()

EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half Eigen::half_impl::pow ( const half a,
const half b 
)
477 {
478 return half(::powf(float(a), float(b)));
479}

◆ raw_uint16_to_half()

◆ sin()

EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half Eigen::half_impl::sin ( const half a)
480 {
481 return half(::sinf(float(a)));
482}

◆ sqrt()

EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half Eigen::half_impl::sqrt ( const half a)
470 {
471#if EIGEN_CUDACC_VER >= 80000 && defined EIGEN_CUDA_ARCH && EIGEN_CUDA_ARCH >= 530
472 return half(hsqrt(a));
473#else
474 return half(::sqrtf(float(a)));
475#endif
476}

◆ tan()

EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half Eigen::half_impl::tan ( const half a)
486 {
487 return half(::tanf(float(a)));
488}

◆ tanh()

EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half Eigen::half_impl::tanh ( const half a)
489 {
490 return half(::tanhf(float(a)));
491}