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

Function ggml_gallocr_init_tensor

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

Source from the content-addressed store, hash-verified

967}
968
969static void ggml_gallocr_init_tensor(ggml_gallocr_t galloc, struct ggml_tensor * tensor, struct tensor_alloc * tensor_alloc) {
970 int buffer_id = tensor_alloc->buffer_id;
971 assert(tensor->data || tensor->view_src || ggml_backend_buft_get_alloc_size(galloc->bufts[buffer_id], tensor) <= tensor_alloc->size_max);
972
973 if (tensor->view_src != NULL) {
974 if (tensor->buffer == NULL) {
975 assert(tensor_alloc->addr.offset == SIZE_MAX);
976 if (tensor->view_src->buffer == NULL) {
977 // this tensor was allocated without ggml-backend
978 return;
979 }
980 ggml_backend_view_init(tensor);
981 }
982 } else {
983 if (tensor->data == NULL) {
984 assert(tensor_alloc->addr.offset != SIZE_MAX);
985 assert(ggml_backend_buft_get_alloc_size(galloc->bufts[buffer_id], tensor) <= tensor_alloc->size_max);
986 ggml_vbuffer_tensor_alloc(galloc->buffers[buffer_id], tensor, tensor_alloc->addr);
987 } else {
988 if (tensor->buffer == NULL) {
989 // this tensor was allocated without ggml-backend
990 return;
991 }
992 }
993 }
994}
995
996static bool ggml_gallocr_node_needs_realloc(ggml_gallocr_t galloc, struct ggml_tensor * node, struct tensor_alloc * talloc) {
997 size_t node_size = 0;

Callers 1

ggml_gallocr_alloc_graphFunction · 0.85

Calls 3

ggml_backend_view_initFunction · 0.85

Tested by

no test coverage detected