mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-05-19 21:32:23 +00:00
Work on eliminating Internal Compiler Error (#16741)
### Description <!-- Describe your changes. --> Replace the offending bitwise `operator |` with if() logic for ARM.
This commit is contained in:
parent
b71ebf91a5
commit
e752cbe7f2
2 changed files with 14 additions and 5 deletions
|
|
@ -179,9 +179,9 @@ struct Float16_t : onnxruntime_float16::Float16Impl<Float16_t> {
|
|||
Float16_t() = default;
|
||||
|
||||
/// <summary>
|
||||
/// Explicit conversion to uint16_t representation of bfloat16.
|
||||
/// Explicit conversion to uint16_t representation of float16.
|
||||
/// </summary>
|
||||
/// <param name="v">uint16_t bit representation of bfloat16</param>
|
||||
/// <param name="v">uint16_t bit representation of float16</param>
|
||||
/// <returns>new instance of Float16_t</returns>
|
||||
constexpr static Float16_t FromBits(uint16_t v) noexcept { return Float16_t(v); }
|
||||
|
||||
|
|
@ -192,9 +192,9 @@ struct Float16_t : onnxruntime_float16::Float16Impl<Float16_t> {
|
|||
explicit Float16_t(float v) noexcept { val = Base::ToUint16Impl(v); }
|
||||
|
||||
/// <summary>
|
||||
/// Converts bfloat16 to float
|
||||
/// Converts float16 to float
|
||||
/// </summary>
|
||||
/// <returns>float representation of bfloat16 value</returns>
|
||||
/// <returns>float representation of float16 value</returns>
|
||||
float ToFloat() const noexcept { return Base::ToFloatImpl(); }
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -310,7 +310,16 @@ inline float Float16Impl<Derived>::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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue