| 142 | } |
| 143 | |
| 144 | static 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 |
no test coverage detected