| 6795 | } |
| 6796 | |
| 6797 | static void ggml_build_forward_impl(struct ggml_cgraph * cgraph, struct ggml_tensor * tensor, bool expand, bool compute) { |
| 6798 | if (!expand) { |
| 6799 | // TODO: this branch isn't accessible anymore, maybe move this to ggml_build_forward_expand |
| 6800 | ggml_graph_clear(cgraph); |
| 6801 | } |
| 6802 | |
| 6803 | const int n_old = cgraph->n_nodes; |
| 6804 | |
| 6805 | ggml_visit_parents_graph(cgraph, tensor, compute); |
| 6806 | |
| 6807 | const int n_new = cgraph->n_nodes - n_old; |
| 6808 | GGML_PRINT_DEBUG("%s: visited %d new nodes\n", __func__, n_new); |
| 6809 | |
| 6810 | if (n_new > 0) { |
| 6811 | // the last added node should always be starting point |
| 6812 | GGML_ASSERT(cgraph->nodes[cgraph->n_nodes - 1] == tensor); |
| 6813 | } |
| 6814 | } |
| 6815 | |
| 6816 | struct ggml_tensor * ggml_build_forward_select( |
| 6817 | struct ggml_cgraph * cgraph, |
no test coverage detected