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

Function ggml_is_contiguous_n

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

Source from the content-addressed store, hash-verified

1397}
1398
1399static bool ggml_is_contiguous_n(const struct ggml_tensor * tensor, int n) {
1400 size_t next_nb = ggml_type_size(tensor->type);
1401 if (tensor->ne[0] != ggml_blck_size(tensor->type) && tensor->nb[0] != next_nb) {
1402 return false;
1403 }
1404 next_nb *= tensor->ne[0]/ggml_blck_size(tensor->type);
1405 for (int i = 1; i < GGML_MAX_DIMS; i++) {
1406 if (tensor->ne[i] != 1) {
1407 if (i > n) {
1408 if (tensor->nb[i] != next_nb) {
1409 return false;
1410 }
1411 next_nb *= tensor->ne[i];
1412 } else {
1413 // this dimension does not need to be contiguous
1414 next_nb = tensor->ne[i]*tensor->nb[i];
1415 }
1416 }
1417 }
1418 return true;
1419}
1420
1421bool ggml_is_contiguous(const struct ggml_tensor * tensor) {
1422 return ggml_is_contiguous_0(tensor);

Callers 3

ggml_is_contiguous_0Function · 0.85
ggml_is_contiguous_1Function · 0.85
ggml_is_contiguous_2Function · 0.85

Calls 2

ggml_type_sizeFunction · 0.85
ggml_blck_sizeFunction · 0.85

Tested by

no test coverage detected