aboutsummaryrefslogtreecommitdiff
path: root/llama.cpp/ggml/src/ggml-opencl/kernels/sqrt.cl
blob: c59fbe06a615271c94ae29a38d1c8094743c8333 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#pragma OPENCL EXTENSION cl_khr_fp16 : enable

kernel void kernel_sqrt_cont_f32(
    global float * src0,
    ulong          offset0,
    global float * dst,
    ulong          offsetd
) {
    src0 = (global float*)((global char*)src0 + offset0);
    dst  = (global float*)((global char*)dst + offsetd);

    uint gid = get_global_id(0);
    dst[gid] = sqrt(src0[gid]);
}

kernel void kernel_sqrt_cont_f32_4(
    global float4 * src0,
    ulong           offset0,
    global float4 * dst,
    ulong           offsetd
) {
    src0 = (global float4*)((global char*)src0 + offset0);
    dst  = (global float4*)((global char*)dst + offsetd);

    uint gid = get_global_id(0);
    dst[gid] = sqrt(src0[gid]);
}

kernel void kernel_sqrt_cont_f16(
    global half * src0,
    ulong         offset0,
    global half * dst,
    ulong         offsetd
) {
    src0 = (global half*)((global char*)src0 + offset0);
    dst  = (global half*)((global char*)dst + offsetd);

    uint gid = get_global_id(0);
    dst[gid] = convert_half(sqrt(convert_float(src0[gid])));
}

kernel void kernel_sqrt_cont_f16_4(
    global half4 * src0,
    ulong          offset0,
    global half4 * dst,
    ulong          offsetd
) {
    src0 = (global half4*)((global char*)src0 + offset0);
    dst  = (global half4*)((global char*)dst + offsetd);

    uint gid = get_global_id(0);
    dst[gid] = convert_half4(sqrt(convert_float4(src0[gid])));
}