diff --git a/include/onnxruntime/core/session/onnxruntime_cxx_api.h b/include/onnxruntime/core/session/onnxruntime_cxx_api.h index c4a3ec047e..ff73f3d93d 100644 --- a/include/onnxruntime/core/session/onnxruntime_cxx_api.h +++ b/include/onnxruntime/core/session/onnxruntime_cxx_api.h @@ -179,9 +179,9 @@ struct Float16_t : onnxruntime_float16::Float16Impl { Float16_t() = default; /// - /// Explicit conversion to uint16_t representation of bfloat16. + /// Explicit conversion to uint16_t representation of float16. /// - /// uint16_t bit representation of bfloat16 + /// uint16_t bit representation of float16 /// new instance of Float16_t constexpr static Float16_t FromBits(uint16_t v) noexcept { return Float16_t(v); } @@ -192,9 +192,9 @@ struct Float16_t : onnxruntime_float16::Float16Impl { explicit Float16_t(float v) noexcept { val = Base::ToUint16Impl(v); } /// - /// Converts bfloat16 to float + /// Converts float16 to float /// - /// float representation of bfloat16 value + /// float representation of float16 value float ToFloat() const noexcept { return Base::ToFloatImpl(); } /// diff --git a/include/onnxruntime/core/session/onnxruntime_float16.h b/include/onnxruntime/core/session/onnxruntime_float16.h index 6a16f685ca..0b066a9cc9 100644 --- a/include/onnxruntime/core/session/onnxruntime_float16.h +++ b/include/onnxruntime/core/session/onnxruntime_float16.h @@ -310,7 +310,16 @@ inline float Float16Impl::ToFloatImpl() const noexcept { o.f -= magic.f; // re-normalize } - o.u |= (val & 0x8000) << 16; // sign bit + // Attempt to workaround the Internal Compiler Error on ARM64 + // for bitwise | operator, including std::bitset +#if (defined _MSC_VER) && (defined _M_ARM || defined _M_ARM64 || defined _M_ARM64EC) + if (IsNegative()) { + return -o.f; + } +#else + // original code: + o.u |= (val & 0x8000U) << 16U; // sign bit +#endif return o.f; }