| 1274 | } |
| 1275 | |
| 1276 | test_status_t eval(ggml_backend_t backend1, |
| 1277 | ggml_backend_t backend2, |
| 1278 | const char * op_names_filter, |
| 1279 | printer * output_printer) { |
| 1280 | mode = MODE_TEST; |
| 1281 | |
| 1282 | ggml_init_params params = { |
| 1283 | /* .mem_size = */ ggml_tensor_overhead()*128 + ggml_graph_overhead(), |
| 1284 | /* .mem_base = */ NULL, |
| 1285 | /* .no_alloc = */ true, |
| 1286 | }; |
| 1287 | ggml_context * ctx = ggml_init(params); |
| 1288 | GGML_ASSERT(ctx); |
| 1289 | |
| 1290 | gf = ggml_new_graph(ctx); |
| 1291 | |
| 1292 | // pre-graph sentinel |
| 1293 | add_sentinel(ctx); |
| 1294 | |
| 1295 | ggml_tensor * out = build_graph(ctx); |
| 1296 | current_op_name = op_desc(out); |
| 1297 | |
| 1298 | if (!matches_filter(out, op_names_filter)) { |
| 1299 | //printf(" %s: skipping\n", op_desc(out).c_str()); |
| 1300 | ggml_free(ctx); |
| 1301 | return test_status_t::SKIPPED; |
| 1302 | } |
| 1303 | |
| 1304 | // check if the backends support the ops |
| 1305 | bool supported = true; |
| 1306 | for (ggml_backend_t backend : {backend1, backend2}) { |
| 1307 | for (ggml_tensor * t = ggml_get_first_tensor(ctx); t != NULL; t = ggml_get_next_tensor(ctx, t)) { |
| 1308 | if (!ggml_backend_supports_op(backend, t)) { |
| 1309 | supported = false; |
| 1310 | break; |
| 1311 | } |
| 1312 | } |
| 1313 | } |
| 1314 | |
| 1315 | if (!supported) { |
| 1316 | // Create test result for unsupported operation |
| 1317 | test_result result(ggml_backend_name(backend1), current_op_name, vars(), "test", |
| 1318 | false, false, "not supported"); |
| 1319 | |
| 1320 | if (output_printer) { |
| 1321 | output_printer->print_test_result(result); |
| 1322 | } |
| 1323 | |
| 1324 | ggml_free(ctx); |
| 1325 | return test_status_t::NOT_SUPPORTED; |
| 1326 | } |
| 1327 | |
| 1328 | // post-graph sentinel |
| 1329 | add_sentinel(ctx); |
| 1330 | |
| 1331 | // allocate |
| 1332 | ggml_backend_buffer_t buf = ggml_backend_alloc_ctx_tensors(ctx, backend1); |
| 1333 |
no test coverage detected