compute with backend
| 97 | |
| 98 | // compute with backend |
| 99 | struct ggml_tensor * compute(simple_model & model, struct ggml_cgraph * gf) { |
| 100 | ggml_backend_sched_reset(model.sched); |
| 101 | ggml_backend_sched_alloc_graph(model.sched, gf); |
| 102 | |
| 103 | // load data from cpu memory to backend buffer |
| 104 | ggml_backend_tensor_set(model.a, matrix_A, 0, ggml_nbytes(model.a)); |
| 105 | ggml_backend_tensor_set(model.b, matrix_B, 0, ggml_nbytes(model.b)); |
| 106 | |
| 107 | // compute the graph |
| 108 | ggml_backend_sched_graph_compute(model.sched, gf); |
| 109 | |
| 110 | // in this case, the output tensor is the last one in the graph |
| 111 | return ggml_graph_node(gf, -1); |
| 112 | } |
| 113 | |
| 114 | int main(void) { |
| 115 | ggml_time_init(); |
no test coverage detected