MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / test_roundtrip_on_chunk

Function test_roundtrip_on_chunk

examples/quantize-stats/quantize-stats.cpp:144–164  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

142}
143
144static void test_roundtrip_on_chunk(
145 const ggml_tensor * layer, int64_t offset, int64_t chunk_size, const ggml_type_traits_t & qfns, bool use_reference,
146 float * input_scratch, char * quantized_scratch, float * output_scratch, error_stats & stats
147) {
148 if (layer->type == GGML_TYPE_F16) {
149 for (int i = 0; i < chunk_size; i++) {
150 input_scratch[i] = ggml_get_f32_1d(layer, i + offset);
151 }
152 } else {
153 input_scratch = ggml_get_data_f32(layer) + offset;
154 }
155
156 if (use_reference) {
157 qfns.from_float_reference(input_scratch, quantized_scratch, chunk_size);
158 } else {
159 qfns.from_float(input_scratch, quantized_scratch, chunk_size);
160 }
161 qfns.to_float(quantized_scratch, output_scratch, chunk_size);
162
163 update_error_stats(chunk_size, input_scratch, output_scratch, stats);
164}
165
166
167// Run quantization function for a single layer and update error stats

Callers 1

test_roundtrip_on_layerFunction · 0.70

Calls 3

update_error_statsFunction · 0.70
ggml_get_f32_1dFunction · 0.50
ggml_get_data_f32Function · 0.50

Tested by

no test coverage detected