Skip to content

Commit 338d9ac

Browse files
committed
opencl: do sqrt in f32 then convert to f16 for better precision
1 parent 2dd65e4 commit 338d9ac

File tree

1 file changed

+2
-2
lines changed
  • ggml/src/ggml-opencl/kernels

1 file changed

+2
-2
lines changed

ggml/src/ggml-opencl/kernels/sqrt.cl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ kernel void kernel_sqrt_cont_f16(
3636
dst = (global half*)((global char*)dst + offsetd);
3737

3838
uint gid = get_global_id(0);
39-
dst[gid] = sqrt(src0[gid]);
39+
dst[gid] = convert_half(sqrt(convert_float(src0[gid])));
4040
}
4141

4242
kernel void kernel_sqrt_cont_f16_4(
@@ -49,5 +49,5 @@ kernel void kernel_sqrt_cont_f16_4(
4949
dst = (global half4*)((global char*)dst + offsetd);
5050

5151
uint gid = get_global_id(0);
52-
dst[gid] = sqrt(src0[gid]);
52+
dst[gid] = convert_half4(sqrt(convert_float4(src0[gid])));
5353
}

0 commit comments

Comments
 (0)