From a51bc0c1c05ef4189b9424bdf29e73cf25b26724 Mon Sep 17 00:00:00 2001 From: Georgi Gerganov Date: Tue, 12 Dec 2023 15:55:42 +0200 Subject: [PATCH] metal : fix binary ops for ne10 % 4 != 0 --- ggml-metal.m | 2 +- tests/test-backend-ops.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ggml-metal.m b/ggml-metal.m index 8276d9fb6..090c84f59 100644 --- a/ggml-metal.m +++ b/ggml-metal.m @@ -1080,7 +1080,7 @@ void ggml_metal_graph_compute( int64_t nb = ne00; - if (ggml_nelements(src1) == ne10 && ggml_is_contiguous(src1) && ne00 % 4 == 0) { + if (ggml_nelements(src1) == ne10 && ggml_is_contiguous(src1) && ne00 % 4 == 0 && ne10 % 4 == 0) { GGML_ASSERT(ggml_is_contiguous(src0)); // src1 is a row diff --git a/tests/test-backend-ops.cpp b/tests/test-backend-ops.cpp index dcbc6d380..8f4b470bc 100644 --- a/tests/test-backend-ops.cpp +++ b/tests/test-backend-ops.cpp @@ -1272,6 +1272,7 @@ static bool test_backend(ggml_backend_t backend, test_mode mode, const char * op }; add_test_bin_bcast(GGML_TYPE_F32, {1, 1, 8, 1}, {1, 1, 1, 1}); + add_test_bin_bcast(GGML_TYPE_F32, {1, 1, 1, 1}, {32, 1, 1, 1}); add_test_bin_bcast(GGML_TYPE_F32, {1, 1, 320, 320}, {1, 1, 1, 1}); add_test_bin_bcast(GGML_TYPE_F32, {16, 10, 1, 1}, {1, 1, 1, 1}); add_test_bin_bcast(GGML_TYPE_F32, {16, 10, 10, 1}, {1, 1, 1, 1});