Skip to content

Commit d21cb54

Browse files
committed
Generalize quantize_fns for simpler FP16 handling
1 parent 0b5a935 commit d21cb54

File tree

7 files changed

+141
-456
lines changed

7 files changed

+141
-456
lines changed

examples/quantize-stats/quantize-stats.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ void test_roundtrip_on_chunk(
142142
const ggml_tensor * layer,
143143
int64_t offset,
144144
int64_t chunk_size,
145-
const quantize_fns_t & qfns,
145+
const ggml_type_handling_t & qfns,
146146
bool use_reference,
147147
float * input_scratch,
148148
char * quantized_scratch,
@@ -158,11 +158,11 @@ void test_roundtrip_on_chunk(
158158
}
159159

160160
if (use_reference) {
161-
qfns.quantize_row_q_reference(input_scratch, quantized_scratch, chunk_size);
161+
qfns.from_float_reference(input_scratch, quantized_scratch, chunk_size);
162162
} else {
163-
qfns.quantize_row_q(input_scratch, quantized_scratch, chunk_size);
163+
qfns.from_float(input_scratch, quantized_scratch, chunk_size);
164164
}
165-
qfns.dequantize_row_q(quantized_scratch, output_scratch, chunk_size);
165+
qfns.to_float(quantized_scratch, output_scratch, chunk_size);
166166

167167
update_error_stats(chunk_size, input_scratch, output_scratch, stats);
168168
}
@@ -172,7 +172,7 @@ void test_roundtrip_on_chunk(
172172
void test_roundtrip_on_layer(
173173
std::string & name,
174174
bool print_layer_stats,
175-
const quantize_fns_t & qfns,
175+
const ggml_type_handling_t & qfns,
176176
bool use_reference,
177177
const ggml_tensor * layer,
178178
std::vector<float> & input_scratch,
@@ -371,8 +371,8 @@ int main(int argc, char ** argv) {
371371
if (!params.include_types.empty() && std::find(params.include_types.begin(), params.include_types.end(), i) == params.include_types.end()) {
372372
continue;
373373
}
374-
quantize_fns_t qfns = ggml_internal_get_quantize_fn(i);
375-
if (qfns.quantize_row_q && qfns.dequantize_row_q) {
374+
ggml_type_handling_t qfns = ggml_internal_get_type_handling(type);
375+
if (qfns.from_float && qfns.to_float) {
376376
if (params.verbose) {
377377
printf("testing %s ...\n", ggml_type_name(type));
378378
}

0 commit comments

Comments
 (0)