/* * Copyright (c) 2019 ARM Limited. * * SPDX-License-Identifier: MIT * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to * deal in the Software without restriction, including without limitation the * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or * sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ #ifdef __aarch64__ #include "../../asmlib.hpp" #include "../../utils.hpp" #include #include #include #include namespace arm_gemm { void a64_sgemm_nativeA_pretransposeB_16x4(const float *A, int lda, const float *B_panel, float *C, int ldc, float beta, unsigned int numrows, unsigned int numcols, unsigned int K) { const bool oddk = ((K % 8) >= 4); const bool beta0 = (beta == 0.0f); const unsigned int oddones = (K % 4); /* Use some small temporary arrays to cope with "ragged" M/N sizes. * * "dummy_A_buf" is used to avoid overreading the A input for ragged M, * and also for output if N is not ragged. * * Since the B input is pretransposed it will be padded as needed, so no * need to worry about overreading that. * * "C_buf" is used to avoid overreading or overwriting the output for * ragged N cases. */ float dummy_A_buf[16]; float C_buf[64]; std::memset(dummy_A_buf, 0, sizeof(dummy_A_buf)); std::memset(C_buf, 0, sizeof(C_buf)); for (unsigned int y=0; y 1) ? 32 : 0; const unsigned long a_incr2 = (active_rows > 2) ? 32 : 0; const unsigned long a_incr3 = (active_rows > 3) ? 32 : 0; /* Starting points for A pointers on this loop */ const float * const a_ptr0_base = A + (y * lda); const float * const a_ptr1_base = (active_rows > 1) ? (a_ptr0_base + lda) : dummy_A_buf; const float * const a_ptr2_base = (active_rows > 2) ? (a_ptr1_base + lda) : dummy_A_buf; const float * const a_ptr3_base = (active_rows > 3) ? (a_ptr2_base + lda) : dummy_A_buf; /* Starting points for C pointers on this loop */ float *c_ptr0 = C + (y * ldc); float *c_ptr1 = (active_rows > 1) ? (c_ptr0 + ldc) : dummy_A_buf; float *c_ptr2 = (active_rows > 2) ? (c_ptr1 + ldc) : dummy_A_buf; float *c_ptr3 = (active_rows > 3) ? (c_ptr2 + ldc) : dummy_A_buf; for (unsigned int x0=0; x0