Skip to content

Commit e2cb7ea

Browse files
committed
CUDA/HIP: also specialize conversion nv_bfloat16 <-> int
1 parent 1e3a92b commit e2cb7ea

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

ggml/src/ggml-cuda/convert.cuh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,15 @@ __host__ __device__ inline nv_bfloat16 ggml_cuda_convert_val<half, nv_bfloat16>(
7070
{
7171
return __float2bfloat16(float(x));
7272
}
73+
74+
template<>
75+
__host__ __device__ inline int ggml_cuda_convert_val<nv_bfloat16, int>(nv_bfloat16 x)
76+
{
77+
return int(__bfloat162float(x));
78+
}
79+
80+
template<>
81+
__host__ __device__ inline nv_bfloat16 ggml_cuda_convert_val<int, nv_bfloat16>(int x)
82+
{
83+
return __float2bfloat16(float(x));
84+
}

0 commit comments

Comments
 (0)