| 16256 | } |
| 16257 | |
| 16258 | static void ggml_build_forward_impl(struct ggml_cgraph * cgraph, struct ggml_tensor * tensor, bool expand) { |
| 16259 | if (!expand) { |
| 16260 | // TODO: this branch isn't accessible anymore, maybe move this to ggml_build_forward_expand |
| 16261 | ggml_graph_clear(cgraph); |
| 16262 | } |
| 16263 | |
| 16264 | const int n0 = cgraph->n_nodes; |
| 16265 | UNUSED(n0); |
| 16266 | |
| 16267 | ggml_visit_parents(cgraph, tensor); |
| 16268 | |
| 16269 | const int n_new = cgraph->n_nodes - n0; |
| 16270 | GGML_PRINT_DEBUG("%s: visited %d new nodes\n", __func__, n_new); |
| 16271 | |
| 16272 | if (n_new > 0) { |
| 16273 | // the last added node should always be starting point |
| 16274 | GGML_ASSERT(cgraph->nodes[cgraph->n_nodes - 1] == tensor); |
| 16275 | } |
| 16276 | } |
| 16277 | |
| 16278 | void ggml_build_forward_expand(struct ggml_cgraph * cgraph, struct ggml_tensor * tensor) { |
| 16279 | ggml_build_forward_impl(cgraph, tensor, true); |
no test coverage detected