#include "ggml.h" #include #include int main(int argc,char**argv){ if(argc<3) return 2; long nrows=atol(argv[1]), np=atol(argv[2]); long n=nrows*np; float *src=malloc(n*sizeof(float)); if(fread(src,sizeof(float),n,stdin)!=(size_t)n){fprintf(stderr,"read fail\n");return 3;} size_t nb=ggml_row_size(GGML_TYPE_Q4_K,np); unsigned char *dst=malloc(nb*nrows); ggml_quantize_init(GGML_TYPE_Q4_K); size_t got=ggml_quantize_chunk(GGML_TYPE_Q4_K,src,dst,0,nrows,np,NULL); if(got!=nb*nrows){fprintf(stderr,"quant size mismatch %zu %zu\n",got,nb*nrows);return 4;} fwrite(dst,1,got,stdout); return 0; }