MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / ggml_gallocr_needs_realloc

Function ggml_gallocr_needs_realloc

external/ggml/src/ggml-alloc.c:1008–1049  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1006}
1007
1008static bool ggml_gallocr_needs_realloc(ggml_gallocr_t galloc, struct ggml_cgraph * graph) {
1009 if (galloc->n_nodes != graph->n_nodes) {
1010#ifndef NDEBUG
1011 GGML_LOG_DEBUG("%s: graph has different number of nodes\n", __func__);
1012#endif
1013 return true;
1014 }
1015
1016 if (galloc->n_leafs != graph->n_leafs) {
1017#ifndef NDEBUG
1018 GGML_LOG_DEBUG("%s: graph has different number of leafs\n", __func__);
1019#endif
1020 return true;
1021 }
1022
1023 for (int i = 0; i < graph->n_nodes; i++) {
1024 struct ggml_tensor * node = graph->nodes[i];
1025 struct node_alloc * node_alloc = &galloc->node_allocs[i];
1026
1027 if (!ggml_gallocr_node_needs_realloc(galloc, node, &node_alloc->dst)) {
1028#ifndef NDEBUG
1029 GGML_LOG_DEBUG("%s: node %s is not valid\n", __func__, node->name);
1030#endif
1031 return true;
1032 }
1033
1034 for (int j = 0; j < GGML_MAX_SRC; j++) {
1035 struct ggml_tensor * src = node->src[j];
1036 if (src == NULL) {
1037 continue;
1038 }
1039 if (!ggml_gallocr_node_needs_realloc(galloc, src, &node_alloc->src[j])) {
1040#ifndef NDEBUG
1041 GGML_LOG_DEBUG("%s: src %d (%s) of node %s is not valid\n", __func__, j, src->name, node->name);
1042#endif
1043 return true;
1044 }
1045 }
1046 }
1047
1048 return false;
1049}
1050
1051bool ggml_gallocr_alloc_graph(ggml_gallocr_t galloc, struct ggml_cgraph * graph) {
1052 if (ggml_gallocr_needs_realloc(galloc, graph)) {

Callers 1

ggml_gallocr_alloc_graphFunction · 0.85

Calls 1

Tested by

no test coverage detected