MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / quantize_f32_rows

Function quantize_f32_rows

src/framework/assets/tensor_source.cpp:99–135  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

97 (normalized == "q3_k" && type == GGML_TYPE_Q3_K) ||
98 (normalized == "q4_k" && type == GGML_TYPE_Q4_K) ||
99 (normalized == "q5_k" && type == GGML_TYPE_Q5_K) ||
100 (normalized == "q6_k" && type == GGML_TYPE_Q6_K) ||
101 (normalized == "q8_0" && type == GGML_TYPE_Q8_0);
102}
103
104ggml_type parse_ggml_type_for_tensor_dtype(std::string_view dtype) {
105 const std::string normalized = lower_ascii(dtype);
106 if (normalized == "f32" || normalized == "float32") return GGML_TYPE_F32;
107 if (normalized == "f16" || normalized == "float16" || normalized == "fp16") return GGML_TYPE_F16;
108 if (normalized == "bf16" || normalized == "bfloat16") return GGML_TYPE_BF16;
109 if (normalized == "i8" || normalized == "int8") return GGML_TYPE_I8;
110 if (normalized == "bool" || normalized == "boolean") return GGML_TYPE_I8;
111 if (normalized == "i16" || normalized == "int16") return GGML_TYPE_I16;
112 if (normalized == "i32" || normalized == "int32") return GGML_TYPE_I32;
113 if (normalized == "i64" || normalized == "int64") return GGML_TYPE_I64;
114 if (normalized == "q4_0") return GGML_TYPE_Q4_0;
115 if (normalized == "q4_1") return GGML_TYPE_Q4_1;
116 if (normalized == "q5_0") return GGML_TYPE_Q5_0;
117 if (normalized == "q5_1") return GGML_TYPE_Q5_1;
118 if (normalized == "q8_0") return GGML_TYPE_Q8_0;
119 if (normalized == "q2_k") return GGML_TYPE_Q2_K;
120 if (normalized == "q3_k") return GGML_TYPE_Q3_K;
121 if (normalized == "q4_k") return GGML_TYPE_Q4_K;
122 if (normalized == "q5_k") return GGML_TYPE_Q5_K;
123 if (normalized == "q6_k") return GGML_TYPE_Q6_K;
124 throw std::runtime_error("unsupported tensor dtype for GGUF: " + std::string(dtype));
125}
126
127std::string dtype_for_ggml_type(ggml_type type) {
128 const char * name = ggml_type_name(type);
129 if (name == nullptr) {
130 throw std::runtime_error("GGUF tensor has an unknown ggml type");
131 }
132 return lower_ascii(name);
133}
134
135void validate_raw_tensor_byte_size(std::string_view name, const core::TensorShape & shape, ggml_type type, size_t bytes) {
136 const size_t expected = static_cast<size_t>(shape.prefix_elements()) *
137 ggml_row_size(type, shape.last_dim());
138 if (bytes != expected) {

Callers 2

encode_f32_tensor_dataFunction · 0.85

Calls 10

ggml_is_quantizedFunction · 0.85
ggml_blck_sizeFunction · 0.85
ggml_row_sizeFunction · 0.85
ggml_quantize_chunkFunction · 0.85
last_dimMethod · 0.80
prefix_elementsMethod · 0.80
stringFunction · 0.50
sizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected