| 545 | |
| 546 | const __m256i y0 = _mm256_loadu_si256((const __m256i *)(py + 0)); |
| 547 | const __m256i y1 = _mm256_loadu_si256((const __m256i *)(py + 32)); |
| 548 | const __m256i y2 = _mm256_loadu_si256((const __m256i *)(py + 64)); |
| 549 | const __m256i y3 = _mm256_loadu_si256((const __m256i *)(py + 96)); |
| 550 | |
| 551 | acc16 = _mm256_add_epi16(acc16, _mm256_add_epi16(_mm256_maddubs_epi16(c0, y0), |
| 552 | _mm256_maddubs_epi16(c1, y1))); |
| 553 | acc16 = _mm256_add_epi16(acc16, _mm256_add_epi16(_mm256_maddubs_epi16(c2, y2), |
| 554 | _mm256_maddubs_epi16(c3, y3))); |
| 555 | } |
| 556 | |
| 557 | acc = _mm256_add_epi32(acc, _mm256_madd_epi16(acc16, one16)); |
| 558 | } |
| 559 | |
| 560 | sumi = ggml_i8_hsum_i32_4(_mm_add_epi32(_mm256_castsi256_si128(acc), |
| 561 | _mm256_extracti128_si256(acc, 1))); |
| 562 | #elif defined(__ARM_NEON) && defined(__aarch64__) |
| 563 | // Half a group per iteration, since a NEON register holds 16 of the 32 |
| 564 | // bytes. The four code lanes still map to the four 32-value slices of y, |
| 565 | // offset by which half of the group is loaded. |
| 566 | const uint8x16_t mask = vdupq_n_u8(3); |
| 567 | |
| 568 | int32x4_t acc = vdupq_n_s32(0); |
| 569 | |
| 570 | for (; b < nb; ++b) { |
| 571 | for (int h = 0; h < 2; ++h) { |
| 572 | const uint8x16_t xq = vld1q_u8(xr + (size_t)b*32 + h*16); |
| 573 | |
| 574 | const int8x16_t c0 = vreinterpretq_s8_u8(vandq_u8(vshrq_n_u8(xq, 6), mask)); |
| 575 | const int8x16_t c1 = vreinterpretq_s8_u8(vandq_u8(vshrq_n_u8(xq, 4), mask)); |
| 576 | const int8x16_t c2 = vreinterpretq_s8_u8(vandq_u8(vshrq_n_u8(xq, 2), mask)); |
| 577 | const int8x16_t c3 = vreinterpretq_s8_u8(vandq_u8(xq, mask)); |
| 578 | |
| 579 | const int8_t * py = y + (size_t)b*128 + h*16; |
| 580 | |
| 581 | const int8x16_t y0 = vld1q_s8(py + 0); |
| 582 | const int8x16_t y1 = vld1q_s8(py + 32); |
| 583 | const int8x16_t y2 = vld1q_s8(py + 64); |
| 584 | const int8x16_t y3 = vld1q_s8(py + 96); |
| 585 | |
| 586 | #if defined(__ARM_FEATURE_DOTPROD) |
| 587 | acc = vdotq_s32(acc, c0, y0); |
| 588 | acc = vdotq_s32(acc, c1, y1); |
| 589 | acc = vdotq_s32(acc, c2, y2); |
| 590 | acc = vdotq_s32(acc, c3, y3); |
| 591 | #else |
| 592 | // Products top out at 2*127 = 254, so the int16 halves are safe |
| 593 | // and vpadalq_s16 folds them pairwise straight into int32. |
| 594 | acc = vpadalq_s16(acc, vmull_s8(vget_low_s8 (c0), vget_low_s8 (y0))); |
| 595 | acc = vpadalq_s16(acc, vmull_s8(vget_high_s8(c0), vget_high_s8(y0))); |
| 596 | acc = vpadalq_s16(acc, vmull_s8(vget_low_s8 (c1), vget_low_s8 (y1))); |
| 597 | acc = vpadalq_s16(acc, vmull_s8(vget_high_s8(c1), vget_high_s8(y1))); |
| 598 | acc = vpadalq_s16(acc, vmull_s8(vget_low_s8 (c2), vget_low_s8 (y2))); |
| 599 | acc = vpadalq_s16(acc, vmull_s8(vget_high_s8(c2), vget_high_s8(y2))); |
| 600 | acc = vpadalq_s16(acc, vmull_s8(vget_low_s8 (c3), vget_low_s8 (y3))); |
| 601 | acc = vpadalq_s16(acc, vmull_s8(vget_high_s8(c3), vget_high_s8(y3))); |
| 602 | #endif |
| 603 | } |
| 604 | } |
no test coverage detected