MCPcopy Create free account
hub / github.com/appdevforall/CodeOnTheGo / ggml_graph_nbytes

Function ggml_graph_nbytes

subprojects/llama.cpp/ggml/src/ggml.c:6940–6956  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6938}
6939
6940static size_t ggml_graph_nbytes(size_t size, bool grads) {
6941 size_t hash_size = ggml_hash_size(size * 2);
6942 void * p = 0;
6943 incr_ptr_aligned(&p, sizeof(struct ggml_cgraph), 1);
6944 incr_ptr_aligned(&p, size * sizeof(struct ggml_tensor *), sizeof(struct ggml_tensor *)); // nodes
6945 incr_ptr_aligned(&p, size * sizeof(struct ggml_tensor *), sizeof(struct ggml_tensor *)); // leafs
6946 incr_ptr_aligned(&p, hash_size * sizeof(int32_t), sizeof(int32_t)); // use_counts
6947 incr_ptr_aligned(&p, hash_size * sizeof(struct ggml_tensor *), sizeof(struct ggml_tensor *)); // hash keys
6948 if (grads) {
6949 incr_ptr_aligned(&p, hash_size * sizeof(struct ggml_tensor *), sizeof(struct ggml_tensor *)); // grads
6950 incr_ptr_aligned(&p, hash_size * sizeof(struct ggml_tensor *), sizeof(struct ggml_tensor *)); // grad_accs
6951 }
6952 incr_ptr_aligned(&p, ggml_bitset_size(hash_size) * sizeof(ggml_bitset_t), sizeof(ggml_bitset_t));
6953
6954 size_t nbytes = (size_t) p;
6955 return nbytes;
6956}
6957
6958size_t ggml_graph_overhead_custom(size_t size, bool grads) {
6959 return GGML_OBJECT_SIZE + GGML_PAD(ggml_graph_nbytes(size, grads), GGML_MEM_ALIGN);

Callers 2

ggml_new_graph_customFunction · 0.85

Calls 3

ggml_hash_sizeFunction · 0.85
ggml_bitset_sizeFunction · 0.85
incr_ptr_alignedFunction · 0.70

Tested by

no test coverage detected