Skip to content

Commit 7f5ee54

Browse files
ggml: fix ggml_is_contiguous_n for ne == 1 (#20092)
1 parent 66199c9 commit 7f5ee54

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

ggml/src/ggml.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1410,16 +1410,14 @@ static bool ggml_is_contiguous_n(const struct ggml_tensor * tensor, int n) {
14101410
}
14111411
next_nb *= tensor->ne[0]/ggml_blck_size(tensor->type);
14121412
for (int i = 1; i < GGML_MAX_DIMS; i++) {
1413-
if (tensor->ne[i] != 1) {
1414-
if (i > n) {
1415-
if (tensor->nb[i] != next_nb) {
1416-
return false;
1417-
}
1418-
next_nb *= tensor->ne[i];
1419-
} else {
1420-
// this dimension does not need to be contiguous
1421-
next_nb = tensor->ne[i]*tensor->nb[i];
1413+
if (i > n) {
1414+
if (tensor->ne[i] != 1 && tensor->nb[i] != next_nb) {
1415+
return false;
14221416
}
1417+
next_nb *= tensor->ne[i];
1418+
} else {
1419+
// this dimension does not need to be contiguous
1420+
next_nb = tensor->ne[i]*tensor->nb[i];
14231421
}
14241422
}
14251423
return true;

0 commit comments

Comments
 (0)