From 0f33afbe56cd1124e1ea16c937411c01f7fa2519 Mon Sep 17 00:00:00 2001 From: Millaguie Date: Mon, 10 Aug 2026 18:48:19 +0200 Subject: [PATCH] tests : declare the generic DT3 vec_dot weak in the parity test Builds without a native DT3 kernel rename the generic symbol to ggml_vec_dot_dt3_q8_0 (arch-fallback.h), so test-dt3 failed to link on them. With a weak declaration the test links everywhere and skips, loudly, when there is no separate generic to compare against. MSVC has no weak symbols, so there the test is compiled out. --- tests/test-dt3.cpp | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/tests/test-dt3.cpp b/tests/test-dt3.cpp index d116e3129..309876125 100644 --- a/tests/test-dt3.cpp +++ b/tests/test-dt3.cpp @@ -479,10 +479,15 @@ static int test_vec_dot(const ggml_type_traits_cpu * qfns_cpu) { return num_failed; } -// the scalar reference implementation, always compiled into ggml-cpu; on -// architectures without a native kernel the dispatched vec_dot IS this -// function and the parity test below passes trivially -extern "C" void ggml_vec_dot_dt3_q8_0_generic(int n, float * s, size_t bs, const void * vx, size_t bx, const void * vy, size_t by, int nrc); +// the scalar reference implementation. The symbol only exists on builds with +// a native DT3 kernel: without one, arch-fallback.h renames the generic to +// ggml_vec_dot_dt3_q8_0 and there is nothing to compare against, so the +// reference is declared weak and the parity test skips when it is absent. +#if defined(_MSC_VER) +#define DT3_NO_WEAK_SYMBOLS +#else +extern "C" void ggml_vec_dot_dt3_q8_0_generic(int n, float * s, size_t bs, const void * vx, size_t bx, const void * vy, size_t by, int nrc) __attribute__((weak)); +#endif // the dispatched (possibly vectorized) vec_dot must match the generic scalar // implementation exactly — the actual function is called, not a re-derivation @@ -492,6 +497,16 @@ extern "C" void ggml_vec_dot_dt3_q8_0_generic(int n, float * s, size_t bs, const static int test_vec_dot_arch_parity(const ggml_type_traits_cpu * qfns_cpu) { int num_failed = 0; +#if defined(DT3_NO_WEAK_SYMBOLS) + (void) qfns_cpu; + printf("(skipping vec_dot arch parity: no weak symbol support)\n"); + return num_failed; +#else + if (ggml_vec_dot_dt3_q8_0_generic == nullptr) { + printf("(skipping vec_dot arch parity: this build has no separate generic vec_dot)\n"); + return num_failed; + } + const auto * vdot_traits = ggml_get_type_traits_cpu(qfns_cpu->vec_dot_type); const int nblocks = 3; @@ -560,6 +575,7 @@ static int test_vec_dot_arch_parity(const ggml_type_traits_cpu * qfns_cpu) { } return num_failed; +#endif } // --dequant IN.bin OUT.f32 : dequantize raw DT3 blocks, for parity checks