From fc94f4d23abd4bc427b701f54ad85282e9ec7872 Mon Sep 17 00:00:00 2001 From: Michael Tyler Date: Tue, 4 Jun 2024 15:47:37 +0100 Subject: Update CPU kernels and add mixed sign GEMM support - Add support for mixed sign quantized convolution. - Add support for mixed sign dequantized GEMM. - Add SME FP16 GEMV kernel. - Change SME vector length function to use RDSVL instead of static variable. - Add GEMM dilation support internally (not exposed yet). - Remove unused "get_default_activation_values" functions. - Add SVE fixed format interleaved BF16 DOT kernel. - Updates and optimizations to assembly kernels. Resolves COMPMID-6926 Change-Id: I227f502502611d4cc4111c89e30c53ce94079544 Signed-off-by: Michael Tyler Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/11570 Tested-by: Arm Jenkins Reviewed-by: Gunes Bayir Comments-Addressed: Arm Jenkins Benchmark: Arm Jenkins --- .../depthwise/interleaves/sve_s8q_3x3_dot.cpp | 118 ++++++++++----------- 1 file changed, 59 insertions(+), 59 deletions(-) (limited to 'src/core/NEON/kernels/arm_conv/depthwise/interleaves/sve_s8q_3x3_dot.cpp') diff --git a/src/core/NEON/kernels/arm_conv/depthwise/interleaves/sve_s8q_3x3_dot.cpp b/src/core/NEON/kernels/arm_conv/depthwise/interleaves/sve_s8q_3x3_dot.cpp index 5d7b54f235..7364963477 100644 --- a/src/core/NEON/kernels/arm_conv/depthwise/interleaves/sve_s8q_3x3_dot.cpp +++ b/src/core/NEON/kernels/arm_conv/depthwise/interleaves/sve_s8q_3x3_dot.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023 Arm Limited. + * Copyright (c) 2021, 2023-2024 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -52,80 +52,80 @@ void interleave_sve_s8q_3x3_dot::pack_parameters(unsigned int n_channels, void * { __asm__ __volatile__( "cmp %x[ld_weight_col], XZR\n" - "csel %x[ld_weight_col], %x[ld_weight_col], %x[n_channels], NE\n" - "mov z16.s, #0x9\n" - "mov z28.b, #0x0\n" "mov x20, #0x3\n" - "ptrue p2.b\n" - "mul x20, %x[ld_weight_col], x20\n" - "ld1rw { z27.s }, p2/Z, [%x[qp], %[offsetof_input_offset]]\n" - "ld1rw { z26.s }, p2/Z, [%x[qp], %[offsetof_weights_offset]]\n" + "mov z16.s, #0x9\n" + "mov z31.b, #0x0\n" + "csel %x[ld_weight_col], %x[ld_weight_col], %x[n_channels], NE\n" + "ptrue p3.b\n" + "mov z30.b, #0x1\n" "cmp %x[ld_weight_row], XZR\n" - "csel %x[ld_weight_row], %x[ld_weight_row], x20, NE\n" - "mov z25.b, #0x1\n" - "mul z26.s, p2/M, z26.s, z27.s\n" - "add x24, %x[weights], %x[ld_weight_row]\n" - "ld1rw { z24.s }, p2/Z, [%x[qp], %[offsetof_per_layer_mul]]\n" - "ld1rw { z23.s }, p2/Z, [%x[qp], %[offsetof_per_layer_right_shift]]\n" - "add x23, x24, %x[ld_weight_row]\n" - "add x22, %x[ld_weight_col], %x[ld_weight_col]\n" - "whilelt p1.s, XZR, %x[n_channels]\n" - "mov x21, #0x0\n" - "mul z26.s, p2/M, z26.s, z16.s\n" + "mov x24, #0x0\n" "pfalse p8.b\n" + "mul x20, %x[ld_weight_col], x20\n" + "ld1rw { z29.s }, p3/Z, [%x[qp], %[offsetof_input_offset]]\n" + "ld1rw { z28.s }, p3/Z, [%x[qp], %[offsetof_weights_offset]]\n" + "add x23, %x[ld_weight_col], %x[ld_weight_col]\n" + "ld1rw { z27.s }, p3/Z, [%x[qp], %[offsetof_per_layer_mul]]\n" + "ld1rw { z26.s }, p3/Z, [%x[qp], %[offsetof_per_layer_right_shift]]\n" + "csel %x[ld_weight_row], %x[ld_weight_row], x20, NE\n" + "whilelt p2.s, XZR, %x[n_channels]\n" + "mul z28.s, p3/M, z28.s, z29.s\n" + "add x22, %x[weights], %x[ld_weight_row]\n" + "add x21, x22, %x[ld_weight_row]\n" + "mul z28.s, p3/M, z28.s, z16.s\n" "cbz %x[bias], 1f\n" "ptrue p8.s\n" "1:" // No bias "2:" // Loop - "cntp x20, p2, p1.s\n" + "cntp x20, p3, p2.s\n" + "mov z25.s, #0x0\n" + "and p1.b, p3/Z, p8.b, p2.b\n" "whilelt p0.b, XZR, x20\n" - "ld1b { z18.b }, p0/Z, [%x[weights]]\n" - "ld1b { z17.b }, p0/Z, [%x[weights], %x[ld_weight_col]]\n" - "ld1b { z16.b }, p0/Z, [%x[weights], x22]\n" - "zip1 z20.b, z18.b, z16.b\n" - "zip1 z19.b, z17.b, z28.b\n" - "ld1b { z18.b }, p0/Z, [x24]\n" - "ld1b { z17.b }, p0/Z, [x24, %x[ld_weight_col]]\n" - "ld1b { z16.b }, p0/Z, [x24, x22]\n" - "zip1 z22.b, z20.b, z19.b\n" - "zip1 z21.b, z18.b, z16.b\n" - "zip1 z19.b, z17.b, z28.b\n" - "mov z20.s, #0x0\n" - "ld1b { z18.b }, p0/Z, [x23]\n" - "ld1b { z17.b }, p0/Z, [x23, %x[ld_weight_col]]\n" - "ld1b { z16.b }, p0/Z, [x23, x22]\n" - "sdot z20.s, z25.b, z22.b\n" - "zip1 z19.b, z21.b, z19.b\n" - "sdot z20.s, z25.b, z19.b\n" - "zip1 z18.b, z18.b, z16.b\n" - "zip1 z16.b, z17.b, z28.b\n" - "and p0.b, p2/Z, p8.b, p1.b\n" - "ld1w { z17.s }, p0/Z, [%x[bias], x21, LSL #2]\n" - "zip1 z16.b, z18.b, z16.b\n" - "sdot z20.s, z25.b, z16.b\n" - "mls z17.s, p2/M, z20.s, z27.s\n" + "ld1w { z24.s }, p1/Z, [%x[bias], x24, LSL #2]\n" + "ld1b { z19.b }, p0/Z, [%x[weights]]\n" + "ld1b { z18.b }, p0/Z, [%x[weights], %x[ld_weight_col]]\n" + "ld1b { z16.b }, p0/Z, [%x[weights], x23]\n" "add %x[weights], %x[weights], x20\n" - "add x24, x24, x20\n" - "add x23, x23, x20\n" - "add z17.s, z17.s, z26.s\n" - "st1w { z17.s }, p2, [%x[outptr]]\n" - "st1b { z22.b }, p2, [%x[outptr], #1, MUL VL]\n" - "st1b { z19.b }, p2, [%x[outptr], #2, MUL VL]\n" - "st1b { z16.b }, p2, [%x[outptr], #3, MUL VL]\n" + "ld1b { z23.b }, p0/Z, [x22]\n" + "ld1b { z20.b }, p0/Z, [x22, %x[ld_weight_col]]\n" + "ld1b { z17.b }, p0/Z, [x22, x23]\n" + "ld1b { z22.b }, p0/Z, [x21]\n" + "add x22, x22, x20\n" + "zip1 z19.b, z19.b, z16.b\n" + "zip1 z18.b, z18.b, z31.b\n" + "ld1b { z21.b }, p0/Z, [x21, %x[ld_weight_col]]\n" + "ld1b { z16.b }, p0/Z, [x21, x23]\n" + "add x21, x21, x20\n" + "zip1 z20.b, z20.b, z31.b\n" + "zip1 z17.b, z23.b, z17.b\n" + "zip1 z19.b, z19.b, z18.b\n" + "zip1 z18.b, z22.b, z16.b\n" + "zip1 z16.b, z21.b, z31.b\n" + "zip1 z17.b, z17.b, z20.b\n" + "sdot z25.s, z30.b, z19.b\n" + "zip1 z16.b, z18.b, z16.b\n" + "sdot z25.s, z30.b, z17.b\n" + "sdot z25.s, z30.b, z16.b\n" + "mls z24.s, p3/M, z25.s, z29.s\n" + "add z24.s, z24.s, z28.s\n" + "st1w { z24.s }, p3, [%x[outptr]]\n" + "st1b { z19.b }, p3, [%x[outptr], #1, MUL VL]\n" + "st1b { z17.b }, p3, [%x[outptr], #2, MUL VL]\n" + "st1b { z16.b }, p3, [%x[outptr], #3, MUL VL]\n" "addvl %x[outptr], %x[outptr], #4\n" "cbz %x[rq_mul_perchannel], 3f\n" - "ld1w { z24.s }, p1/Z, [%x[rq_mul_perchannel], x21, LSL #2]\n" - "ld1w { z23.s }, p1/Z, [%x[rq_shift_perchannel], x21, LSL #2]\n" + "ld1w { z27.s }, p2/Z, [%x[rq_mul_perchannel], x24, LSL #2]\n" + "ld1w { z26.s }, p2/Z, [%x[rq_shift_perchannel], x24, LSL #2]\n" "3:" // Loop: Quantisation parameters: Store - "incw x21\n" - "whilelt p1.s, x21, %x[n_channels]\n" - "st1w { z24.s }, p2, [%x[outptr]]\n" - "st1w { z23.s }, p2, [%x[outptr], #1, MUL VL]\n" + "incw x24\n" + "st1w { z27.s }, p3, [%x[outptr]]\n" + "st1w { z26.s }, p3, [%x[outptr], #1, MUL VL]\n" "addvl %x[outptr], %x[outptr], #2\n" + "whilelt p2.s, x24, %x[n_channels]\n" "b.any 2b\n" : [ld_weight_col] "+&r" (ld_weight_col), [ld_weight_row] "+&r" (ld_weight_row), [outptr] "+&r" (outptr), [weights] "+&r" (weights) : [bias] "r" (bias), [n_channels] "r" (n_channels), [offsetof_input_offset] "I" (offsetof(arm_gemm::Requantize32, a_offset)), [offsetof_per_layer_mul] "I" (offsetof(arm_gemm::Requantize32, per_layer_mul)), [offsetof_per_layer_right_shift] "I" (offsetof(arm_gemm::Requantize32, per_layer_right_shift)), [offsetof_weights_offset] "I" (offsetof(arm_gemm::Requantize32, b_offset)), [qp] "r" (&qp), [rq_mul_perchannel] "r" (qp.per_channel_muls), [rq_shift_perchannel] "r" (qp.per_channel_right_shifts) - : "cc", "memory", "p0", "p1", "p2", "p8", "x20", "x21", "x22", "x23", "x24", "z16", "z17", "z18", "z19", "z20", "z21", "z22", "z23", "z24", "z25", "z26", "z27", "z28" + : "cc", "memory", "p0", "p1", "p2", "p3", "p8", "x20", "x21", "x22", "x23", "x24", "z16", "z17", "z18", "z19", "z20", "z21", "z22", "z23", "z24", "z25", "z26", "z27", "z28", "z29", "z30", "z31" ); } -- cgit v1.2.1