From 2f8be164ad761207c7c9d1e83195d79db85f38c0 Mon Sep 17 00:00:00 2001 From: Georgi Gerganov Date: Fri, 22 Mar 2024 09:47:56 +0200 Subject: [PATCH] metal : proper assert for mat-mat memory alignment ggml-ci --- ggml-metal.m | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ggml-metal.m b/ggml-metal.m index 54d1f1d5a..a6f03906c 100644 --- a/ggml-metal.m +++ b/ggml-metal.m @@ -1392,6 +1392,10 @@ static enum ggml_status ggml_metal_graph_compute( (ne11 > ne11_mm_min || (ggml_is_quantized(src0t) && ne12 > 1))) { //printf("matrix: ne00 = %6d, ne01 = %6d, ne02 = %6d, ne11 = %6d, ne12 = %6d\n", ne00, ne01, ne02, ne11, ne12); + // some Metal matrix data types require alignment to 16 bytes + // ref: https://developer.apple.com/metal/Metal-Shading-Language-Specification.pdf (Table 2.5) + GGML_ASSERT(nb01 % 16 == 0); + id pipeline = nil; switch (src0->type) { @@ -1706,6 +1710,10 @@ static enum ggml_status ggml_metal_graph_compute( ne20 % 32 == 0 && ne20 >= 64 && ne11 > ne11_mm_min) { + // some Metal matrix data types require alignment to 16 bytes + // ref: https://developer.apple.com/metal/Metal-Shading-Language-Specification.pdf (Table 2.5) + GGML_ASSERT(nb01 % 16 == 0); + id pipeline = nil; switch (src2->type) {