Skip to content

Commit

Permalink
fix stack buffer overflow in float to half conversion (#118)
Browse files Browse the repository at this point in the history
Co-authored-by: Alejandro Acosta <[email protected]>
  • Loading branch information
AD2605 and aacostadiaz authored Aug 12, 2024
1 parent 9837af2 commit dfed8f9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions include/cutlass/half.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ struct alignas(2) half_t {
#if defined(__CUDA_ARCH__) && (__CUDA_ARCH__ >= 530)
return half_t(__float2half_rn(flt));
#elif defined(CUTLASS_ENABLE_SYCL)
return static_cast<half_t>(flt);
return half_t(half(flt));
#else

#if !defined(__CUDA_ARCH__) && CUTLASS_ENABLE_F16C
Expand Down Expand Up @@ -281,7 +281,7 @@ struct alignas(2) half_t {
#if defined(__CUDA_ARCH__) && (__CUDA_ARCH__ >= 530)
return half_t(__int2half_rn(n));
#elif defined(CUTLASS_ENABLE_SYCL)
return static_cast<half_t>(n);
return half_t(half(n));
#else
return convert(float(n));
#endif
Expand All @@ -293,7 +293,7 @@ struct alignas(2) half_t {
#if defined(__CUDA_ARCH__) && (__CUDA_ARCH__ >= 530)
return half_t(__uint2half_rn(n));
#elif defined(CUTLASS_ENABLE_SYCL)
return static_cast<half_t>(n);
return half_t(half(n));
#else
return convert(float(n));
#endif
Expand Down

0 comments on commit dfed8f9

Please sign in to comment.