|
8 | 8 |
|
9 | 9 | // a function that can be called for every computed node during graph evaluation |
10 | 10 | // the user can choose to whether to observe the data of the node depending on the tensor parameters |
11 | | -static bool observe_compute(int node_index, struct ggml_tensor * t, void * user_data) { |
| 11 | +static bool observe_compute(int node_index, struct ggml_tensor * t, bool ask, void * user_data) { |
12 | 12 | GGML_UNUSED(user_data); |
13 | 13 |
|
14 | | - // check if name contains soft_max |
15 | | - if (strstr(t->name, "soft_max") != 0) { |
16 | | - printf("%s: node_index = %5d, t->name = %32s, t->op = %12s, [%5d, %5d, %5d, %5d]\n", |
17 | | - __func__, node_index, t->name, ggml_op_name(t->op), (int) t->ne[0], (int) t->ne[1], (int) t->ne[2], (int) t->ne[3]); |
| 14 | + // the scheduler is asking us if we want to observe this node |
| 15 | + if (ask) { |
| 16 | + // check if name contains soft_max |
| 17 | + return strstr(t->name, "soft_max") != 0; |
| 18 | + } |
18 | 19 |
|
19 | | - std::vector<float> t_data(ggml_nelements(t)); |
20 | | - ggml_backend_tensor_get(t, t_data.data(), 0, ggml_nbytes(t)); |
| 20 | + // print the node data |
| 21 | + printf("%s: node_index = %5d, t->name = %32s, t->op = %12s, [%5d, %5d, %5d, %5d]\n", |
| 22 | + __func__, node_index, t->name, ggml_op_name(t->op), (int) t->ne[0], (int) t->ne[1], (int) t->ne[2], (int) t->ne[3]); |
21 | 23 |
|
22 | | - // print first row |
23 | | - for (int i = 0; i < t->ne[0]; i++) { |
24 | | - printf("%8.4f ", t_data[i]); |
25 | | - } |
26 | | - printf("\n"); |
| 24 | + std::vector<float> t_data(ggml_nelements(t)); |
| 25 | + ggml_backend_tensor_get(t, t_data.data(), 0, ggml_nbytes(t)); |
| 26 | + |
| 27 | + // print first row |
| 28 | + for (int i = 0; i < t->ne[0]; i++) { |
| 29 | + printf("%8.4f ", t_data[i]); |
27 | 30 | } |
| 31 | + printf("\n"); |
28 | 32 |
|
29 | 33 | return true; |
30 | 34 | } |
|
0 commit comments