diff options
Diffstat (limited to 'tools/test_api.c')
| -rw-r--r-- | tools/test_api.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tools/test_api.c b/tools/test_api.c index 6923102..18f68b6 100644 --- a/tools/test_api.c +++ b/tools/test_api.c @@ -5,6 +5,10 @@ #include <stdlib.h> #include <string.h> +#ifdef USE_OPENBLAS +#include <cblas.h> +#endif + #define CHECK(condition) do { \ if (!(condition)) { \ fprintf(stderr, "%s:%d: %s\n", __FILE__, __LINE__, #condition); \ @@ -40,6 +44,9 @@ int main(int argc, char **argv) { langdet_t *first = langdet_open(model_dir, 1, error, sizeof(error)); CHECK(first && !error[0]); +#ifdef USE_OPENBLAS + CHECK(openblas_get_num_threads() == 1); +#endif langdet_result_t result; const char *english = "This is an English sentence."; CHECK(langdet_predict(first, english, &result, error, sizeof(error)) == 0); @@ -80,10 +87,19 @@ int main(int argc, char **argv) { langdet_t *second = langdet_open(model_dir, 4, error, sizeof(error)); CHECK(second && !error[0]); +#ifdef USE_OPENBLAS + CHECK(openblas_get_num_threads() == 4); +#endif CHECK(langdet_predict(first, english, &result, error, sizeof(error)) == 0); +#ifdef USE_OPENBLAS + CHECK(openblas_get_num_threads() == 1); +#endif CHECK(result.score == saved.score); langdet_free(first); CHECK(langdet_predict(second, english, &result, error, sizeof(error)) == 0); +#ifdef USE_OPENBLAS + CHECK(openblas_get_num_threads() == 4); +#endif CHECK(result.score == saved.score); langdet_free(second); puts("PASS: public API, repeated predictions, result ownership, truncation, errors, and lifecycle."); |
