You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
815 B
30 lines
815 B
struct MatrixBatch {
|
|
size: vec4<u32>,
|
|
data: array<f32>,
|
|
}
|
|
|
|
@group(0) @binding(0)
|
|
var<storage, read> ilogits: MatrixBatch;
|
|
@group(0) @binding(1)
|
|
var<storage, read> inp: MatrixBatch;
|
|
@group(0) @binding(2)
|
|
var<storage, read> pos: MatrixBatch;
|
|
@group(0) @binding(3)
|
|
var<storage, read_write> r: MatrixBatch;
|
|
|
|
@compute @workgroup_size(1)
|
|
fn main(@builtin(global_invocation_id) global_id: vec3<u32>) {
|
|
r.size = pos.size;
|
|
|
|
var s = 0f;
|
|
var li = (global_id.z * ilogits.size.y + global_id.y) * ilogits.size.x;
|
|
var ri = global_id.z * inp.size.x * inp.size.y + global_id.x;
|
|
for (var i = 0u; i < ilogits.size.x; i++) {
|
|
s += ilogits.data[li] * inp.data[ri];
|
|
li++;
|
|
ri += inp.size.x;
|
|
}
|
|
|
|
var resi = (global_id.z * r.size.y + global_id.y) * r.size.x + global_id.x;
|
|
r.data[resi] = s + pos.data[resi];
|
|
}
|
|
|