| 1294 | } |
| 1295 | |
| 1296 | test_status_t eval(ggml_backend_t backend1, |
| 1297 | ggml_backend_t backend2, |
| 1298 | const char * op_names_filter, |
| 1299 | printer * output_printer) { |
| 1300 | mode = MODE_TEST; |
| 1301 | |
| 1302 | ggml_init_params params = { |
| 1303 | /* .mem_size = */ ggml_tensor_overhead()*128 + ggml_graph_overhead(), |
| 1304 | /* .mem_base = */ NULL, |
| 1305 | /* .no_alloc = */ true, |
| 1306 | }; |
| 1307 | ggml_context * ctx = ggml_init(params); |
| 1308 | GGML_ASSERT(ctx); |
| 1309 | |
| 1310 | gf = ggml_new_graph(ctx); |
| 1311 | |
| 1312 | // pre-graph sentinel |
| 1313 | add_sentinel(ctx); |
| 1314 | |
| 1315 | ggml_tensor * out = build_graph(ctx); |
| 1316 | current_op_name = op_desc(out); |
| 1317 | check_for_f16_tensor(ctx); |
| 1318 | |
| 1319 | if (!matches_filter(out, op_names_filter)) { |
| 1320 | //printf(" %s: skipping\n", op_desc(out).c_str()); |
| 1321 | ggml_free(ctx); |
| 1322 | return test_status_t::SKIPPED; |
| 1323 | } |
| 1324 | |
| 1325 | // check if the backends support the ops |
| 1326 | bool supported = true; |
| 1327 | for (ggml_backend_t backend : {backend1, backend2}) { |
| 1328 | for (ggml_tensor * t = ggml_get_first_tensor(ctx); t != NULL; t = ggml_get_next_tensor(ctx, t)) { |
| 1329 | if (!ggml_backend_supports_op(backend, t)) { |
| 1330 | supported = false; |
| 1331 | break; |
| 1332 | } |
| 1333 | } |
| 1334 | } |
| 1335 | |
| 1336 | if (!supported) { |
| 1337 | // Create test result for unsupported operation |
| 1338 | test_result result(ggml_backend_name(backend1), current_op_name, vars(), "test", |
| 1339 | false, false, "not supported"); |
| 1340 | |
| 1341 | if (output_printer) { |
| 1342 | output_printer->print_test_result(result); |
| 1343 | } |
| 1344 | |
| 1345 | ggml_free(ctx); |
| 1346 | return test_status_t::NOT_SUPPORTED; |
| 1347 | } |
| 1348 | |
| 1349 | // post-graph sentinel |
| 1350 | add_sentinel(ctx); |
| 1351 | |
| 1352 | // allocate |
| 1353 | ggml_backend_buffer_t buf = ggml_backend_alloc_ctx_tensors(ctx, backend1); |
no test coverage detected