#include <math.h>
#include <stdio.h>
#include <string.h>

#include "../src/bio_quant.h"

int main(void) {
    uint8_t data[256];
    uint32_t tokens[4] = {1u, 2u, 3u, 4u};
    float scalar[32];
    float avx[32];
    bio_gguf_tensor_span tensor;
    for (uint32_t i = 0; i < sizeof(data); ++i) {
        data[i] = (uint8_t)i;
    }
    memset(&tensor, 0, sizeof(tensor));
    tensor.data = data;
    tensor.byte_size = sizeof(data);
    tensor.ggml_type = BIO_GGUF_TYPE_Q4_K;
    if (bio_quant_project_scalar(&tensor, tokens, 4u, scalar, 32u) != BIO_OK ||
        bio_quant_project_avx2(&tensor, tokens, 4u, avx, 32u) != BIO_OK) {
        fprintf(stderr, "quant projection failed\n");
        return 1;
    }
    for (uint32_t i = 0; i < 32u; ++i) {
        if (fabsf(scalar[i] - avx[i]) > 0.0001f) {
            fprintf(stderr, "quant parity failed\n");
            return 1;
        }
    }
    puts("bio-tests: quant projection parity ok");
    return 0;
}
