Spaces:
Running
Running
ggml : add system info functions
Browse files- examples/bench/bench.cpp +15 -0
- ggml.c +50 -0
- ggml.h +11 -0
- whisper.cpp +14 -0
- whisper.h +3 -0
examples/bench/bench.cpp
CHANGED
|
@@ -74,5 +74,20 @@ int main(int argc, char ** argv) {
|
|
| 74 |
whisper_print_timings(ctx);
|
| 75 |
whisper_free(ctx);
|
| 76 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
return 0;
|
| 78 |
}
|
|
|
|
| 74 |
whisper_print_timings(ctx);
|
| 75 |
whisper_free(ctx);
|
| 76 |
|
| 77 |
+
fprintf(stderr, "\n");
|
| 78 |
+
fprintf(stderr, "system_info: n_threads = %d | %s\n", params.n_threads, whisper_print_system_info());
|
| 79 |
+
|
| 80 |
+
fprintf(stderr, "\n");
|
| 81 |
+
fprintf(stderr, "If you wish, you can submit these results here:\n");
|
| 82 |
+
fprintf(stderr, "\n");
|
| 83 |
+
fprintf(stderr, " https://github.com/ggerganov/whisper.cpp/issues/89\n");
|
| 84 |
+
fprintf(stderr, "\n");
|
| 85 |
+
fprintf(stderr, "Please include the following information:\n");
|
| 86 |
+
fprintf(stderr, "\n");
|
| 87 |
+
fprintf(stderr, " - CPU model\n");
|
| 88 |
+
fprintf(stderr, " - Operating system\n");
|
| 89 |
+
fprintf(stderr, " - Compiler\n");
|
| 90 |
+
fprintf(stderr, "\n");
|
| 91 |
+
|
| 92 |
return 0;
|
| 93 |
}
|
ggml.c
CHANGED
|
@@ -8032,3 +8032,53 @@ enum ggml_opt_result ggml_opt(
|
|
| 8032 |
}
|
| 8033 |
|
| 8034 |
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8032 |
}
|
| 8033 |
|
| 8034 |
////////////////////////////////////////////////////////////////////////////////
|
| 8035 |
+
|
| 8036 |
+
int ggml_cpu_has_avx2(void) {
|
| 8037 |
+
#if defined(__AVX2__)
|
| 8038 |
+
return 1;
|
| 8039 |
+
#else
|
| 8040 |
+
return 0;
|
| 8041 |
+
#endif
|
| 8042 |
+
}
|
| 8043 |
+
|
| 8044 |
+
int ggml_cpu_has_avx512(void) {
|
| 8045 |
+
#if defined(__AVX512F__)
|
| 8046 |
+
return 1;
|
| 8047 |
+
#else
|
| 8048 |
+
return 0;
|
| 8049 |
+
#endif
|
| 8050 |
+
}
|
| 8051 |
+
|
| 8052 |
+
int ggml_cpu_has_neon(void) {
|
| 8053 |
+
#if defined(__ARM_NEON__)
|
| 8054 |
+
return 1;
|
| 8055 |
+
#else
|
| 8056 |
+
return 0;
|
| 8057 |
+
#endif
|
| 8058 |
+
}
|
| 8059 |
+
|
| 8060 |
+
int ggml_cpu_has_fp16_va(void) {
|
| 8061 |
+
#if defined(__ARM_FEATURE_FP16_VECTOR_ARITHMETIC)
|
| 8062 |
+
return 1;
|
| 8063 |
+
#else
|
| 8064 |
+
return 0;
|
| 8065 |
+
#endif
|
| 8066 |
+
}
|
| 8067 |
+
|
| 8068 |
+
int ggml_cpu_has_wasm_simd(void) {
|
| 8069 |
+
#if defined(__wasm_simd128__)
|
| 8070 |
+
return 1;
|
| 8071 |
+
#else
|
| 8072 |
+
return 0;
|
| 8073 |
+
#endif
|
| 8074 |
+
}
|
| 8075 |
+
|
| 8076 |
+
int ggml_cpu_has_blas(void) {
|
| 8077 |
+
#if defined(GGML_USE_BLAS) || defined(GGML_USE_ACCELERATE)
|
| 8078 |
+
return 1;
|
| 8079 |
+
#else
|
| 8080 |
+
return 0;
|
| 8081 |
+
#endif
|
| 8082 |
+
}
|
| 8083 |
+
|
| 8084 |
+
////////////////////////////////////////////////////////////////////////////////
|
ggml.h
CHANGED
|
@@ -548,6 +548,17 @@ enum ggml_opt_result ggml_opt(
|
|
| 548 |
struct ggml_opt_params params,
|
| 549 |
struct ggml_tensor * f);
|
| 550 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 551 |
#ifdef __cplusplus
|
| 552 |
}
|
| 553 |
#endif
|
|
|
|
| 548 |
struct ggml_opt_params params,
|
| 549 |
struct ggml_tensor * f);
|
| 550 |
|
| 551 |
+
//
|
| 552 |
+
// system info
|
| 553 |
+
//
|
| 554 |
+
|
| 555 |
+
int ggml_cpu_has_avx2(void);
|
| 556 |
+
int ggml_cpu_has_avx512(void);
|
| 557 |
+
int ggml_cpu_has_neon(void);
|
| 558 |
+
int ggml_cpu_has_fp16_va(void);
|
| 559 |
+
int ggml_cpu_has_wasm_simd(void);
|
| 560 |
+
int ggml_cpu_has_blas(void);
|
| 561 |
+
|
| 562 |
#ifdef __cplusplus
|
| 563 |
}
|
| 564 |
#endif
|
whisper.cpp
CHANGED
|
@@ -2628,3 +2628,17 @@ whisper_token whisper_full_get_token_id(struct whisper_context * ctx, int i_segm
|
|
| 2628 |
float whisper_full_get_token_p(struct whisper_context * ctx, int i_segment, int i_token) {
|
| 2629 |
return ctx->result_all[i_segment].tokens[i_token].p;
|
| 2630 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2628 |
float whisper_full_get_token_p(struct whisper_context * ctx, int i_segment, int i_token) {
|
| 2629 |
return ctx->result_all[i_segment].tokens[i_token].p;
|
| 2630 |
}
|
| 2631 |
+
|
| 2632 |
+
const char * whisper_print_system_info() {
|
| 2633 |
+
static std::string s;
|
| 2634 |
+
|
| 2635 |
+
s = "";
|
| 2636 |
+
s += "AVX2 = " + std::to_string(ggml_cpu_has_avx2()) + " | ";
|
| 2637 |
+
s += "AVX512 = " + std::to_string(ggml_cpu_has_avx512()) + " | ";
|
| 2638 |
+
s += "NEON = " + std::to_string(ggml_cpu_has_neon()) + " | ";
|
| 2639 |
+
s += "FP16_VA = " + std::to_string(ggml_cpu_has_fp16_va()) + " | ";
|
| 2640 |
+
s += "WASM_SIMD = " + std::to_string(ggml_cpu_has_wasm_simd()) + " | ";
|
| 2641 |
+
s += "BLAS = " + std::to_string(ggml_cpu_has_blas()) + " | ";
|
| 2642 |
+
|
| 2643 |
+
return s.c_str();
|
| 2644 |
+
}
|
whisper.h
CHANGED
|
@@ -225,6 +225,9 @@ extern "C" {
|
|
| 225 |
// Get the probability of the specified token in the specified segment.
|
| 226 |
WHISPER_API float whisper_full_get_token_p(struct whisper_context * ctx, int i_segment, int i_token);
|
| 227 |
|
|
|
|
|
|
|
|
|
|
| 228 |
#ifdef __cplusplus
|
| 229 |
}
|
| 230 |
#endif
|
|
|
|
| 225 |
// Get the probability of the specified token in the specified segment.
|
| 226 |
WHISPER_API float whisper_full_get_token_p(struct whisper_context * ctx, int i_segment, int i_token);
|
| 227 |
|
| 228 |
+
// Print system information
|
| 229 |
+
WHISPER_API const char * whisper_print_system_info();
|
| 230 |
+
|
| 231 |
#ifdef __cplusplus
|
| 232 |
}
|
| 233 |
#endif
|