[ROCm]: Fix build from source failure with gcc14 and ROCm 6.3 (#13779)

Signed-off-by: Arjun Kathuria <arjun.kathuria8@gmail.com>
This commit is contained in:
Arjun Kathuria
2025-05-13 09:06:33 +05:30
committed by GitHub
parent c06af9a959
commit d8487ef557
2 changed files with 21 additions and 3 deletions

View File

@@ -21,7 +21,13 @@ static __device__ __forceinline__ int8_t float_to_int8_rn(float const x) {
// round
float dst = std::nearbyint(x);
// saturate
dst = std::clamp(dst, i8_min, i8_max);
// See https://github.com/pytorch/pytorch/issues/127666
// See https://github.com/llvm/llvm-project/issues/95183
// hip-clang std::clamp __glibcxx_assert_fail host function when building on
// Arch/gcc14. The following replaces std::clamp usage with similar logic
// dst = std::clamp(dst, i8_min, i8_max);
dst = (dst < i8_min) ? i8_min : (dst > i8_max) ? i8_max : dst;
return static_cast<int8_t>(dst);
#else
// CUDA path