interplane.Get Omega
Read in your language

ggml

[Ported from github.com/ggml-org/ggml] docs : sync ggml_type enum in gguf.md (#1685)

Brought by drakestapleton

branch master Branches Tags History

ggml / src / ggml-vulkan / vulkan-shaders / col2im_1d.comp

61 lines · 1792 bytes Raw Blame History
1#version 450
2
3#include "types.glsl"
4
5layout (binding = 0) readonly buffer A {A_TYPE data_a[];}; // columns: [K_OC, T_in]
6layout (binding = 1) writeonly buffer D {D_TYPE data_d[];}; // output: [T_out, OC]
7
8layout(local_size_x = 256, local_size_y = 1, local_size_z = 1) in;
9
10layout (push_constant) uniform parameter {
11 uint32_t T_out;
12 uint32_t OC;
13 uint32_t K_OC;
14 uint32_t T_in;
15 uint32_t K;
16 int32_t stride;
17 int32_t p0;
18} p;
19
20// Load A_TYPE to float
21float load_col(uint32_t idx) {
22#if defined(DATA_A_BF16)
23 return bf16_to_fp32(uint32_t(data_a[idx]));
24#else
25 return float(data_a[idx]);
26#endif
27}
28
29// Store float as D_TYPE
30void store_dst(uint32_t idx, float v) {
31#if defined(DATA_A_BF16)
32 data_d[idx] = D_TYPE(fp32_to_bf16(v));
33#else
34 data_d[idx] = D_TYPE(v);
35#endif
36}
37
38void main() {
39 const uint32_t t_out = gl_GlobalInvocationID.x;
40 const uint32_t oc = gl_GlobalInvocationID.y;
41 if (t_out >= p.T_out || oc >= p.OC) return;
42
43 const int32_t t_abs = int32_t(t_out) + p.p0; // absolute position in uncropped signal
44
45 // Gather: only the ceil(K/stride) columns that scatter into t_abs, no modulo
46 int32_t t_in_min = (t_abs - int32_t(p.K) + p.stride) / p.stride;
47 if (t_in_min < 0) t_in_min = 0;
48 int32_t t_in_max = t_abs / p.stride;
49 if (t_in_max >= int32_t(p.T_in)) t_in_max = int32_t(p.T_in) - 1;
50
51 float val = 0.0;
52 for (int32_t t_in = t_in_min; t_in <= t_in_max; t_in++) {
53 int32_t k = t_abs - t_in * p.stride;
54 // col layout: [K_OC, T_in], column index = oc * K + k
55 uint32_t col_idx = (oc * p.K + uint32_t(k)) + uint32_t(t_in) * p.K_OC;
56 val += load_col(col_idx);
57 }
58
59 // dst layout: [T_out, OC], element (t_out, oc) = t_out + oc * T_out
60 store_dst(t_out + oc * p.T_out, val);
61}