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

Function ggml_nbytes

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

Source from the content-addressed store, hash-verified

1236}
1237
1238size_t ggml_nbytes(const struct ggml_tensor * tensor) {
1239 for (int i = 0; i < GGML_MAX_DIMS; ++i) {
1240 if (tensor->ne[i] <= 0) {
1241 return 0;
1242 }
1243 }
1244
1245 size_t nbytes;
1246 const size_t blck_size = ggml_blck_size(tensor->type);
1247 if (blck_size == 1) {
1248 nbytes = ggml_type_size(tensor->type);
1249 for (int i = 0; i < GGML_MAX_DIMS; ++i) {
1250 nbytes += (tensor->ne[i] - 1)*tensor->nb[i];
1251 }
1252 }
1253 else {
1254 nbytes = tensor->ne[0]*tensor->nb[0]/blck_size;
1255 for (int i = 1; i < GGML_MAX_DIMS; ++i) {
1256 nbytes += (tensor->ne[i] - 1)*tensor->nb[i];
1257 }
1258 }
1259
1260 return nbytes;
1261}
1262
1263size_t ggml_nbytes_pad(const struct ggml_tensor * tensor) {
1264 return GGML_PAD(ggml_nbytes(tensor), GGML_MEM_ALIGN);

Callers 15

save_tensor_for_layerMethod · 0.85
filter_nonzero_rowsMethod · 0.85
train_contextMethod · 0.85
concat_diff_tmpMethod · 0.85
build_v_diffMethod · 0.85
pca_modelMethod · 0.85
power_iterationFunction · 0.85
read_tensor_dataMethod · 0.85
copy_tensorMethod · 0.85
merge_tensorMethod · 0.85
clip_model_loaderMethod · 0.85
load_tensorsMethod · 0.85

Calls 2

ggml_blck_sizeFunction · 0.85
ggml_type_sizeFunction · 0.85

Tested by 15

test_datasetFunction · 0.68
test_gradFunction · 0.68
test_forward_backwardFunction · 0.68
test_epoch_vs_fitFunction · 0.68
test_idata_splitFunction · 0.68
check_max_sizeFunction · 0.68
memory_overlapFunction · 0.68
init_tensor_uniformFunction · 0.68
init_tensor_trilFunction · 0.68
tensor_to_floatFunction · 0.68
op_sizeMethod · 0.68
evalMethod · 0.68