Improve the testing of the optimized quantized vec-dot ops (#1016)

* Expose the unopt functions for testing.

* Better testing of the optimized quantized computations.
This commit is contained in:
Laurent Mazare
2023-10-02 09:50:43 +01:00
committed by GitHub
parent 5130a7da32
commit 263a172202
3 changed files with 75 additions and 5 deletions

View File

@ -100,8 +100,15 @@ fn ggml_matmul_error_test<T: GgmlType>() -> Result<()> {
T::VecDotType::from_float(&b, &mut b_quant)?;
let result = T::vec_dot(length, &a_quant, &b_quant)?;
let result_unopt = T::vec_dot_unopt(length, &a_quant, &b_quant)?;
let reference_result = vec_dot_reference(&a, &b);
if (result - result_unopt).abs() / length as f32 > 1e-6 {
candle::bail!(
"the opt and unopt vec-dot returned different values, opt {result}, unopt {result_unopt}"
)
}
let error = (result - reference_result).abs() / length as f32;
let ggml_error = ggml_reference_matmul_error(T::DTYPE)?;