Skip to content

Commit 0f82d8c

Browse files
committed
ggml : fix unaligned access in AMX code
1 parent d9e0e7c commit 0f82d8c

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

ggml/src/ggml-cpu/amx/mmq.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1432,7 +1432,10 @@ struct tinygemm_kernel_vnni<block_q8_0, block_q4_0, float, BLOCK_M, BLOCK_N, BLO
14321432
auto compute = [&](auto col, auto i) {
14331433
// load a and compute compensation
14341434
if constexpr (col == 0) {
1435-
const int32_t * a_ptr = reinterpret_cast<const int32_t *>(A[0 * KB + i].qs);
1435+
//const int32_t * a_ptr = reinterpret_cast<const int32_t *>(A[0 * KB + i].qs);
1436+
int32_t a_ptr[8];
1437+
memcpy((char *)a_ptr, (const char *)A[0 * KB + i].qs, 32);
1438+
14361439
vcomp = _mm512_setzero_si512();
14371440
for (int k = 0; k < 8; ++k) {
14381441
va[k] = _mm512_set1_epi32(a_ptr[k]);
@@ -1495,7 +1498,10 @@ struct tinygemm_kernel_vnni<block_q8_1, block_q4_1, float, 1, BLOCK_N, BLOCK_K>
14951498
auto compute = [&](auto col, auto i) {
14961499
// load a
14971500
if constexpr (col == 0) {
1498-
const int32_t * a_ptr = reinterpret_cast<const int32_t *>(A[0 * KB + i].qs);
1501+
//const int32_t * a_ptr = reinterpret_cast<const int32_t *>(A[0 * KB + i].qs);
1502+
int32_t a_ptr[8];
1503+
memcpy((char *)a_ptr, (const char *)A[0 * KB + i].qs, 32);
1504+
14991505
for (int k = 0; k < 8; ++k) {
15001506
va[k] = _mm512_set1_epi32(a_ptr[k]);
15011507
}

0 commit comments

Comments
 (0)