Download ggml_deq.cpp from HelloSun/openPangu-2.0-Flash-base-Q3_K_M_EPQ: direct link, hf CLI and curl.
- Browser
- Download file 1.58 kB
-
https://huggingface.co/HelloSun/openPangu-2.0-Flash-base-Q3_K_M_EPQ/resolve/main/ggml_deq.cpp
- Command line
-
hf download hf://HelloSun/openPangu-2.0-Flash-base-Q3_K_M_EPQ/ggml_deq.cpp
-
curl -L -o ggml_deq.cpp https://huggingface.co/HelloSun/openPangu-2.0-Flash-base-Q3_K_M_EPQ/resolve/main/ggml_deq.cpp
1.58 kB
| // Dump one ggml-dequantized row so the NumPy reference can be checked against | |
| // ggml's own dequantizers. usage: ggml_deq <type> <file> <offset> <n> | |
| int main(int argc, char ** argv) { | |
| if (argc < 5) { | |
| fprintf(stderr, "usage: %s <type> <file> <offset> <n>\n", argv[0]); | |
| return 1; | |
| } | |
| const int tt = atoi(argv[1]); | |
| const char * path = argv[2]; | |
| const long long off = atoll(argv[3]); | |
| const int n = atoi(argv[4]); | |
| FILE * f = fopen(path, "rb"); | |
| if (!f) { perror("open"); return 1; } | |
| const size_t ts = ggml_row_size((ggml_type) tt, n); | |
| void * buf = malloc(ts); | |
| if (fseek(f, (long) off, SEEK_SET) != 0) { fprintf(stderr, "seek\n"); return 1; } | |
| if (fread(buf, 1, ts, f) != ts) { fprintf(stderr, "short read\n"); return 1; } | |
| fclose(f); | |
| float * y = (float *) malloc(sizeof(float) * n); | |
| switch (tt) { | |
| case 11: dequantize_row_q3_K((const block_q3_K *) buf, y, n); break; | |
| case 12: dequantize_row_q4_K((const block_q4_K *) buf, y, n); break; | |
| case 13: dequantize_row_q5_K((const block_q5_K *) buf, y, n); break; | |
| case 14: dequantize_row_q6_K((const block_q6_K *) buf, y, n); break; | |
| case 7: dequantize_row_q5_1((const block_q5_1 *) buf, y, n); break; | |
| case 8: dequantize_row_q8_0((const block_q8_0 *) buf, y, n); break; | |
| default: fprintf(stderr, "type %d not handled\n", tt); return 1; | |
| } | |
| fwrite(y, sizeof(float), n, stdout); | |
| free(y); | |
| free(buf); | |
| return 0; | |
| } | |