MCPcopy Create free account
hub / github.com/antirez/ds4 / tensor_to_f32

Function tensor_to_f32

gguf-tools/deepseek4-quantize.c:660–681  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

658 free(keys);
659 json_free(&d);
660 free(header);
661 s->fp = fp;
662 s->loaded = true;
663}
664
665static void db_open(st_db *db, const char *hf_dir) {
666 memset(db, 0, sizeof(*db));
667 pthread_mutex_init(&db->lock, NULL);
668 db->hf_dir = xstrdup(hf_dir);
669 char *index_path = path_join(hf_dir, "model.safetensors.index.json");
670 size_t len = 0;
671 char *text = read_file(index_path, &len);
672 json_doc d = json_parse_text(text, len);
673 int weight_map = json_obj_get(&d, 0, "weight_map");
674 if (weight_map < 0 || d.v[weight_map].type != JT_OBJECT) die("safetensors index has no weight_map");
675
676 int cap = 4096;
677 db->weights = xmalloc((size_t)cap * sizeof(db->weights[0]));
678 for (int i = weight_map + 1; i < d.len && d.v[i].parent == weight_map;) {
679 int k = i;
680 int v = i + 1;
681 if (db->n_weights == cap) {
682 cap *= 2;
683 db->weights = xrealloc(db->weights, (size_t)cap * sizeof(db->weights[0]));
684 }

Callers 1

generate_regularFunction · 0.85

Calls 7

value_nelementsFunction · 0.85
bf16_to_f32_bitsFunction · 0.85
load_u16_leFunction · 0.85
ds4q_f16_to_f32Function · 0.85
e4m3fn_to_f32Function · 0.85
xmallocFunction · 0.70
dieFunction · 0.70

Tested by

no test coverage detected