Skip to content

Commit

Permalink
add cpuid check for avx-vnni
Browse files Browse the repository at this point in the history
  • Loading branch information
slaren committed Dec 1, 2024
1 parent b14b9bf commit 6d78e0f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 0 additions & 1 deletion ggml/src/ggml-backend-reg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,6 @@ static ggml_backend_reg_t ggml_backend_load_best(const char * name, bool silent)
}

void ggml_backend_load_all() {
ggml_backend_load_best("amx", true);
ggml_backend_load_best("blas", true);
ggml_backend_load_best("cann", true);
ggml_backend_load_best("cuda", true);
Expand Down
4 changes: 3 additions & 1 deletion ggml/src/ggml-cpu/cpu-feats-x86.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ struct cpuid_x86 {
bool AVX512_VNNI(void) { return f_7_ecx[11]; }
bool AVX512_FP16(void) { return f_7_edx[23]; }
bool AVX512_BF16(void) { return f_7_1_eax[5]; }
bool AVX_VNNI(void) { return f_7_1_eax[4]; }

bool AMX_TILE(void) { return f_7_edx[24]; }
bool AMX_INT8(void) { return f_7_edx[25]; }
Expand Down Expand Up @@ -265,6 +266,7 @@ static int ggml_backend_cpu_x86_score() {
if (ggml_cpu_has_ssse3() && !is.SSSE3()) { return 0; }
if (ggml_cpu_has_sse3() && !is.SSE3()) { return 0; }
if (ggml_cpu_has_avx() && !is.AVX()) { return 0; }
if (ggml_cpu_has_avx_vnni() && !is.AVX_VNNI()) { return 0; }
if (ggml_cpu_has_avx2() && !is.AVX2()) { return 0; }
if (ggml_cpu_has_avx512() && !is.AVX512F()) { return 0; }
if (ggml_cpu_has_avx512_vbmi() && !is.AVX512_VBMI()) { return 0; }
Expand All @@ -279,8 +281,8 @@ static int ggml_backend_cpu_x86_score() {
score += ggml_cpu_has_f16c () * 1<<1;
score += ggml_cpu_has_ssse3 () * 1<<2;
score += ggml_cpu_has_sse3 () * 1<<3;
// score += ggml_cpu_has_avx_vnni () * 1<<4; // not used
score += ggml_cpu_has_avx () * 1<<5;
score += ggml_cpu_has_avx_vnni () * 1<<4;
score += ggml_cpu_has_avx2 () * 1<<6;
score += ggml_cpu_has_avx512 () * 1<<7;
// score += ggml_cpu_has_avx512_vbmi() * 1<<8; // not used
Expand Down

0 comments on commit 6d78e0f

Please sign in to comment.