HelloSun's picture
Pipeline stage P2: explain and fix refiner Q8_0 slowdown, V-pack hoist + 128x128 flash-attn tiles
111541a
Raw History Blame Contribute Delete
660 Bytes
#include "ggml.h"
#include <stdio.h>
#include <stdlib.h>
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;
}