Skip to content

Commit

Permalink
test-backend-ops : skip CPU backend by default (ggerganov#6028)
Browse files Browse the repository at this point in the history
  • Loading branch information
slaren authored and hodlen committed Apr 1, 2024
1 parent 0fb4225 commit bc3792f
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions tests/test-backend-ops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2222,8 +2222,8 @@ static void usage(char ** argv) {

int main(int argc, char ** argv) {
test_mode mode = MODE_TEST;
const char * op_name = NULL;
const char * backend = NULL;
const char * op_name_filter = NULL;
const char * backend_filter = NULL;

for (int i = 1; i < argc; i++) {
if (strcmp(argv[i], "test") == 0) {
Expand All @@ -2232,14 +2232,14 @@ int main(int argc, char ** argv) {
mode = MODE_PERF;
} else if (strcmp(argv[i], "-o") == 0) {
if (i + 1 < argc) {
op_name = argv[++i];
op_name_filter = argv[++i];
} else {
usage(argv);
return 1;
}
} else if (strcmp(argv[i], "-b") == 0) {
if (i + 1 < argc) {
backend = argv[++i];
backend_filter = argv[++i];
} else {
usage(argv);
return 1;
Expand All @@ -2258,17 +2258,25 @@ int main(int argc, char ** argv) {
for (size_t i = 0; i < ggml_backend_reg_get_count(); i++) {
printf("Backend %zu/%zu (%s)\n", i + 1, ggml_backend_reg_get_count(), ggml_backend_reg_get_name(i));

if (backend != NULL && strcmp(backend, ggml_backend_reg_get_name(i)) != 0) {
if (backend_filter != NULL && strcmp(backend_filter, ggml_backend_reg_get_name(i)) != 0) {
printf(" Skipping\n");
n_ok++;
continue;
}

ggml_backend_t backend = ggml_backend_reg_init_backend(i, NULL);
GGML_ASSERT(backend != NULL);

if (backend_filter == NULL && ggml_backend_is_cpu(backend)) {
printf(" Skipping CPU backend\n");
ggml_backend_free(backend);
n_ok++;
continue;
}

printf(" Backend name: %s\n", ggml_backend_name(backend));

bool ok = test_backend(backend, mode, op_name);
bool ok = test_backend(backend, mode, op_name_filter);

printf(" Backend %s: ", ggml_backend_name(backend));
if (ok) {
Expand Down

0 comments on commit bc3792f

Please sign in to comment.