From c9edc01c0b02f2d31020ac4bc06631f755403d3b Mon Sep 17 00:00:00 2001 From: Jeff Daily Date: Tue, 13 Dec 2022 15:34:42 -0800 Subject: [PATCH] [ROCm] float16.h should use __HIP__ not USE_ROCM (#13684) The float16.h header is shared between the CPU and ROCm EPs. The USE_ROCM macro is defined universally, but for the float16.h header we only wish to detect the hip-clang compiler. Otherwise, the CPU EP fails to build because of -Werror -Wuninitialized caused by the USE_ROCM code additions, and the CPU EP should be using a different code path. --- include/onnxruntime/core/framework/float16.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/onnxruntime/core/framework/float16.h b/include/onnxruntime/core/framework/float16.h index 598f3748af..290a5e7f2f 100644 --- a/include/onnxruntime/core/framework/float16.h +++ b/include/onnxruntime/core/framework/float16.h @@ -41,7 +41,7 @@ inline bool operator<(const MLFloat16& left, const MLFloat16& right) { return le // BFloat16 struct BFloat16 { uint16_t val{0}; -#if defined(USE_ROCM) +#if defined(__HIP__) ORT_HOST_DEVICE BFloat16() = default; #else BFloat16() = default; @@ -54,7 +54,7 @@ struct BFloat16 { inline ORT_HOST_DEVICE BFloat16(float v) { #if defined(CUDA_VERSION) && CUDA_VERSION >= 11000 && defined(__CUDA_ARCH__) && __CUDA_ARCH__ >= 800 val = __bfloat16_as_ushort(__float2bfloat16(v)); -#elif defined(USE_ROCM) +#elif defined(__HIP__) // We should be using memcpy in order to respect the strict aliasing rule but it fails in the HIP environment. if (v != v) { // isnan val = UINT16_C(0x7FC0); @@ -81,7 +81,7 @@ struct BFloat16 { inline ORT_HOST_DEVICE float ToFloat() const { #if defined(CUDA_VERSION) && CUDA_VERSION >= 11000 return __bfloat162float(*reinterpret_cast(&val)); -#elif defined(USE_ROCM) +#elif defined(__HIP__) // We should be using memcpy in order to respect the strict aliasing rule but it fails in the HIP environment. float result = 0; uint32_t tmp = val;