Skip to content

Commit 2b770f0

Browse files
committed
ggml : check src[1] does not have more than 2 dimensions
1 parent 8e293f2 commit 2b770f0

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

ggml/src/ggml-cpu/repack.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1872,7 +1872,8 @@ static const ggml::cpu::tensor_traits * ggml_repack_get_optimal_repack_type(cons
18721872
static bool supports_tensor(const struct ggml_tensor * op) {
18731873
if (op->op == GGML_OP_MUL_MAT &&
18741874
op->src[0]->buffer &&
1875-
(ggml_n_dims(op->src[0]) == 2) && ggml_repack_get_optimal_repack_type(op->src[0])) {
1875+
(ggml_n_dims(op->src[0]) == 2) && (ggml_n_dims(op->src[1]) == 2) &&
1876+
ggml_repack_get_optimal_repack_type(op->src[0])) {
18761877

18771878
if (op->src[1]->buffer && !ggml_backend_buft_is_host(op->src[1]->buffer->buft)) {
18781879
return false;
@@ -1883,7 +1884,8 @@ static bool supports_tensor(const struct ggml_tensor * op) {
18831884
}
18841885

18851886
} else if (op->op == GGML_OP_MUL_MAT_ID && op->src[0]->buffer &&
1886-
(ggml_n_dims(op->src[0]) == 3) && ggml_repack_get_optimal_repack_type(op->src[0])) {
1887+
(ggml_n_dims(op->src[0]) == 3) && (ggml_n_dims(op->src[1]) == 2) &&
1888+
ggml_repack_get_optimal_repack_type(op->src[0])) {
18871889

18881890
if (op->src[1]->buffer && !ggml_backend_buft_is_host(op->src[1]->buffer->buft)) {
18891891
return false;

0 commit comments

Comments
 (0)