Changesets · Branches · Tags · Compare
| Changeset | 784957476a84eda4f89cd043a08a97e7740eee1ff2e3bb31b385850c13e81ef0 |
|---|---|
| Author | Viet-Hoa Do <viet-hoa.do@arm.com> · 2026-06-17 11:46 UTC |
| Committer | Viet-Hoa Do <viet-hoa.do@arm.com> · 2026-06-17 11:46 UTC |
| Parents | 5f9c5b4ed164 |
15 files changed
modified docs/microkernel_testing.md +7 −7
| @@ -23,7 +23,7 @@ | ||
| 23 | 23 | subdirectories of `test/nextgen/operators/matmul`. The files here adapt the |
| 24 | 24 | micro-kernel C API into the common test harness API. Micro-kernel factory |
| 25 | 25 | declarations are listed in wrapper interface headers, e.g., |
| 26 | - `test/nextgen/operators/matmul/matmul/matmul_wrapper.hpp`. | |
| 26 | + `test/nextgen/operators/matmul/matmul/matmul_wrapper_registry.hpp`. | |
| 27 | 27 | - A test bench in `test/nextgen/operators/matmul/matmul_tb.cpp` that generates |
| 28 | 28 | inputs, runs the implementation, and compares to a reference. |
| 29 | 29 | |
| @@ -164,7 +164,7 @@ | ||
| 164 | 164 | As an example, the matmul factory can be implemented as follows: |
| 165 | 165 | |
| 166 | 166 | ```cpp |
| 167 | -// test/nextgen/operators/matmul/matmul/matmul_wrapper.cpp | |
| 167 | +// test/nextgen/operators/matmul/matmul/matmul_wrapper_registry.cpp | |
| 168 | 168 | std::unique_ptr<KernelWrapper<MatMulShape>> |
| 169 | 169 | create_matmul_clamp_f16_f16_f16p_neon() { |
| 170 | 170 | return std::make_unique<MatMulFpWrapper>( |
| @@ -186,25 +186,25 @@ | ||
| 186 | 186 | |
| 187 | 187 | For this example, the matmul wrapper uses unpacked FP16 LHS, packed FP16 RHS |
| 188 | 188 | with block size of $16 ⨯ 1$, and a plain FP16 destination format. Use existing |
| 189 | -factories in `matmul_wrapper.cpp` and packer wrappers as a model. | |
| 189 | +factories in `matmul_wrapper_registry.cpp` and packer wrappers as a model. | |
| 190 | 190 | |
| 191 | 191 | Make sure there is a `create_matmul_...` factory declaration added to |
| 192 | -`test/nextgen/operators/matmul/matmul/matmul_wrapper.hpp` for the new micro-kernel. | |
| 192 | +`test/nextgen/operators/matmul/matmul/matmul_wrapper_registry.hpp` for the new micro-kernel. | |
| 193 | 193 | |
| 194 | 194 | ### Step 2: Add packing micro-kernel wrapper factories |
| 195 | 195 | |
| 196 | 196 | For the F16 example, only RHS packing is needed. Add or reuse the RHS |
| 197 | 197 | packer wrapper in: |
| 198 | 198 | |
| 199 | -- `test/nextgen/operators/matmul/pack_rhs/matmul_pack_rhs_wrapper.cpp` | |
| 199 | +- `test/nextgen/operators/matmul/pack_rhs/matmul_pack_rhs_wrapper_registry.cpp` | |
| 200 | 200 | |
| 201 | 201 | If another micro-kernel also packs the LHS, add or reuse a packer wrapper in |
| 202 | -`test/nextgen/operators/matmul/pack_lhs/matmul_pack_lhs_wrapper.cpp`. | |
| 202 | +`test/nextgen/operators/matmul/pack_lhs/matmul_pack_lhs_wrapper_registry.cpp`. | |
| 203 | 203 | |
| 204 | 204 | Example skeleton for RHS packing: |
| 205 | 205 | |
| 206 | 206 | ```cpp |
| 207 | -// test/nextgen/operators/matmul/pack_rhs/matmul_pack_rhs_wrapper.cpp | |
| 207 | +// test/nextgen/operators/matmul/pack_rhs/matmul_pack_rhs_wrapper_registry.cpp | |
| 208 | 208 | std::unique_ptr<KernelWrapper<MatShape>> |
| 209 | 209 | create_matmul_rhs_pack_kxn_f16p16x1biasf16_f16_f16_neon() { |
| 210 | 210 | return std::make_unique<MatMulPackRhsFpNtWrapper>( |
modified test/CMakeLists.txt +3 −3
| @@ -61,14 +61,14 @@ | ||
| 61 | 61 | test/nextgen/format/block2d_row_format.cpp |
| 62 | 62 | test/nextgen/quantization/asymm_linear_quantizer.cpp |
| 63 | 63 | test/nextgen/quantization/symm_linear_quantizer.cpp |
| 64 | - test/nextgen/operators/matmul/pack_lhs/matmul_pack_lhs_wrapper.cpp | |
| 64 | + test/nextgen/operators/matmul/pack_lhs/matmul_pack_lhs_wrapper_registry.cpp | |
| 65 | 65 | test/nextgen/operators/matmul/pack_lhs/matmul_pack_lhs_dq_wrapper.cpp |
| 66 | 66 | test/nextgen/operators/matmul/pack_lhs/matmul_pack_lhs_fp_wrapper.cpp |
| 67 | 67 | test/nextgen/operators/matmul/pack_lhs/matmul_pack_lhs_ukerapi_wrapper.cpp |
| 68 | - test/nextgen/operators/matmul/pack_rhs/matmul_pack_rhs_wrapper.cpp | |
| 68 | + test/nextgen/operators/matmul/pack_rhs/matmul_pack_rhs_wrapper_registry.cpp | |
| 69 | 69 | test/nextgen/operators/matmul/pack_rhs/matmul_pack_rhs_quant_wrapper.cpp |
| 70 | 70 | test/nextgen/operators/matmul/pack_rhs/matmul_pack_rhs_fp_nt_wrapper.cpp |
| 71 | - test/nextgen/operators/matmul/matmul/matmul_wrapper.cpp | |
| 71 | + test/nextgen/operators/matmul/matmul/matmul_wrapper_registry.cpp | |
| 72 | 72 | test/nextgen/operators/matmul/matmul/matmul_dq_wrapper.cpp |
| 73 | 73 | test/nextgen/operators/matmul/matmul/matmul_fp_wrapper.cpp |
| 74 | 74 | test/nextgen/operators/matmul/matmul/matmul_ukerapi_wrapper.cpp |
deleted test/nextgen/operators/matmul/matmul/matmul_wrapper.cpp +0 −199
| @@ -1,199 +0,0 @@ | ||
| 1 | -// | |
| 2 | -// SPDX-FileCopyrightText: Copyright 2025-2026 Arm Limited and/or its affiliates <open-source-office@arm.com> | |
| 3 | -// | |
| 4 | -// SPDX-License-Identifier: Apache-2.0 | |
| 5 | -// | |
| 6 | - | |
| 7 | -#include "test/nextgen/operators/matmul/matmul/matmul_wrapper.hpp" | |
| 8 | - | |
| 9 | -#include <array> | |
| 10 | -#include <memory> | |
| 11 | - | |
| 12 | -#include "kai/ukernels/matmul/kai_matmul.h" | |
| 13 | -#include "kai/ukernels/matmul/matmul_clamp_f32_f32p_f32p/kai_matmul_clamp_f32_f32p2vlx1_f32p2vlx1biasf32_sme2_mopa.h" | |
| 14 | -#include "kai/ukernels/matmul/matmul_clamp_f32_qai8dxp_qsi4cxp/kai_matmul_clamp_f32_qai8dxp1vlx4_qsi4cxp4vlx4_1vlx4vl_sme_mopa.h" | |
| 15 | -#include "kai/ukernels/matmul/matmul_clamp_f32_qai8dxp_qsi4cxp/kai_matmul_clamp_f32_qai8dxp1vlx8_qsi4cxp4vlx8_1vlx4vl_sme2_mopa.h" | |
| 16 | -#include "kai/ukernels/matmul/matmul_clamp_f32_qai8dxp_qsi4cxp/kai_matmul_clamp_f32_qai8dxp1x4_qsi4cxp4vlx4_1x4vl_sme2_sdot.h" | |
| 17 | -#include "test/common/data_type.hpp" | |
| 18 | -#include "test/common/sme.hpp" | |
| 19 | -#include "test/nextgen/format/block2d_row_format.hpp" | |
| 20 | -#include "test/nextgen/format/plain_format.hpp" | |
| 21 | -#include "test/nextgen/functions/round.hpp" | |
| 22 | -#include "test/nextgen/harness/kernel_wrapper.hpp" | |
| 23 | -#include "test/nextgen/operators/matmul/matmul/matmul_dq_wrapper.hpp" | |
| 24 | -#include "test/nextgen/operators/matmul/matmul/matmul_fp_wrapper.hpp" | |
| 25 | -#include "test/nextgen/operators/matmul/matmul/matmul_interface.hpp" | |
| 26 | -#include "test/nextgen/operators/matmul/matmul/matmul_ukerapi_wrapper.hpp" | |
| 27 | -#include "test/nextgen/operators/matmul/matmul_slots.hpp" | |
| 28 | -#include "test/nextgen/quantization/asymm_linear_quantizer.hpp" | |
| 29 | -#include "test/nextgen/quantization/symm_linear_quantizer.hpp" | |
| 30 | - | |
| 31 | -namespace kai::test { | |
| 32 | - | |
| 33 | -std::unique_ptr<KernelWrapper<MatMulShape>> create_matmul_clamp_f32_qai8dxp1vlx8_qsi4cxp4vlx8_1vlx4vl_sme2_mopa() { | |
| 34 | - return std::make_unique<MatMulDqWrapper>( | |
| 35 | - "matmul_clamp_f32_qai8dxp1vlx8_qsi4cxp4vlx8_1vlx4vl_sme2_mopa", | |
| 36 | - MatMulDqInterface{ | |
| 37 | - kai_get_m_step_matmul_clamp_f32_qai8dxp1vlx8_qsi4cxp4vlx8_1vlx4vl_sme2_mopa, | |
| 38 | - kai_get_n_step_matmul_clamp_f32_qai8dxp1vlx8_qsi4cxp4vlx8_1vlx4vl_sme2_mopa, | |
| 39 | - kai_get_mr_matmul_clamp_f32_qai8dxp1vlx8_qsi4cxp4vlx8_1vlx4vl_sme2_mopa, | |
| 40 | - kai_get_nr_matmul_clamp_f32_qai8dxp1vlx8_qsi4cxp4vlx8_1vlx4vl_sme2_mopa, | |
| 41 | - kai_get_kr_matmul_clamp_f32_qai8dxp1vlx8_qsi4cxp4vlx8_1vlx4vl_sme2_mopa, | |
| 42 | - kai_get_sr_matmul_clamp_f32_qai8dxp1vlx8_qsi4cxp4vlx8_1vlx4vl_sme2_mopa, | |
| 43 | - kai_get_lhs_packed_offset_matmul_clamp_f32_qai8dxp1vlx8_qsi4cxp4vlx8_1vlx4vl_sme2_mopa, | |
| 44 | - kai_get_rhs_packed_offset_matmul_clamp_f32_qai8dxp1vlx8_qsi4cxp4vlx8_1vlx4vl_sme2_mopa, | |
| 45 | - kai_get_dst_offset_matmul_clamp_f32_qai8dxp1vlx8_qsi4cxp4vlx8_1vlx4vl_sme2_mopa, | |
| 46 | - kai_get_dst_size_matmul_clamp_f32_qai8dxp1vlx8_qsi4cxp4vlx8_1vlx4vl_sme2_mopa, | |
| 47 | - kai_run_matmul_clamp_f32_qai8dxp1vlx8_qsi4cxp4vlx8_1vlx4vl_sme2_mopa, | |
| 48 | - }, | |
| 49 | - std::make_unique<AsymmLinearQuantizer>( | |
| 50 | - DataType::I8, DataType::FP32, DataType::I32, RoundMode::TIE_AWAY, RoundMode::CURRENT, 1, 0), | |
| 51 | - std::make_unique<SymmLinearQuantizer>(DataType::U4, DataType::FP32, RoundMode::CURRENT, 1, 0), | |
| 52 | - make_poly<Block2dRowFormat>( | |
| 53 | - 1 * get_sme_vector_length<float>(), 4, 32, true, DataType::I8, std::array<DataType, 0>{}, | |
| 54 | - std::array{DataType::I32, DataType::FP32}), | |
| 55 | - make_poly<Block2dRowFormat>( | |
| 56 | - 4 * get_sme_vector_length<float>(), 4, 32, false, DataType::I4, std::array<DataType, 0>{}, | |
| 57 | - std::array{DataType::I32, DataType::FP32, DataType::FP32}), | |
| 58 | - make_poly<PlainFormat>(DataType::FP32)); | |
| 59 | -} | |
| 60 | - | |
| 61 | -std::unique_ptr<KernelWrapper<MatMulShape>> create_matmul_clamp_f32_qai8dxp1vlx4_qsi4cxp4vlx4_1vlx4vl_sme_mopa() { | |
| 62 | - return std::make_unique<MatMulDqWrapper>( | |
| 63 | - "matmul_clamp_f32_qai8dxp1vlx4_qsi4cxp4vlx4_1vlx4vl_sme_mopa", | |
| 64 | - MatMulDqInterface{ | |
| 65 | - kai_get_m_step_matmul_clamp_f32_qai8dxp1vlx4_qsi4cxp4vlx4_1vlx4vl_sme_mopa, | |
| 66 | - kai_get_n_step_matmul_clamp_f32_qai8dxp1vlx4_qsi4cxp4vlx4_1vlx4vl_sme_mopa, | |
| 67 | - kai_get_mr_matmul_clamp_f32_qai8dxp1vlx4_qsi4cxp4vlx4_1vlx4vl_sme_mopa, | |
| 68 | - kai_get_nr_matmul_clamp_f32_qai8dxp1vlx4_qsi4cxp4vlx4_1vlx4vl_sme_mopa, | |
| 69 | - kai_get_kr_matmul_clamp_f32_qai8dxp1vlx4_qsi4cxp4vlx4_1vlx4vl_sme_mopa, | |
| 70 | - kai_get_sr_matmul_clamp_f32_qai8dxp1vlx4_qsi4cxp4vlx4_1vlx4vl_sme_mopa, | |
| 71 | - kai_get_lhs_packed_offset_matmul_clamp_f32_qai8dxp1vlx4_qsi4cxp4vlx4_1vlx4vl_sme_mopa, | |
| 72 | - kai_get_rhs_packed_offset_matmul_clamp_f32_qai8dxp1vlx4_qsi4cxp4vlx4_1vlx4vl_sme_mopa, | |
| 73 | - kai_get_dst_offset_matmul_clamp_f32_qai8dxp1vlx4_qsi4cxp4vlx4_1vlx4vl_sme_mopa, | |
| 74 | - kai_get_dst_size_matmul_clamp_f32_qai8dxp1vlx4_qsi4cxp4vlx4_1vlx4vl_sme_mopa, | |
| 75 | - kai_run_matmul_clamp_f32_qai8dxp1vlx4_qsi4cxp4vlx4_1vlx4vl_sme_mopa, | |
| 76 | - }, | |
| 77 | - std::make_unique<AsymmLinearQuantizer>( | |
| 78 | - DataType::I8, DataType::FP32, DataType::I32, RoundMode::TIE_AWAY, RoundMode::CURRENT, 1, 0), | |
| 79 | - std::make_unique<SymmLinearQuantizer>(DataType::U4, DataType::FP32, RoundMode::CURRENT, 1, 0), | |
| 80 | - make_poly<Block2dRowFormat>( | |
| 81 | - 1 * get_sme_vector_length<float>(), 4, 32, true, DataType::I8, std::array<DataType, 0>{}, | |
| 82 | - std::array{DataType::I32, DataType::FP32}), | |
| 83 | - make_poly<Block2dRowFormat>( | |
| 84 | - 4 * get_sme_vector_length<float>(), 4, 32, false, DataType::I4, std::array<DataType, 0>{}, | |
| 85 | - std::array{DataType::I32, DataType::FP32, DataType::FP32}), | |
| 86 | - make_poly<PlainFormat>(DataType::FP32)); | |
| 87 | -} | |
| 88 | - | |
| 89 | -std::unique_ptr<KernelWrapper<MatMulShape>> create_matmul_clamp_f32_qai8dxp1x4_qsi4cxp4vlx4_1x4vl_sme2_sdot() { | |
| 90 | - return std::make_unique<MatMulDqWrapper>( | |
| 91 | - "matmul_clamp_f32_qai8dxp1x4_qsi4cxp4vlx4_1x4vl_sme2_sdot", | |
| 92 | - MatMulDqInterface{ | |
| 93 | - kai_get_m_step_matmul_clamp_f32_qai8dxp1x4_qsi4cxp4vlx4_1x4vl_sme2_sdot, | |
| 94 | - kai_get_n_step_matmul_clamp_f32_qai8dxp1x4_qsi4cxp4vlx4_1x4vl_sme2_sdot, | |
| 95 | - kai_get_mr_matmul_clamp_f32_qai8dxp1x4_qsi4cxp4vlx4_1x4vl_sme2_sdot, | |
| 96 | - kai_get_nr_matmul_clamp_f32_qai8dxp1x4_qsi4cxp4vlx4_1x4vl_sme2_sdot, | |
| 97 | - kai_get_kr_matmul_clamp_f32_qai8dxp1x4_qsi4cxp4vlx4_1x4vl_sme2_sdot, | |
| 98 | - kai_get_sr_matmul_clamp_f32_qai8dxp1x4_qsi4cxp4vlx4_1x4vl_sme2_sdot, | |
| 99 | - kai_get_lhs_packed_offset_matmul_clamp_f32_qai8dxp1x4_qsi4cxp4vlx4_1x4vl_sme2_sdot, | |
| 100 | - kai_get_rhs_packed_offset_matmul_clamp_f32_qai8dxp1x4_qsi4cxp4vlx4_1x4vl_sme2_sdot, | |
| 101 | - kai_get_dst_offset_matmul_clamp_f32_qai8dxp1x4_qsi4cxp4vlx4_1x4vl_sme2_sdot, | |
| 102 | - kai_get_dst_size_matmul_clamp_f32_qai8dxp1x4_qsi4cxp4vlx4_1x4vl_sme2_sdot, | |
| 103 | - kai_run_matmul_clamp_f32_qai8dxp1x4_qsi4cxp4vlx4_1x4vl_sme2_sdot, | |
| 104 | - }, | |
| 105 | - std::make_unique<AsymmLinearQuantizer>( | |
| 106 | - DataType::I8, DataType::FP32, DataType::I32, RoundMode::TIE_AWAY, RoundMode::CURRENT, 1, 0), | |
| 107 | - std::make_unique<SymmLinearQuantizer>(DataType::U4, DataType::FP32, RoundMode::CURRENT, 1, 0), | |
| 108 | - make_poly<Block2dRowFormat>( | |
| 109 | - 1, 4, 32, true, DataType::I8, std::array<DataType, 0>{}, std::array{DataType::I32, DataType::FP32}), | |
| 110 | - make_poly<Block2dRowFormat>( | |
| 111 | - 4 * get_sme_vector_length<float>(), 4, 32, false, DataType::I4, std::array<DataType, 0>{}, | |
| 112 | - std::array{DataType::I32, DataType::FP32, DataType::FP32}), | |
| 113 | - make_poly<PlainFormat>(DataType::FP32)); | |
| 114 | -} | |
| 115 | - | |
| 116 | -std::unique_ptr<KernelWrapper<MatMulShape>> create_matmul_clamp_f32_f32p2vlx1_f32p2vlx1biasf32_sme2_mopa() { | |
| 117 | - return std::make_unique<MatMulFpWrapper>( | |
| 118 | - "matmul_clamp_f32_f32p2vlx1_f32p2vlx1biasf32_sme2_mopa", | |
| 119 | - MatMulFpInterface{ | |
| 120 | - kai_get_m_step_matmul_clamp_f32_f32p2vlx1_f32p2vlx1biasf32_sme2_mopa, | |
| 121 | - kai_get_n_step_matmul_clamp_f32_f32p2vlx1_f32p2vlx1biasf32_sme2_mopa, | |
| 122 | - kai_get_mr_matmul_clamp_f32_f32p2vlx1_f32p2vlx1biasf32_sme2_mopa, | |
| 123 | - kai_get_nr_matmul_clamp_f32_f32p2vlx1_f32p2vlx1biasf32_sme2_mopa, | |
| 124 | - kai_get_kr_matmul_clamp_f32_f32p2vlx1_f32p2vlx1biasf32_sme2_mopa, | |
| 125 | - kai_get_sr_matmul_clamp_f32_f32p2vlx1_f32p2vlx1biasf32_sme2_mopa, | |
| 126 | - kai_get_lhs_packed_offset_matmul_clamp_f32_f32p2vlx1_f32p2vlx1biasf32_sme2_mopa, | |
| 127 | - kai_get_rhs_packed_offset_matmul_clamp_f32_f32p2vlx1_f32p2vlx1biasf32_sme2_mopa, | |
| 128 | - kai_get_dst_offset_matmul_clamp_f32_f32p2vlx1_f32p2vlx1biasf32_sme2_mopa, | |
| 129 | - kai_get_dst_size_matmul_clamp_f32_f32p2vlx1_f32p2vlx1biasf32_sme2_mopa, | |
| 130 | - kai_run_matmul_clamp_f32_f32p2vlx1_f32p2vlx1biasf32_sme2_mopa, | |
| 131 | - }, | |
| 132 | - make_poly<Block2dRowFormat>( | |
| 133 | - 1 * get_sme_vector_length<float>(), 1, 1, false, DataType::FP32, std::array<DataType, 0>{}, | |
| 134 | - std::array<DataType, 0>{}), | |
| 135 | - make_poly<Block2dRowFormat>( | |
| 136 | - 1 * get_sme_vector_length<float>(), 1, 1, false, DataType::FP32, std::array{DataType::FP32}, | |
| 137 | - std::array<DataType, 0>{}), | |
| 138 | - make_poly<PlainFormat>(DataType::FP32)); | |
| 139 | -} | |
| 140 | - | |
| 141 | -std::unique_ptr<KernelWrapper<MatMulShape>> create_matmul_clamp_f32_f32p4vsx1_f32p4vsx1b_8vsx8vs_elastic_sme2_mopa() { | |
| 142 | - return std::make_unique<MatMulUkerApiWrapper>( | |
| 143 | - "matmul_clamp_f32_f32p4vsx1_f32p4vsx1b_8vsx8vs_elastic_sme2_mopa", | |
| 144 | - kai_matmul_clamp_f32_f32p4vsx1_f32p4vsx1bf32_8vsx8vs_sme2_mopa(), MatMulSlot::LHS_PACKED, | |
| 145 | - make_poly<Block2dRowFormat>( | |
| 146 | - 4 * get_sme_vector_scale(), 1, 1, false, DataType::FP32, std::array<DataType, 0>{}, | |
| 147 | - std::array<DataType, 0>{}), | |
| 148 | - make_poly<Block2dRowFormat>( | |
| 149 | - 4 * get_sme_vector_scale(), 1, 1, false, DataType::FP32, std::array{DataType::FP32}, | |
| 150 | - std::array<DataType, 0>{}), | |
| 151 | - make_poly<PlainFormat>(DataType::FP32), DataType::FP32, MatMulUkerClampConfig::optional(DataType::FP32), | |
| 152 | - MatMulUkerApiBiasDeliveryStage::PACK_RHS); | |
| 153 | -} | |
| 154 | - | |
| 155 | -std::unique_ptr<KernelWrapper<MatMulShape>> create_matmul_i32_u8p4vsx4_u8p4vsx4_i32_i32_8vsx8vs_sme2_mopa() { | |
| 156 | - return std::make_unique<MatMulUkerApiWrapper>( | |
| 157 | - "matmul_i32_u8p4vsx4_u8p4vsx4_i32_i32_8vsx8vs_sme2_mopa", | |
| 158 | - kai_matmul_i32_u8p4vsx4_u8p4vsx4_i32_i32_8vsx8vs_sme2_mopa(), MatMulSlot::LHS_PACKED, | |
| 159 | - make_poly<Block2dRowFormat>( | |
| 160 | - 4 * get_sme_vector_scale(), 4, 4, false, DataType::U8, std::array<DataType, 0>{}, | |
| 161 | - std::array<DataType, 0>{}), | |
| 162 | - make_poly<Block2dRowFormat>( | |
| 163 | - 4 * get_sme_vector_scale(), 4, 4, false, DataType::U8, std::array<DataType, 0>{}, | |
| 164 | - std::array<DataType, 0>{}), | |
| 165 | - make_poly<PlainFormat>(DataType::I32), DataType::I32, MatMulUkerClampConfig::unsupported(), | |
| 166 | - MatMulUkerApiBiasDeliveryStage::MATMUL); | |
| 167 | -} | |
| 168 | - | |
| 169 | -std::unique_ptr<KernelWrapper<MatMulShape>> | |
| 170 | -create_matmul_clamp_f32_u8p4vsx4_u8p4vsx4_i32_i32_f32_f32_8vsx8vs_sme2_mopa() { | |
| 171 | - return std::make_unique<MatMulUkerApiWrapper>( | |
| 172 | - "matmul_clamp_f32_u8p4vsx4_u8p4vsx4_i32_i32_f32_f32_8vsx8vs_sme2_mopa", | |
| 173 | - kai_matmul_clamp_f32_u8p4vsx4_u8p4vsx4_i32_i32_f32_f32_8vsx8vs_sme2_mopa(), MatMulSlot::LHS_PACKED, | |
| 174 | - make_poly<Block2dRowFormat>( | |
| 175 | - 4 * get_sme_vector_scale(), 4, 4, false, DataType::U8, std::array<DataType, 0>{}, | |
| 176 | - std::array<DataType, 0>{}), | |
| 177 | - make_poly<Block2dRowFormat>( | |
| 178 | - 4 * get_sme_vector_scale(), 4, 4, false, DataType::U8, std::array<DataType, 0>{}, | |
| 179 | - std::array<DataType, 0>{}), | |
| 180 | - make_poly<PlainFormat>(DataType::FP32), DataType::I32, MatMulUkerClampConfig::optional(DataType::FP32), | |
| 181 | - MatMulUkerApiBiasDeliveryStage::MATMUL, | |
| 182 | - MatMulUkerOutputStageConfig{ | |
| 183 | - MatMulUkerStageParameterLayout::GLOBAL, | |
| 184 | - MatMulUkerStageParameterLayout::PER_N, | |
| 185 | - }); | |
| 186 | -} | |
| 187 | - | |
| 188 | -std::unique_ptr<KernelWrapper<MatMulShape>> create_matmul_clamp_f32_f32_f32p4vsx1bf32_1x32vs_sme2_mla() { | |
| 189 | - return std::make_unique<MatMulUkerApiWrapper>( | |
| 190 | - "matmul_clamp_f32_f32_f32p4vsx1bf32_1x32vs_sme2_mla", kai_matmul_clamp_f32_f32_f32p4vsx1bf32_1x32vs_sme2_mla(), | |
| 191 | - MatMulSlot::LHS_DATA, make_poly<PlainFormat>(DataType::FP32), | |
| 192 | - make_poly<Block2dRowFormat>( | |
| 193 | - 4 * get_sme_vector_scale(), 1, 1, false, DataType::FP32, std::array{DataType::FP32}, | |
| 194 | - std::array<DataType, 0>{}), | |
| 195 | - make_poly<PlainFormat>(DataType::FP32), DataType::FP32, MatMulUkerClampConfig::optional(DataType::FP32), | |
| 196 | - MatMulUkerApiBiasDeliveryStage::PACK_RHS); | |
| 197 | -} | |
| 198 | - | |
| 199 | -} // namespace kai::test |
deleted test/nextgen/operators/matmul/matmul/matmul_wrapper.hpp +0 −47
| @@ -1,47 +0,0 @@ | ||
| 1 | -// | |
| 2 | -// SPDX-FileCopyrightText: Copyright 2025-2026 Arm Limited and/or its affiliates <open-source-office@arm.com> | |
| 3 | -// | |
| 4 | -// SPDX-License-Identifier: Apache-2.0 | |
| 5 | -// | |
| 6 | - | |
| 7 | -#pragma once | |
| 8 | - | |
| 9 | -#include <memory> | |
| 10 | - | |
| 11 | -#include "test/nextgen/harness/kernel_wrapper.hpp" | |
| 12 | -#include "test/nextgen/operators/matmul/matmul_dims.hpp" | |
| 13 | - | |
| 14 | -namespace kai::test { | |
| 15 | - | |
| 16 | -/// Creates a wrapper for matmul_clamp_f32_qai8dxp1vlx8_qsi4cxp4vlx8_1vlx4vl_sme2_mopa kernel. | |
| 17 | -[[nodiscard]] std::unique_ptr<KernelWrapper<MatMulShape>> | |
| 18 | -create_matmul_clamp_f32_qai8dxp1vlx8_qsi4cxp4vlx8_1vlx4vl_sme2_mopa(); | |
| 19 | - | |
| 20 | -/// Creates a wrapper for matmul_clamp_f32_qai8dxp1vlx4_qsi4cxp4vlx4_1vlx4vl_sme_mopa kernel. | |
| 21 | -[[nodiscard]] std::unique_ptr<KernelWrapper<MatMulShape>> | |
| 22 | -create_matmul_clamp_f32_qai8dxp1vlx4_qsi4cxp4vlx4_1vlx4vl_sme_mopa(); | |
| 23 | - | |
| 24 | -/// Creates a wrapper for matmul_clamp_f32_qai8dxp1x4_qsi4cxp4vlx4_1x4vl_sme2_sdot kernel. | |
| 25 | -[[nodiscard]] std::unique_ptr<KernelWrapper<MatMulShape>> | |
| 26 | -create_matmul_clamp_f32_qai8dxp1x4_qsi4cxp4vlx4_1x4vl_sme2_sdot(); | |
| 27 | - | |
| 28 | -/// Creates a wrapper for matmul_clamp_f32_f32p2vlx1_f32p2vlx1biasf32_sme2_mopa kernel. | |
| 29 | -[[nodiscard]] std::unique_ptr<KernelWrapper<MatMulShape>> | |
| 30 | -create_matmul_clamp_f32_f32p2vlx1_f32p2vlx1biasf32_sme2_mopa(); | |
| 31 | - | |
| 32 | -/// Creates a wrapper for matmul_clamp_f32_f32p4vsx1_f32p4vsx1b_8vsx8vs_elastic_sme2_mopa kernel. | |
| 33 | -[[nodiscard]] std::unique_ptr<KernelWrapper<MatMulShape>> | |
| 34 | -create_matmul_clamp_f32_f32p4vsx1_f32p4vsx1b_8vsx8vs_elastic_sme2_mopa(); | |
| 35 | - | |
| 36 | -/// Creates a wrapper for matmul_i32_u8p4vsx4_u8p4vsx4_i32_i32_8vsx8vs_sme2_mopa kernel. | |
| 37 | -[[nodiscard]] std::unique_ptr<KernelWrapper<MatMulShape>> | |
| 38 | -create_matmul_i32_u8p4vsx4_u8p4vsx4_i32_i32_8vsx8vs_sme2_mopa(); | |
| 39 | - | |
| 40 | -/// Creates a wrapper for matmul_clamp_f32_u8p4vsx4_u8p4vsx4_i32_i32_f32_f32_8vsx8vs_sme2_mopa kernel. | |
| 41 | -[[nodiscard]] std::unique_ptr<KernelWrapper<MatMulShape>> | |
| 42 | -create_matmul_clamp_f32_u8p4vsx4_u8p4vsx4_i32_i32_f32_f32_8vsx8vs_sme2_mopa(); | |
| 43 | - | |
| 44 | -/// Creates a wrapper for matmul_clamp_f32_f32_f32p4vsx1b_1x32vs_sme2_mla kernel. | |
| 45 | -[[nodiscard]] std::unique_ptr<KernelWrapper<MatMulShape>> create_matmul_clamp_f32_f32_f32p4vsx1bf32_1x32vs_sme2_mla(); | |
| 46 | - | |
| 47 | -} // namespace kai::test |
added test/nextgen/operators/matmul/matmul/matmul_wrapper_registry.cpp +199 −0
| @@ -0,0 +1,199 @@ | ||
| 1 | +// | |
| 2 | +// SPDX-FileCopyrightText: Copyright 2025-2026 Arm Limited and/or its affiliates <open-source-office@arm.com> | |
| 3 | +// | |
| 4 | +// SPDX-License-Identifier: Apache-2.0 | |
| 5 | +// | |
| 6 | + | |
| 7 | +#include "test/nextgen/operators/matmul/matmul/matmul_wrapper_registry.hpp" | |
| 8 | + | |
| 9 | +#include <array> | |
| 10 | +#include <memory> | |
| 11 | + | |
| 12 | +#include "kai/ukernels/matmul/kai_matmul.h" | |
| 13 | +#include "kai/ukernels/matmul/matmul_clamp_f32_f32p_f32p/kai_matmul_clamp_f32_f32p2vlx1_f32p2vlx1biasf32_sme2_mopa.h" | |
| 14 | +#include "kai/ukernels/matmul/matmul_clamp_f32_qai8dxp_qsi4cxp/kai_matmul_clamp_f32_qai8dxp1vlx4_qsi4cxp4vlx4_1vlx4vl_sme_mopa.h" | |
| 15 | +#include "kai/ukernels/matmul/matmul_clamp_f32_qai8dxp_qsi4cxp/kai_matmul_clamp_f32_qai8dxp1vlx8_qsi4cxp4vlx8_1vlx4vl_sme2_mopa.h" | |
| 16 | +#include "kai/ukernels/matmul/matmul_clamp_f32_qai8dxp_qsi4cxp/kai_matmul_clamp_f32_qai8dxp1x4_qsi4cxp4vlx4_1x4vl_sme2_sdot.h" | |
| 17 | +#include "test/common/data_type.hpp" | |
| 18 | +#include "test/common/sme.hpp" | |
| 19 | +#include "test/nextgen/format/block2d_row_format.hpp" | |
| 20 | +#include "test/nextgen/format/plain_format.hpp" | |
| 21 | +#include "test/nextgen/functions/round.hpp" | |
| 22 | +#include "test/nextgen/harness/kernel_wrapper.hpp" | |
| 23 | +#include "test/nextgen/operators/matmul/matmul/matmul_dq_wrapper.hpp" | |
| 24 | +#include "test/nextgen/operators/matmul/matmul/matmul_fp_wrapper.hpp" | |
| 25 | +#include "test/nextgen/operators/matmul/matmul/matmul_interface.hpp" | |
| 26 | +#include "test/nextgen/operators/matmul/matmul/matmul_ukerapi_wrapper.hpp" | |
| 27 | +#include "test/nextgen/operators/matmul/matmul_slots.hpp" | |
| 28 | +#include "test/nextgen/quantization/asymm_linear_quantizer.hpp" | |
| 29 | +#include "test/nextgen/quantization/symm_linear_quantizer.hpp" | |
| 30 | + | |
| 31 | +namespace kai::test { | |
| 32 | + | |
| 33 | +std::unique_ptr<KernelWrapper<MatMulShape>> create_matmul_clamp_f32_qai8dxp1vlx8_qsi4cxp4vlx8_1vlx4vl_sme2_mopa() { | |
| 34 | + return std::make_unique<MatMulDqWrapper>( | |
| 35 | + "matmul_clamp_f32_qai8dxp1vlx8_qsi4cxp4vlx8_1vlx4vl_sme2_mopa", | |
| 36 | + MatMulDqInterface{ | |
| 37 | + kai_get_m_step_matmul_clamp_f32_qai8dxp1vlx8_qsi4cxp4vlx8_1vlx4vl_sme2_mopa, | |
| 38 | + kai_get_n_step_matmul_clamp_f32_qai8dxp1vlx8_qsi4cxp4vlx8_1vlx4vl_sme2_mopa, | |
| 39 | + kai_get_mr_matmul_clamp_f32_qai8dxp1vlx8_qsi4cxp4vlx8_1vlx4vl_sme2_mopa, | |
| 40 | + kai_get_nr_matmul_clamp_f32_qai8dxp1vlx8_qsi4cxp4vlx8_1vlx4vl_sme2_mopa, | |
| 41 | + kai_get_kr_matmul_clamp_f32_qai8dxp1vlx8_qsi4cxp4vlx8_1vlx4vl_sme2_mopa, | |
| 42 | + kai_get_sr_matmul_clamp_f32_qai8dxp1vlx8_qsi4cxp4vlx8_1vlx4vl_sme2_mopa, | |
| 43 | + kai_get_lhs_packed_offset_matmul_clamp_f32_qai8dxp1vlx8_qsi4cxp4vlx8_1vlx4vl_sme2_mopa, | |
| 44 | + kai_get_rhs_packed_offset_matmul_clamp_f32_qai8dxp1vlx8_qsi4cxp4vlx8_1vlx4vl_sme2_mopa, | |
| 45 | + kai_get_dst_offset_matmul_clamp_f32_qai8dxp1vlx8_qsi4cxp4vlx8_1vlx4vl_sme2_mopa, | |
| 46 | + kai_get_dst_size_matmul_clamp_f32_qai8dxp1vlx8_qsi4cxp4vlx8_1vlx4vl_sme2_mopa, | |
| 47 | + kai_run_matmul_clamp_f32_qai8dxp1vlx8_qsi4cxp4vlx8_1vlx4vl_sme2_mopa, | |
| 48 | + }, | |
| 49 | + std::make_unique<AsymmLinearQuantizer>( | |
| 50 | + DataType::I8, DataType::FP32, DataType::I32, RoundMode::TIE_AWAY, RoundMode::CURRENT, 1, 0), | |
| 51 | + std::make_unique<SymmLinearQuantizer>(DataType::U4, DataType::FP32, RoundMode::CURRENT, 1, 0), | |
| 52 | + make_poly<Block2dRowFormat>( | |
| 53 | + 1 * get_sme_vector_length<float>(), 4, 32, true, DataType::I8, std::array<DataType, 0>{}, | |
| 54 | + std::array{DataType::I32, DataType::FP32}), | |
| 55 | + make_poly<Block2dRowFormat>( | |
| 56 | + 4 * get_sme_vector_length<float>(), 4, 32, false, DataType::I4, std::array<DataType, 0>{}, | |
| 57 | + std::array{DataType::I32, DataType::FP32, DataType::FP32}), | |
| 58 | + make_poly<PlainFormat>(DataType::FP32)); | |
| 59 | +} | |
| 60 | + | |
| 61 | +std::unique_ptr<KernelWrapper<MatMulShape>> create_matmul_clamp_f32_qai8dxp1vlx4_qsi4cxp4vlx4_1vlx4vl_sme_mopa() { | |
| 62 | + return std::make_unique<MatMulDqWrapper>( | |
| 63 | + "matmul_clamp_f32_qai8dxp1vlx4_qsi4cxp4vlx4_1vlx4vl_sme_mopa", | |
| 64 | + MatMulDqInterface{ | |
| 65 | + kai_get_m_step_matmul_clamp_f32_qai8dxp1vlx4_qsi4cxp4vlx4_1vlx4vl_sme_mopa, | |
| 66 | + kai_get_n_step_matmul_clamp_f32_qai8dxp1vlx4_qsi4cxp4vlx4_1vlx4vl_sme_mopa, | |
| 67 | + kai_get_mr_matmul_clamp_f32_qai8dxp1vlx4_qsi4cxp4vlx4_1vlx4vl_sme_mopa, | |
| 68 | + kai_get_nr_matmul_clamp_f32_qai8dxp1vlx4_qsi4cxp4vlx4_1vlx4vl_sme_mopa, | |
| 69 | + kai_get_kr_matmul_clamp_f32_qai8dxp1vlx4_qsi4cxp4vlx4_1vlx4vl_sme_mopa, | |
| 70 | + kai_get_sr_matmul_clamp_f32_qai8dxp1vlx4_qsi4cxp4vlx4_1vlx4vl_sme_mopa, | |
| 71 | + kai_get_lhs_packed_offset_matmul_clamp_f32_qai8dxp1vlx4_qsi4cxp4vlx4_1vlx4vl_sme_mopa, | |
| 72 | + kai_get_rhs_packed_offset_matmul_clamp_f32_qai8dxp1vlx4_qsi4cxp4vlx4_1vlx4vl_sme_mopa, | |
| 73 | + kai_get_dst_offset_matmul_clamp_f32_qai8dxp1vlx4_qsi4cxp4vlx4_1vlx4vl_sme_mopa, | |
| 74 | + kai_get_dst_size_matmul_clamp_f32_qai8dxp1vlx4_qsi4cxp4vlx4_1vlx4vl_sme_mopa, | |
| 75 | + kai_run_matmul_clamp_f32_qai8dxp1vlx4_qsi4cxp4vlx4_1vlx4vl_sme_mopa, | |
| 76 | + }, | |
| 77 | + std::make_unique<AsymmLinearQuantizer>( | |
| 78 | + DataType::I8, DataType::FP32, DataType::I32, RoundMode::TIE_AWAY, RoundMode::CURRENT, 1, 0), | |
| 79 | + std::make_unique<SymmLinearQuantizer>(DataType::U4, DataType::FP32, RoundMode::CURRENT, 1, 0), | |
| 80 | + make_poly<Block2dRowFormat>( | |
| 81 | + 1 * get_sme_vector_length<float>(), 4, 32, true, DataType::I8, std::array<DataType, 0>{}, | |
| 82 | + std::array{DataType::I32, DataType::FP32}), | |
| 83 | + make_poly<Block2dRowFormat>( | |
| 84 | + 4 * get_sme_vector_length<float>(), 4, 32, false, DataType::I4, std::array<DataType, 0>{}, | |
| 85 | + std::array{DataType::I32, DataType::FP32, DataType::FP32}), | |
| 86 | + make_poly<PlainFormat>(DataType::FP32)); | |
| 87 | +} | |
| 88 | + | |
| 89 | +std::unique_ptr<KernelWrapper<MatMulShape>> create_matmul_clamp_f32_qai8dxp1x4_qsi4cxp4vlx4_1x4vl_sme2_sdot() { | |
| 90 | + return std::make_unique<MatMulDqWrapper>( | |
| 91 | + "matmul_clamp_f32_qai8dxp1x4_qsi4cxp4vlx4_1x4vl_sme2_sdot", | |
| 92 | + MatMulDqInterface{ | |
| 93 | + kai_get_m_step_matmul_clamp_f32_qai8dxp1x4_qsi4cxp4vlx4_1x4vl_sme2_sdot, | |
| 94 | + kai_get_n_step_matmul_clamp_f32_qai8dxp1x4_qsi4cxp4vlx4_1x4vl_sme2_sdot, | |
| 95 | + kai_get_mr_matmul_clamp_f32_qai8dxp1x4_qsi4cxp4vlx4_1x4vl_sme2_sdot, | |
| 96 | + kai_get_nr_matmul_clamp_f32_qai8dxp1x4_qsi4cxp4vlx4_1x4vl_sme2_sdot, | |
| 97 | + kai_get_kr_matmul_clamp_f32_qai8dxp1x4_qsi4cxp4vlx4_1x4vl_sme2_sdot, | |
| 98 | + kai_get_sr_matmul_clamp_f32_qai8dxp1x4_qsi4cxp4vlx4_1x4vl_sme2_sdot, | |
| 99 | + kai_get_lhs_packed_offset_matmul_clamp_f32_qai8dxp1x4_qsi4cxp4vlx4_1x4vl_sme2_sdot, | |
| 100 | + kai_get_rhs_packed_offset_matmul_clamp_f32_qai8dxp1x4_qsi4cxp4vlx4_1x4vl_sme2_sdot, | |
| 101 | + kai_get_dst_offset_matmul_clamp_f32_qai8dxp1x4_qsi4cxp4vlx4_1x4vl_sme2_sdot, | |
| 102 | + kai_get_dst_size_matmul_clamp_f32_qai8dxp1x4_qsi4cxp4vlx4_1x4vl_sme2_sdot, | |
| 103 | + kai_run_matmul_clamp_f32_qai8dxp1x4_qsi4cxp4vlx4_1x4vl_sme2_sdot, | |
| 104 | + }, | |
| 105 | + std::make_unique<AsymmLinearQuantizer>( | |
| 106 | + DataType::I8, DataType::FP32, DataType::I32, RoundMode::TIE_AWAY, RoundMode::CURRENT, 1, 0), | |
| 107 | + std::make_unique<SymmLinearQuantizer>(DataType::U4, DataType::FP32, RoundMode::CURRENT, 1, 0), | |
| 108 | + make_poly<Block2dRowFormat>( | |
| 109 | + 1, 4, 32, true, DataType::I8, std::array<DataType, 0>{}, std::array{DataType::I32, DataType::FP32}), | |
| 110 | + make_poly<Block2dRowFormat>( | |
| 111 | + 4 * get_sme_vector_length<float>(), 4, 32, false, DataType::I4, std::array<DataType, 0>{}, | |
| 112 | + std::array{DataType::I32, DataType::FP32, DataType::FP32}), | |
| 113 | + make_poly<PlainFormat>(DataType::FP32)); | |
| 114 | +} | |
| 115 | + | |
| 116 | +std::unique_ptr<KernelWrapper<MatMulShape>> create_matmul_clamp_f32_f32p2vlx1_f32p2vlx1biasf32_sme2_mopa() { | |
| 117 | + return std::make_unique<MatMulFpWrapper>( | |
| 118 | + "matmul_clamp_f32_f32p2vlx1_f32p2vlx1biasf32_sme2_mopa", | |
| 119 | + MatMulFpInterface{ | |
| 120 | + kai_get_m_step_matmul_clamp_f32_f32p2vlx1_f32p2vlx1biasf32_sme2_mopa, | |
| 121 | + kai_get_n_step_matmul_clamp_f32_f32p2vlx1_f32p2vlx1biasf32_sme2_mopa, | |
| 122 | + kai_get_mr_matmul_clamp_f32_f32p2vlx1_f32p2vlx1biasf32_sme2_mopa, | |
| 123 | + kai_get_nr_matmul_clamp_f32_f32p2vlx1_f32p2vlx1biasf32_sme2_mopa, | |
| 124 | + kai_get_kr_matmul_clamp_f32_f32p2vlx1_f32p2vlx1biasf32_sme2_mopa, | |
| 125 | + kai_get_sr_matmul_clamp_f32_f32p2vlx1_f32p2vlx1biasf32_sme2_mopa, | |
| 126 | + kai_get_lhs_packed_offset_matmul_clamp_f32_f32p2vlx1_f32p2vlx1biasf32_sme2_mopa, | |
| 127 | + kai_get_rhs_packed_offset_matmul_clamp_f32_f32p2vlx1_f32p2vlx1biasf32_sme2_mopa, | |
| 128 | + kai_get_dst_offset_matmul_clamp_f32_f32p2vlx1_f32p2vlx1biasf32_sme2_mopa, | |
| 129 | + kai_get_dst_size_matmul_clamp_f32_f32p2vlx1_f32p2vlx1biasf32_sme2_mopa, | |
| 130 | + kai_run_matmul_clamp_f32_f32p2vlx1_f32p2vlx1biasf32_sme2_mopa, | |
| 131 | + }, | |
| 132 | + make_poly<Block2dRowFormat>( | |
| 133 | + 1 * get_sme_vector_length<float>(), 1, 1, false, DataType::FP32, std::array<DataType, 0>{}, | |
| 134 | + std::array<DataType, 0>{}), | |
| 135 | + make_poly<Block2dRowFormat>( | |
| 136 | + 1 * get_sme_vector_length<float>(), 1, 1, false, DataType::FP32, std::array{DataType::FP32}, | |
| 137 | + std::array<DataType, 0>{}), | |
| 138 | + make_poly<PlainFormat>(DataType::FP32)); | |
| 139 | +} | |
| 140 | + | |
| 141 | +std::unique_ptr<KernelWrapper<MatMulShape>> create_matmul_clamp_f32_f32p4vsx1_f32p4vsx1b_8vsx8vs_elastic_sme2_mopa() { | |
| 142 | + return std::make_unique<MatMulUkerApiWrapper>( | |
| 143 | + "matmul_clamp_f32_f32p4vsx1_f32p4vsx1b_8vsx8vs_elastic_sme2_mopa", | |
| 144 | + kai_matmul_clamp_f32_f32p4vsx1_f32p4vsx1bf32_8vsx8vs_sme2_mopa(), MatMulSlot::LHS_PACKED, | |
| 145 | + make_poly<Block2dRowFormat>( | |
| 146 | + 4 * get_sme_vector_scale(), 1, 1, false, DataType::FP32, std::array<DataType, 0>{}, | |
| 147 | + std::array<DataType, 0>{}), | |
| 148 | + make_poly<Block2dRowFormat>( | |
| 149 | + 4 * get_sme_vector_scale(), 1, 1, false, DataType::FP32, std::array{DataType::FP32}, | |
| 150 | + std::array<DataType, 0>{}), | |
| 151 | + make_poly<PlainFormat>(DataType::FP32), DataType::FP32, MatMulUkerClampConfig::optional(DataType::FP32), | |
| 152 | + MatMulUkerApiBiasDeliveryStage::PACK_RHS); | |
| 153 | +} | |
| 154 | + | |
| 155 | +std::unique_ptr<KernelWrapper<MatMulShape>> create_matmul_i32_u8p4vsx4_u8p4vsx4_i32_i32_8vsx8vs_sme2_mopa() { | |
| 156 | + return std::make_unique<MatMulUkerApiWrapper>( | |
| 157 | + "matmul_i32_u8p4vsx4_u8p4vsx4_i32_i32_8vsx8vs_sme2_mopa", | |
| 158 | + kai_matmul_i32_u8p4vsx4_u8p4vsx4_i32_i32_8vsx8vs_sme2_mopa(), MatMulSlot::LHS_PACKED, | |
| 159 | + make_poly<Block2dRowFormat>( | |
| 160 | + 4 * get_sme_vector_scale(), 4, 4, false, DataType::U8, std::array<DataType, 0>{}, | |
| 161 | + std::array<DataType, 0>{}), | |
| 162 | + make_poly<Block2dRowFormat>( | |
| 163 | + 4 * get_sme_vector_scale(), 4, 4, false, DataType::U8, std::array<DataType, 0>{}, | |
| 164 | + std::array<DataType, 0>{}), | |
| 165 | + make_poly<PlainFormat>(DataType::I32), DataType::I32, MatMulUkerClampConfig::unsupported(), | |
| 166 | + MatMulUkerApiBiasDeliveryStage::MATMUL); | |
| 167 | +} | |
| 168 | + | |
| 169 | +std::unique_ptr<KernelWrapper<MatMulShape>> | |
| 170 | +create_matmul_clamp_f32_u8p4vsx4_u8p4vsx4_i32_i32_f32_f32_8vsx8vs_sme2_mopa() { | |
| 171 | + return std::make_unique<MatMulUkerApiWrapper>( | |
| 172 | + "matmul_clamp_f32_u8p4vsx4_u8p4vsx4_i32_i32_f32_f32_8vsx8vs_sme2_mopa", | |
| 173 | + kai_matmul_clamp_f32_u8p4vsx4_u8p4vsx4_i32_i32_f32_f32_8vsx8vs_sme2_mopa(), MatMulSlot::LHS_PACKED, | |
| 174 | + make_poly<Block2dRowFormat>( | |
| 175 | + 4 * get_sme_vector_scale(), 4, 4, false, DataType::U8, std::array<DataType, 0>{}, | |
| 176 | + std::array<DataType, 0>{}), | |
| 177 | + make_poly<Block2dRowFormat>( | |
| 178 | + 4 * get_sme_vector_scale(), 4, 4, false, DataType::U8, std::array<DataType, 0>{}, | |
| 179 | + std::array<DataType, 0>{}), | |
| 180 | + make_poly<PlainFormat>(DataType::FP32), DataType::I32, MatMulUkerClampConfig::optional(DataType::FP32), | |
| 181 | + MatMulUkerApiBiasDeliveryStage::MATMUL, | |
| 182 | + MatMulUkerOutputStageConfig{ | |
| 183 | + MatMulUkerStageParameterLayout::GLOBAL, | |
| 184 | + MatMulUkerStageParameterLayout::PER_N, | |
| 185 | + }); | |
| 186 | +} | |
| 187 | + | |
| 188 | +std::unique_ptr<KernelWrapper<MatMulShape>> create_matmul_clamp_f32_f32_f32p4vsx1bf32_1x32vs_sme2_mla() { | |
| 189 | + return std::make_unique<MatMulUkerApiWrapper>( | |
| 190 | + "matmul_clamp_f32_f32_f32p4vsx1bf32_1x32vs_sme2_mla", kai_matmul_clamp_f32_f32_f32p4vsx1bf32_1x32vs_sme2_mla(), | |
| 191 | + MatMulSlot::LHS_DATA, make_poly<PlainFormat>(DataType::FP32), | |
| 192 | + make_poly<Block2dRowFormat>( | |
| 193 | + 4 * get_sme_vector_scale(), 1, 1, false, DataType::FP32, std::array{DataType::FP32}, | |
| 194 | + std::array<DataType, 0>{}), | |
| 195 | + make_poly<PlainFormat>(DataType::FP32), DataType::FP32, MatMulUkerClampConfig::optional(DataType::FP32), | |
| 196 | + MatMulUkerApiBiasDeliveryStage::PACK_RHS); | |
| 197 | +} | |
| 198 | + | |
| 199 | +} // namespace kai::test |
added test/nextgen/operators/matmul/matmul/matmul_wrapper_registry.hpp +47 −0
| @@ -0,0 +1,47 @@ | ||
| 1 | +// | |
| 2 | +// SPDX-FileCopyrightText: Copyright 2025-2026 Arm Limited and/or its affiliates <open-source-office@arm.com> | |
| 3 | +// | |
| 4 | +// SPDX-License-Identifier: Apache-2.0 | |
| 5 | +// | |
| 6 | + | |
| 7 | +#pragma once | |
| 8 | + | |
| 9 | +#include <memory> | |
| 10 | + | |
| 11 | +#include "test/nextgen/harness/kernel_wrapper.hpp" | |
| 12 | +#include "test/nextgen/operators/matmul/matmul_dims.hpp" | |
| 13 | + | |
| 14 | +namespace kai::test { | |
| 15 | + | |
| 16 | +/// Creates a wrapper for matmul_clamp_f32_qai8dxp1vlx8_qsi4cxp4vlx8_1vlx4vl_sme2_mopa kernel. | |
| 17 | +[[nodiscard]] std::unique_ptr<KernelWrapper<MatMulShape>> | |
| 18 | +create_matmul_clamp_f32_qai8dxp1vlx8_qsi4cxp4vlx8_1vlx4vl_sme2_mopa(); | |
| 19 | + | |
| 20 | +/// Creates a wrapper for matmul_clamp_f32_qai8dxp1vlx4_qsi4cxp4vlx4_1vlx4vl_sme_mopa kernel. | |
| 21 | +[[nodiscard]] std::unique_ptr<KernelWrapper<MatMulShape>> | |
| 22 | +create_matmul_clamp_f32_qai8dxp1vlx4_qsi4cxp4vlx4_1vlx4vl_sme_mopa(); | |
| 23 | + | |
| 24 | +/// Creates a wrapper for matmul_clamp_f32_qai8dxp1x4_qsi4cxp4vlx4_1x4vl_sme2_sdot kernel. | |
| 25 | +[[nodiscard]] std::unique_ptr<KernelWrapper<MatMulShape>> | |
| 26 | +create_matmul_clamp_f32_qai8dxp1x4_qsi4cxp4vlx4_1x4vl_sme2_sdot(); | |
| 27 | + | |
| 28 | +/// Creates a wrapper for matmul_clamp_f32_f32p2vlx1_f32p2vlx1biasf32_sme2_mopa kernel. | |
| 29 | +[[nodiscard]] std::unique_ptr<KernelWrapper<MatMulShape>> | |
| 30 | +create_matmul_clamp_f32_f32p2vlx1_f32p2vlx1biasf32_sme2_mopa(); | |
| 31 | + | |
| 32 | +/// Creates a wrapper for matmul_clamp_f32_f32p4vsx1_f32p4vsx1b_8vsx8vs_elastic_sme2_mopa kernel. | |
| 33 | +[[nodiscard]] std::unique_ptr<KernelWrapper<MatMulShape>> | |
| 34 | +create_matmul_clamp_f32_f32p4vsx1_f32p4vsx1b_8vsx8vs_elastic_sme2_mopa(); | |
| 35 | + | |
| 36 | +/// Creates a wrapper for matmul_i32_u8p4vsx4_u8p4vsx4_i32_i32_8vsx8vs_sme2_mopa kernel. | |
| 37 | +[[nodiscard]] std::unique_ptr<KernelWrapper<MatMulShape>> | |
| 38 | +create_matmul_i32_u8p4vsx4_u8p4vsx4_i32_i32_8vsx8vs_sme2_mopa(); | |
| 39 | + | |
| 40 | +/// Creates a wrapper for matmul_clamp_f32_u8p4vsx4_u8p4vsx4_i32_i32_f32_f32_8vsx8vs_sme2_mopa kernel. | |
| 41 | +[[nodiscard]] std::unique_ptr<KernelWrapper<MatMulShape>> | |
| 42 | +create_matmul_clamp_f32_u8p4vsx4_u8p4vsx4_i32_i32_f32_f32_8vsx8vs_sme2_mopa(); | |
| 43 | + | |
| 44 | +/// Creates a wrapper for matmul_clamp_f32_f32_f32p4vsx1b_1x32vs_sme2_mla kernel. | |
| 45 | +[[nodiscard]] std::unique_ptr<KernelWrapper<MatMulShape>> create_matmul_clamp_f32_f32_f32p4vsx1bf32_1x32vs_sme2_mla(); | |
| 46 | + | |
| 47 | +} // namespace kai::test |
modified test/nextgen/operators/matmul/matmul_operator.cpp +3 −3
| @@ -14,10 +14,10 @@ | ||
| 14 | 14 | #include "test/common/data_type.hpp" |
| 15 | 15 | #include "test/common/span.hpp" |
| 16 | 16 | #include "test/nextgen/functions/round.hpp" |
| 17 | -#include "test/nextgen/operators/matmul/matmul/matmul_wrapper.hpp" | |
| 17 | +#include "test/nextgen/operators/matmul/matmul/matmul_wrapper_registry.hpp" | |
| 18 | 18 | #include "test/nextgen/operators/matmul/matmul_bias_mode.hpp" |
| 19 | -#include "test/nextgen/operators/matmul/pack_lhs/matmul_pack_lhs_wrapper.hpp" | |
| 20 | -#include "test/nextgen/operators/matmul/pack_rhs/matmul_pack_rhs_wrapper.hpp" | |
| 19 | +#include "test/nextgen/operators/matmul/pack_lhs/matmul_pack_lhs_wrapper_registry.hpp" | |
| 20 | +#include "test/nextgen/operators/matmul/pack_rhs/matmul_pack_rhs_wrapper_registry.hpp" | |
| 21 | 21 | #include "test/nextgen/quantization/asymm_linear_quantizer.hpp" |
| 22 | 22 | #include "test/nextgen/quantization/symm_linear_quantizer.hpp" |
| 23 | 23 |
deleted test/nextgen/operators/matmul/pack_lhs/matmul_pack_lhs_wrapper.cpp +0 −180
| @@ -1,180 +0,0 @@ | ||
| 1 | -// | |
| 2 | -// SPDX-FileCopyrightText: Copyright 2025-2026 Arm Limited and/or its affiliates <open-source-office@arm.com> | |
| 3 | -// | |
| 4 | -// SPDX-License-Identifier: Apache-2.0 | |
| 5 | -// | |
| 6 | - | |
| 7 | -#include "test/nextgen/operators/matmul/pack_lhs/matmul_pack_lhs_wrapper.hpp" | |
| 8 | - | |
| 9 | -#include <array> | |
| 10 | -#include <cstdint> | |
| 11 | -#include <memory> | |
| 12 | -#include <string> | |
| 13 | -#include <string_view> | |
| 14 | - | |
| 15 | -#include "kai/ukernels/matmul/kai_matmul_pack_lhs.h" | |
| 16 | -#include "kai/ukernels/matmul/matmul_clamp_f32_f32p_f32p/kai_matmul_clamp_f32_f32p2vlx1_f32p2vlx1biasf32_sme2_mopa.h" | |
| 17 | -#include "kai/ukernels/matmul/matmul_clamp_f32_qai8dxp_qsi4cxp/kai_matmul_clamp_f32_qai8dxp1vlx4_qsi4cxp4vlx4_1vlx4vl_sme_mopa.h" | |
| 18 | -#include "kai/ukernels/matmul/matmul_clamp_f32_qai8dxp_qsi4cxp/kai_matmul_clamp_f32_qai8dxp1vlx8_qsi4cxp4vlx8_1vlx4vl_sme2_mopa.h" | |
| 19 | -#include "kai/ukernels/matmul/matmul_clamp_f32_qai8dxp_qsi4cxp/kai_matmul_clamp_f32_qai8dxp1x4_qsi4cxp4vlx4_1x4vl_sme2_sdot.h" | |
| 20 | -#include "kai/ukernels/matmul/pack/kai_lhs_pack_f32p2vlx1_f32_sme.h" | |
| 21 | -#include "kai/ukernels/matmul/pack/kai_lhs_quant_pack_qai8dxp_f32.h" | |
| 22 | -#include "test/common/data_type.hpp" | |
| 23 | -#include "test/common/matrix_portion.hpp" | |
| 24 | -#include "test/common/sme.hpp" | |
| 25 | -#include "test/nextgen/common/poly.hpp" | |
| 26 | -#include "test/nextgen/format/block2d_row_format.hpp" | |
| 27 | -#include "test/nextgen/format/plain_format.hpp" | |
| 28 | -#include "test/nextgen/harness/kernel_wrapper.hpp" | |
| 29 | -#include "test/nextgen/operators/matmul/pack_lhs/matmul_pack_lhs_dq_wrapper.hpp" | |
| 30 | -#include "test/nextgen/operators/matmul/pack_lhs/matmul_pack_lhs_fp_wrapper.hpp" | |
| 31 | -#include "test/nextgen/operators/matmul/pack_lhs/matmul_pack_lhs_interface.hpp" | |
| 32 | -#include "test/nextgen/operators/matmul/pack_lhs/matmul_pack_lhs_ukerapi_wrapper.hpp" | |
| 33 | - | |
| 34 | -namespace kai::test { | |
| 35 | - | |
| 36 | -namespace { | |
| 37 | - | |
| 38 | -std::unique_ptr<KernelWrapper<MatShape>> create_matmul_lhs_quant_pack_qai8dxp_f32( | |
| 39 | - std::string_view block_name, size_t block_height, size_t block_width) { | |
| 40 | - return std::make_unique<MatMulPackLhsDqWrapper>( | |
| 41 | - "matmul_lhs_quant_pack_qai8dxp" + std::string(block_name) + "_f32", | |
| 42 | - MatMulPackLhsDqInterface{ | |
| 43 | - kai_get_m_step_lhs_quant_pack_qai8dxp_f32, | |
| 44 | - kai_get_lhs_offset_lhs_quant_pack_qai8dxp_f32, | |
| 45 | - kai_get_lhs_packed_offset_lhs_quant_pack_qai8dxp_f32, | |
| 46 | - kai_get_lhs_packed_size_lhs_quant_pack_qai8dxp_f32, | |
| 47 | - kai_run_lhs_quant_pack_qai8dxp_f32, | |
| 48 | - }, | |
| 49 | - make_poly<PlainFormat>(DataType::FP32), | |
| 50 | - make_poly<Block2dRowFormat>( | |
| 51 | - block_height, block_width, 32, true, DataType::I8, std::array<DataType, 0>{}, | |
| 52 | - std::array{DataType::I32, DataType::FP32})); | |
| 53 | -} | |
| 54 | - | |
| 55 | -bool portion_non_empty( | |
| 56 | - size_t full_height, size_t full_width, size_t scheduler_block_height, size_t scheduler_block_width, | |
| 57 | - const MatrixPortion& portion) { | |
| 58 | - const Rect rect = portion.compute_portion(full_height, full_width, scheduler_block_height, scheduler_block_width); | |
| 59 | - return rect.height() > 0 && rect.width() > 0; | |
| 60 | -} | |
| 61 | - | |
| 62 | -bool is_shape_suitable_lhs_uker_api( | |
| 63 | - size_t shape_m, size_t shape_k, const MatrixPortion& portion, const kai_matmul_pack_lhs_uker_api& api) { | |
| 64 | - if (shape_m == 0 || shape_k == 0) { | |
| 65 | - return false; | |
| 66 | - } | |
| 67 | - | |
| 68 | - const kai_matmul_pack_lhs_uker_config config = {}; | |
| 69 | - | |
| 70 | - const struct kai_matmul_pack_lhs_uker_dim_args step = api.get_step(&config); | |
| 71 | - | |
| 72 | - const size_t block_m = (step.m == 0) ? shape_m : step.m; | |
| 73 | - const size_t block_k = (step.k == 0) ? shape_k : step.k; | |
| 74 | - | |
| 75 | - return portion_non_empty(shape_m, shape_k, block_m, block_k, portion); | |
| 76 | -} | |
| 77 | - | |
| 78 | -} // namespace | |
| 79 | - | |
| 80 | -std::unique_ptr<KernelWrapper<MatShape>> create_matmul_pack_lhs_mxk_x32p4vsx1_x32_sme() { | |
| 81 | - return std::make_unique<MatMulPackLhsUkerApiWrapper>( | |
| 82 | - "create_matmul_pack_lhs_mxk_x32p4vsx1_x32_sme", kai_matmul_pack_lhs_mxk_x32p4vsx1_x32_sme(), | |
| 83 | - make_poly<PlainFormat>(DataType::FP32), | |
| 84 | - make_poly<Block2dRowFormat>( | |
| 85 | - 4 * get_sme_vector_scale(), 1, 1, false, DataType::FP32, std::array<DataType, 0>{}, | |
| 86 | - std::array<DataType, 0>{})); | |
| 87 | -} | |
| 88 | - | |
| 89 | -std::unique_ptr<KernelWrapper<MatShape>> create_matmul_pack_lhs_mxk_x8p4vsx4_x8_sme() { | |
| 90 | - return std::make_unique<MatMulPackLhsUkerApiWrapper>( | |
| 91 | - "matmul_pack_lhs_mxk_x8p4vsx4_x8_sme", kai_matmul_pack_lhs_mxk_x8p4vsx4_x8_sme(), | |
| 92 | - make_poly<PlainFormat>(DataType::U8), | |
| 93 | - make_poly<Block2dRowFormat>( | |
| 94 | - 4 * get_sme_vector_scale(), 4, 4, false, DataType::U8, std::array<DataType, 0>{}, | |
| 95 | - std::array<DataType, 0>{})); | |
| 96 | -} | |
| 97 | - | |
| 98 | -std::unique_ptr<KernelWrapper<MatShape>> create_matmul_lhs_quant_pack_qai8dxp1vlx4_f32() { | |
| 99 | - return create_matmul_lhs_quant_pack_qai8dxp_f32("1vlx4", 1 * get_sme_vector_length<float>(), 4); | |
| 100 | -} | |
| 101 | - | |
| 102 | -std::unique_ptr<KernelWrapper<MatShape>> create_matmul_lhs_quant_pack_qai8dxp1x4_f32() { | |
| 103 | - return create_matmul_lhs_quant_pack_qai8dxp_f32("1x4", 1, 4); | |
| 104 | -} | |
| 105 | - | |
| 106 | -std::unique_ptr<KernelWrapper<MatShape>> create_matmul_lhs_pack_f32p2vlx1_f32_sme() { | |
| 107 | - return std::make_unique<MatMulPackLhsFpWrapper>( | |
| 108 | - "create_matmul_lhs_pack_f32p2vlx1_f32_sme", | |
| 109 | - MatMulPackLhsFpInterface{ | |
| 110 | - kai_get_m_step_lhs_pack_f32p2vlx1_f32_sme, | |
| 111 | - kai_get_lhs_offset_lhs_pack_f32p2vlx1_f32_sme, | |
| 112 | - kai_get_lhs_packed_offset_lhs_pack_f32p2vlx1_f32_sme, | |
| 113 | - kai_get_lhs_packed_size_lhs_pack_f32p2vlx1_f32_sme, | |
| 114 | - kai_run_lhs_pack_f32p2vlx1_f32_sme, | |
| 115 | - }, | |
| 116 | - make_poly<PlainFormat>(DataType::FP32), | |
| 117 | - make_poly<Block2dRowFormat>( | |
| 118 | - 2 * get_sme_vector_length<float>(), 1, 1, false, DataType::FP32, std::array<DataType, 0>{}, | |
| 119 | - std::array<DataType, 0>{})); | |
| 120 | -} | |
| 121 | - | |
| 122 | -bool is_shape_suitable_lhs_x32p4vsx1_x32_sme( | |
| 123 | - size_t shape_m, [[maybe_unused]] size_t shape_n, size_t shape_k, const MatrixPortion& portion) { | |
| 124 | - return is_shape_suitable_lhs_uker_api(shape_m, shape_k, portion, kai_matmul_pack_lhs_mxk_x32p4vsx1_x32_sme()); | |
| 125 | -} | |
| 126 | - | |
| 127 | -bool is_shape_suitable_lhs_x8p4vsx4_x8_sme( | |
| 128 | - size_t shape_m, [[maybe_unused]] size_t shape_n, size_t shape_k, const MatrixPortion& portion) { | |
| 129 | - return is_shape_suitable_lhs_uker_api(shape_m, shape_k, portion, kai_matmul_pack_lhs_mxk_x8p4vsx4_x8_sme()); | |
| 130 | -} | |
| 131 | - | |
| 132 | -bool is_shape_suitable_lhs_qai8dxp1vlx8_qsi4cxp4vlx8_1vlx4vl_sme2_mopa( | |
| 133 | - size_t shape_m, [[maybe_unused]] size_t shape_n, size_t shape_k, const MatrixPortion& portion) { | |
| 134 | - if (shape_m == 0 || shape_k == 0) { | |
| 135 | - return false; | |
| 136 | - } | |
| 137 | - | |
| 138 | - const size_t mr = kai_get_mr_matmul_clamp_f32_qai8dxp1vlx8_qsi4cxp4vlx8_1vlx4vl_sme2_mopa(); | |
| 139 | - const size_t lhs_m_step = kai_get_m_step_lhs_quant_pack_qai8dxp_f32(mr); | |
| 140 | - | |
| 141 | - return portion_non_empty(shape_m, shape_k, lhs_m_step, shape_k, portion); | |
| 142 | -} | |
| 143 | - | |
| 144 | -bool is_shape_suitable_lhs_qai8dxp1vlx4_qsi4cxp4vlx4_1vlx4vl_sme_mopa( | |
| 145 | - size_t shape_m, [[maybe_unused]] size_t shape_n, size_t shape_k, const MatrixPortion& portion) { | |
| 146 | - if (shape_m == 0 || shape_k == 0) { | |
| 147 | - return false; | |
| 148 | - } | |
| 149 | - | |
| 150 | - const size_t mr = kai_get_mr_matmul_clamp_f32_qai8dxp1vlx4_qsi4cxp4vlx4_1vlx4vl_sme_mopa(); | |
| 151 | - const size_t lhs_m_step = kai_get_m_step_lhs_quant_pack_qai8dxp_f32(mr); | |
| 152 | - | |
| 153 | - return portion_non_empty(shape_m, shape_k, lhs_m_step, shape_k, portion); | |
| 154 | -} | |
| 155 | - | |
| 156 | -bool is_shape_suitable_lhs_qai8dxp1x4_qsi4cxp4vlx4_1x4vl_sme2_sdot( | |
| 157 | - size_t shape_m, [[maybe_unused]] size_t shape_n, size_t shape_k, const MatrixPortion& portion) { | |
| 158 | - if (shape_m == 0 || shape_k == 0) { | |
| 159 | - return false; | |
| 160 | - } | |
| 161 | - | |
| 162 | - const size_t mr = kai_get_mr_matmul_clamp_f32_qai8dxp1x4_qsi4cxp4vlx4_1x4vl_sme2_sdot(); | |
| 163 | - const size_t lhs_m_step = kai_get_m_step_lhs_quant_pack_qai8dxp_f32(mr); | |
| 164 | - | |
| 165 | - return portion_non_empty(shape_m, shape_k, lhs_m_step, shape_k, portion); | |
| 166 | -} | |
| 167 | - | |
| 168 | -bool is_shape_suitable_lhs_f32p2vlx1_f32p2vlx1biasf32_sme2_mopa( | |
| 169 | - size_t shape_m, [[maybe_unused]] size_t shape_n, size_t shape_k, const MatrixPortion& portion) { | |
| 170 | - if (shape_m == 0 || shape_k == 0) { | |
| 171 | - return false; | |
| 172 | - } | |
| 173 | - | |
| 174 | - const size_t mr = kai_get_mr_matmul_clamp_f32_f32p2vlx1_f32p2vlx1biasf32_sme2_mopa(); | |
| 175 | - const size_t lhs_m_step = kai_get_m_step_lhs_pack_f32p2vlx1_f32_sme(mr); | |
| 176 | - | |
| 177 | - return portion_non_empty(shape_m, shape_k, lhs_m_step, shape_k, portion); | |
| 178 | -} | |
| 179 | - | |
| 180 | -} // namespace kai::test |
deleted test/nextgen/operators/matmul/pack_lhs/matmul_pack_lhs_wrapper.hpp +0 −56
| @@ -1,56 +0,0 @@ | ||
| 1 | -// | |
| 2 | -// SPDX-FileCopyrightText: Copyright 2025-2026 Arm Limited and/or its affiliates <open-source-office@arm.com> | |
| 3 | -// | |
| 4 | -// SPDX-License-Identifier: Apache-2.0 | |
| 5 | -// | |
| 6 | - | |
| 7 | -#pragma once | |
| 8 | - | |
| 9 | -#include <memory> | |
| 10 | - | |
| 11 | -#include "test/common/matrix_portion.hpp" | |
| 12 | -#include "test/nextgen/harness/kernel_wrapper.hpp" | |
| 13 | -#include "test/nextgen/operators/matmul/matmul_dims.hpp" | |
| 14 | - | |
| 15 | -namespace kai::test { | |
| 16 | - | |
| 17 | -/// Creates a wrapper for kai_lhs_quant_pack_qai8dxp_f32 micro-kernel. | |
| 18 | -[[nodiscard]] std::unique_ptr<KernelWrapper<MatShape>> create_matmul_lhs_quant_pack_qai8dxp1vlx4_f32(); | |
| 19 | - | |
| 20 | -/// Creates a wrapper for kai_lhs_quant_pack_qai8dxp_f32 micro-kernel. | |
| 21 | -[[nodiscard]] std::unique_ptr<KernelWrapper<MatShape>> create_matmul_lhs_quant_pack_qai8dxp1x4_f32(); | |
| 22 | - | |
| 23 | -/// Creates a wrapper for kai_lhs_pack_f32p2vlx1_f32_sme micro-kernel. | |
| 24 | -[[nodiscard]] std::unique_ptr<KernelWrapper<MatShape>> create_matmul_lhs_pack_f32p2vlx1_f32_sme(); | |
| 25 | - | |
| 26 | -/// Creates a wrapper for kai_matmul_pack_lhs_mxk_x32p4vsx1_x32_sme. | |
| 27 | -[[nodiscard]] std::unique_ptr<KernelWrapper<MatShape>> create_matmul_pack_lhs_mxk_x32p4vsx1_x32_sme(); | |
| 28 | - | |
| 29 | -/// Creates a wrapper for kai_matmul_pack_lhs_mxk_x8p4vsx4_x8_sme. | |
| 30 | -[[nodiscard]] std::unique_ptr<KernelWrapper<MatShape>> create_matmul_pack_lhs_mxk_x8p4vsx4_x8_sme(); | |
| 31 | - | |
| 32 | -/// Checks if the portion produces non-empty LHS packing tiles for the x32p4vsx1 matmul operator. | |
| 33 | -[[nodiscard]] bool is_shape_suitable_lhs_x32p4vsx1_x32_sme( | |
| 34 | - size_t shape_m, size_t shape_n, size_t shape_k, const MatrixPortion& portion); | |
| 35 | - | |
| 36 | -/// Checks if the portion produces non-empty LHS packing tiles for the x8p4vsx4 matmul operator. | |
| 37 | -[[nodiscard]] bool is_shape_suitable_lhs_x8p4vsx4_x8_sme( | |
| 38 | - size_t shape_m, size_t shape_n, size_t shape_k, const MatrixPortion& portion); | |
| 39 | - | |
| 40 | -/// Checks if the portion produces non-empty LHS packing tiles for the qai8dxp1vlx8/qsi4cxp4vlx8 matmul operator. | |
| 41 | -[[nodiscard]] bool is_shape_suitable_lhs_qai8dxp1vlx8_qsi4cxp4vlx8_1vlx4vl_sme2_mopa( | |
| 42 | - size_t shape_m, size_t shape_n, size_t shape_k, const MatrixPortion& portion); | |
| 43 | - | |
| 44 | -/// Checks if the portion produces non-empty LHS packing tiles for the qai8dxp1vlx8/qsi4cxp4vlx8 matmul operator. | |
| 45 | -[[nodiscard]] bool is_shape_suitable_lhs_qai8dxp1vlx4_qsi4cxp4vlx4_1vlx4vl_sme_mopa( | |
| 46 | - size_t shape_m, size_t shape_n, size_t shape_k, const MatrixPortion& portion); | |
| 47 | - | |
| 48 | -/// Checks if the portion produces non-empty LHS packing tiles for the qai8dxp1x4/qsi4cxp4vlx4 matmul operator. | |
| 49 | -[[nodiscard]] bool is_shape_suitable_lhs_qai8dxp1x4_qsi4cxp4vlx4_1x4vl_sme2_sdot( | |
| 50 | - size_t shape_m, size_t shape_n, size_t shape_k, const MatrixPortion& portion); | |
| 51 | - | |
| 52 | -/// Checks if the portion produces non-empty LHS packing tiles for the f32p2vlx1 matmul operator. | |
| 53 | -[[nodiscard]] bool is_shape_suitable_lhs_f32p2vlx1_f32p2vlx1biasf32_sme2_mopa( | |
| 54 | - size_t shape_m, size_t shape_n, size_t shape_k, const MatrixPortion& portion); | |
| 55 | - | |
| 56 | -} // namespace kai::test |
added test/nextgen/operators/matmul/pack_lhs/matmul_pack_lhs_wrapper_registry.cpp +180 −0
| @@ -0,0 +1,180 @@ | ||
| 1 | +// | |
| 2 | +// SPDX-FileCopyrightText: Copyright 2025-2026 Arm Limited and/or its affiliates <open-source-office@arm.com> | |
| 3 | +// | |
| 4 | +// SPDX-License-Identifier: Apache-2.0 | |
| 5 | +// | |
| 6 | + | |
| 7 | +#include "test/nextgen/operators/matmul/pack_lhs/matmul_pack_lhs_wrapper_registry.hpp" | |
| 8 | + | |
| 9 | +#include <array> | |
| 10 | +#include <cstdint> | |
| 11 | +#include <memory> | |
| 12 | +#include <string> | |
| 13 | +#include <string_view> | |
| 14 | + | |
| 15 | +#include "kai/ukernels/matmul/kai_matmul_pack_lhs.h" | |
| 16 | +#include "kai/ukernels/matmul/matmul_clamp_f32_f32p_f32p/kai_matmul_clamp_f32_f32p2vlx1_f32p2vlx1biasf32_sme2_mopa.h" | |
| 17 | +#include "kai/ukernels/matmul/matmul_clamp_f32_qai8dxp_qsi4cxp/kai_matmul_clamp_f32_qai8dxp1vlx4_qsi4cxp4vlx4_1vlx4vl_sme_mopa.h" | |
| 18 | +#include "kai/ukernels/matmul/matmul_clamp_f32_qai8dxp_qsi4cxp/kai_matmul_clamp_f32_qai8dxp1vlx8_qsi4cxp4vlx8_1vlx4vl_sme2_mopa.h" | |
| 19 | +#include "kai/ukernels/matmul/matmul_clamp_f32_qai8dxp_qsi4cxp/kai_matmul_clamp_f32_qai8dxp1x4_qsi4cxp4vlx4_1x4vl_sme2_sdot.h" | |
| 20 | +#include "kai/ukernels/matmul/pack/kai_lhs_pack_f32p2vlx1_f32_sme.h" | |
| 21 | +#include "kai/ukernels/matmul/pack/kai_lhs_quant_pack_qai8dxp_f32.h" | |
| 22 | +#include "test/common/data_type.hpp" | |
| 23 | +#include "test/common/matrix_portion.hpp" | |
| 24 | +#include "test/common/sme.hpp" | |
| 25 | +#include "test/nextgen/common/poly.hpp" | |
| 26 | +#include "test/nextgen/format/block2d_row_format.hpp" | |
| 27 | +#include "test/nextgen/format/plain_format.hpp" | |
| 28 | +#include "test/nextgen/harness/kernel_wrapper.hpp" | |
| 29 | +#include "test/nextgen/operators/matmul/pack_lhs/matmul_pack_lhs_dq_wrapper.hpp" | |
| 30 | +#include "test/nextgen/operators/matmul/pack_lhs/matmul_pack_lhs_fp_wrapper.hpp" | |
| 31 | +#include "test/nextgen/operators/matmul/pack_lhs/matmul_pack_lhs_interface.hpp" | |
| 32 | +#include "test/nextgen/operators/matmul/pack_lhs/matmul_pack_lhs_ukerapi_wrapper.hpp" | |
| 33 | + | |
| 34 | +namespace kai::test { | |
| 35 | + | |
| 36 | +namespace { | |
| 37 | + | |
| 38 | +std::unique_ptr<KernelWrapper<MatShape>> create_matmul_lhs_quant_pack_qai8dxp_f32( | |
| 39 | + std::string_view block_name, size_t block_height, size_t block_width) { | |
| 40 | + return std::make_unique<MatMulPackLhsDqWrapper>( | |
| 41 | + "matmul_lhs_quant_pack_qai8dxp" + std::string(block_name) + "_f32", | |
| 42 | + MatMulPackLhsDqInterface{ | |
| 43 | + kai_get_m_step_lhs_quant_pack_qai8dxp_f32, | |
| 44 | + kai_get_lhs_offset_lhs_quant_pack_qai8dxp_f32, | |
| 45 | + kai_get_lhs_packed_offset_lhs_quant_pack_qai8dxp_f32, | |
| 46 | + kai_get_lhs_packed_size_lhs_quant_pack_qai8dxp_f32, | |
| 47 | + kai_run_lhs_quant_pack_qai8dxp_f32, | |
| 48 | + }, | |
| 49 | + make_poly<PlainFormat>(DataType::FP32), | |
| 50 | + make_poly<Block2dRowFormat>( | |
| 51 | + block_height, block_width, 32, true, DataType::I8, std::array<DataType, 0>{}, | |
| 52 | + std::array{DataType::I32, DataType::FP32})); | |
| 53 | +} | |
| 54 | + | |
| 55 | +bool portion_non_empty( | |
| 56 | + size_t full_height, size_t full_width, size_t scheduler_block_height, size_t scheduler_block_width, | |
| 57 | + const MatrixPortion& portion) { | |
| 58 | + const Rect rect = portion.compute_portion(full_height, full_width, scheduler_block_height, scheduler_block_width); | |
| 59 | + return rect.height() > 0 && rect.width() > 0; | |
| 60 | +} | |
| 61 | + | |
| 62 | +bool is_shape_suitable_lhs_uker_api( | |
| 63 | + size_t shape_m, size_t shape_k, const MatrixPortion& portion, const kai_matmul_pack_lhs_uker_api& api) { | |
| 64 | + if (shape_m == 0 || shape_k == 0) { | |
| 65 | + return false; | |
| 66 | + } | |
| 67 | + | |
| 68 | + const kai_matmul_pack_lhs_uker_config config = {}; | |
| 69 | + | |
| 70 | + const struct kai_matmul_pack_lhs_uker_dim_args step = api.get_step(&config); | |
| 71 | + | |
| 72 | + const size_t block_m = (step.m == 0) ? shape_m : step.m; | |
| 73 | + const size_t block_k = (step.k == 0) ? shape_k : step.k; | |
| 74 | + | |
| 75 | + return portion_non_empty(shape_m, shape_k, block_m, block_k, portion); | |
| 76 | +} | |
| 77 | + | |
| 78 | +} // namespace | |
| 79 | + | |
| 80 | +std::unique_ptr<KernelWrapper<MatShape>> create_matmul_pack_lhs_mxk_x32p4vsx1_x32_sme() { | |
| 81 | + return std::make_unique<MatMulPackLhsUkerApiWrapper>( | |
| 82 | + "create_matmul_pack_lhs_mxk_x32p4vsx1_x32_sme", kai_matmul_pack_lhs_mxk_x32p4vsx1_x32_sme(), | |
| 83 | + make_poly<PlainFormat>(DataType::FP32), | |
| 84 | + make_poly<Block2dRowFormat>( | |
| 85 | + 4 * get_sme_vector_scale(), 1, 1, false, DataType::FP32, std::array<DataType, 0>{}, | |
| 86 | + std::array<DataType, 0>{})); | |
| 87 | +} | |
| 88 | + | |
| 89 | +std::unique_ptr<KernelWrapper<MatShape>> create_matmul_pack_lhs_mxk_x8p4vsx4_x8_sme() { | |
| 90 | + return std::make_unique<MatMulPackLhsUkerApiWrapper>( | |
| 91 | + "matmul_pack_lhs_mxk_x8p4vsx4_x8_sme", kai_matmul_pack_lhs_mxk_x8p4vsx4_x8_sme(), | |
| 92 | + make_poly<PlainFormat>(DataType::U8), | |
| 93 | + make_poly<Block2dRowFormat>( | |
| 94 | + 4 * get_sme_vector_scale(), 4, 4, false, DataType::U8, std::array<DataType, 0>{}, | |
| 95 | + std::array<DataType, 0>{})); | |
| 96 | +} | |
| 97 | + | |
| 98 | +std::unique_ptr<KernelWrapper<MatShape>> create_matmul_lhs_quant_pack_qai8dxp1vlx4_f32() { | |
| 99 | + return create_matmul_lhs_quant_pack_qai8dxp_f32("1vlx4", 1 * get_sme_vector_length<float>(), 4); | |
| 100 | +} | |
| 101 | + | |
| 102 | +std::unique_ptr<KernelWrapper<MatShape>> create_matmul_lhs_quant_pack_qai8dxp1x4_f32() { | |
| 103 | + return create_matmul_lhs_quant_pack_qai8dxp_f32("1x4", 1, 4); | |
| 104 | +} | |
| 105 | + | |
| 106 | +std::unique_ptr<KernelWrapper<MatShape>> create_matmul_lhs_pack_f32p2vlx1_f32_sme() { | |
| 107 | + return std::make_unique<MatMulPackLhsFpWrapper>( | |
| 108 | + "create_matmul_lhs_pack_f32p2vlx1_f32_sme", | |
| 109 | + MatMulPackLhsFpInterface{ | |
| 110 | + kai_get_m_step_lhs_pack_f32p2vlx1_f32_sme, | |
| 111 | + kai_get_lhs_offset_lhs_pack_f32p2vlx1_f32_sme, | |
| 112 | + kai_get_lhs_packed_offset_lhs_pack_f32p2vlx1_f32_sme, | |
| 113 | + kai_get_lhs_packed_size_lhs_pack_f32p2vlx1_f32_sme, | |
| 114 | + kai_run_lhs_pack_f32p2vlx1_f32_sme, | |
| 115 | + }, | |
| 116 | + make_poly<PlainFormat>(DataType::FP32), | |
| 117 | + make_poly<Block2dRowFormat>( | |
| 118 | + 2 * get_sme_vector_length<float>(), 1, 1, false, DataType::FP32, std::array<DataType, 0>{}, | |
| 119 | + std::array<DataType, 0>{})); | |
| 120 | +} | |
| 121 | + | |
| 122 | +bool is_shape_suitable_lhs_x32p4vsx1_x32_sme( | |
| 123 | + size_t shape_m, [[maybe_unused]] size_t shape_n, size_t shape_k, const MatrixPortion& portion) { | |
| 124 | + return is_shape_suitable_lhs_uker_api(shape_m, shape_k, portion, kai_matmul_pack_lhs_mxk_x32p4vsx1_x32_sme()); | |
| 125 | +} | |
| 126 | + | |
| 127 | +bool is_shape_suitable_lhs_x8p4vsx4_x8_sme( | |
| 128 | + size_t shape_m, [[maybe_unused]] size_t shape_n, size_t shape_k, const MatrixPortion& portion) { | |
| 129 | + return is_shape_suitable_lhs_uker_api(shape_m, shape_k, portion, kai_matmul_pack_lhs_mxk_x8p4vsx4_x8_sme()); | |
| 130 | +} | |
| 131 | + | |
| 132 | +bool is_shape_suitable_lhs_qai8dxp1vlx8_qsi4cxp4vlx8_1vlx4vl_sme2_mopa( | |
| 133 | + size_t shape_m, [[maybe_unused]] size_t shape_n, size_t shape_k, const MatrixPortion& portion) { | |
| 134 | + if (shape_m == 0 || shape_k == 0) { | |
| 135 | + return false; | |
| 136 | + } | |
| 137 | + | |
| 138 | + const size_t mr = kai_get_mr_matmul_clamp_f32_qai8dxp1vlx8_qsi4cxp4vlx8_1vlx4vl_sme2_mopa(); | |
| 139 | + const size_t lhs_m_step = kai_get_m_step_lhs_quant_pack_qai8dxp_f32(mr); | |
| 140 | + | |
| 141 | + return portion_non_empty(shape_m, shape_k, lhs_m_step, shape_k, portion); | |
| 142 | +} | |
| 143 | + | |
| 144 | +bool is_shape_suitable_lhs_qai8dxp1vlx4_qsi4cxp4vlx4_1vlx4vl_sme_mopa( | |
| 145 | + size_t shape_m, [[maybe_unused]] size_t shape_n, size_t shape_k, const MatrixPortion& portion) { | |
| 146 | + if (shape_m == 0 || shape_k == 0) { | |
| 147 | + return false; | |
| 148 | + } | |
| 149 | + | |
| 150 | + const size_t mr = kai_get_mr_matmul_clamp_f32_qai8dxp1vlx4_qsi4cxp4vlx4_1vlx4vl_sme_mopa(); | |
| 151 | + const size_t lhs_m_step = kai_get_m_step_lhs_quant_pack_qai8dxp_f32(mr); | |
| 152 | + | |
| 153 | + return portion_non_empty(shape_m, shape_k, lhs_m_step, shape_k, portion); | |
| 154 | +} | |
| 155 | + | |
| 156 | +bool is_shape_suitable_lhs_qai8dxp1x4_qsi4cxp4vlx4_1x4vl_sme2_sdot( | |
| 157 | + size_t shape_m, [[maybe_unused]] size_t shape_n, size_t shape_k, const MatrixPortion& portion) { | |
| 158 | + if (shape_m == 0 || shape_k == 0) { | |
| 159 | + return false; | |
| 160 | + } | |
| 161 | + | |
| 162 | + const size_t mr = kai_get_mr_matmul_clamp_f32_qai8dxp1x4_qsi4cxp4vlx4_1x4vl_sme2_sdot(); | |
| 163 | + const size_t lhs_m_step = kai_get_m_step_lhs_quant_pack_qai8dxp_f32(mr); | |
| 164 | + | |
| 165 | + return portion_non_empty(shape_m, shape_k, lhs_m_step, shape_k, portion); | |
| 166 | +} | |
| 167 | + | |
| 168 | +bool is_shape_suitable_lhs_f32p2vlx1_f32p2vlx1biasf32_sme2_mopa( | |
| 169 | + size_t shape_m, [[maybe_unused]] size_t shape_n, size_t shape_k, const MatrixPortion& portion) { | |
| 170 | + if (shape_m == 0 || shape_k == 0) { | |
| 171 | + return false; | |
| 172 | + } | |
| 173 | + | |
| 174 | + const size_t mr = kai_get_mr_matmul_clamp_f32_f32p2vlx1_f32p2vlx1biasf32_sme2_mopa(); | |
| 175 | + const size_t lhs_m_step = kai_get_m_step_lhs_pack_f32p2vlx1_f32_sme(mr); | |
| 176 | + | |
| 177 | + return portion_non_empty(shape_m, shape_k, lhs_m_step, shape_k, portion); | |
| 178 | +} | |
| 179 | + | |
| 180 | +} // namespace kai::test |
added test/nextgen/operators/matmul/pack_lhs/matmul_pack_lhs_wrapper_registry.hpp +56 −0
| @@ -0,0 +1,56 @@ | ||
| 1 | +// | |
| 2 | +// SPDX-FileCopyrightText: Copyright 2025-2026 Arm Limited and/or its affiliates <open-source-office@arm.com> | |
| 3 | +// | |
| 4 | +// SPDX-License-Identifier: Apache-2.0 | |
| 5 | +// | |
| 6 | + | |
| 7 | +#pragma once | |
| 8 | + | |
| 9 | +#include <memory> | |
| 10 | + | |
| 11 | +#include "test/common/matrix_portion.hpp" | |
| 12 | +#include "test/nextgen/harness/kernel_wrapper.hpp" | |
| 13 | +#include "test/nextgen/operators/matmul/matmul_dims.hpp" | |
| 14 | + | |
| 15 | +namespace kai::test { | |
| 16 | + | |
| 17 | +/// Creates a wrapper for kai_lhs_quant_pack_qai8dxp_f32 micro-kernel. | |
| 18 | +[[nodiscard]] std::unique_ptr<KernelWrapper<MatShape>> create_matmul_lhs_quant_pack_qai8dxp1vlx4_f32(); | |
| 19 | + | |
| 20 | +/// Creates a wrapper for kai_lhs_quant_pack_qai8dxp_f32 micro-kernel. | |
| 21 | +[[nodiscard]] std::unique_ptr<KernelWrapper<MatShape>> create_matmul_lhs_quant_pack_qai8dxp1x4_f32(); | |
| 22 | + | |
| 23 | +/// Creates a wrapper for kai_lhs_pack_f32p2vlx1_f32_sme micro-kernel. | |
| 24 | +[[nodiscard]] std::unique_ptr<KernelWrapper<MatShape>> create_matmul_lhs_pack_f32p2vlx1_f32_sme(); | |
| 25 | + | |
| 26 | +/// Creates a wrapper for kai_matmul_pack_lhs_mxk_x32p4vsx1_x32_sme. | |
| 27 | +[[nodiscard]] std::unique_ptr<KernelWrapper<MatShape>> create_matmul_pack_lhs_mxk_x32p4vsx1_x32_sme(); | |
| 28 | + | |
| 29 | +/// Creates a wrapper for kai_matmul_pack_lhs_mxk_x8p4vsx4_x8_sme. | |
| 30 | +[[nodiscard]] std::unique_ptr<KernelWrapper<MatShape>> create_matmul_pack_lhs_mxk_x8p4vsx4_x8_sme(); | |
| 31 | + | |
| 32 | +/// Checks if the portion produces non-empty LHS packing tiles for the x32p4vsx1 matmul operator. | |
| 33 | +[[nodiscard]] bool is_shape_suitable_lhs_x32p4vsx1_x32_sme( | |
| 34 | + size_t shape_m, size_t shape_n, size_t shape_k, const MatrixPortion& portion); | |
| 35 | + | |
| 36 | +/// Checks if the portion produces non-empty LHS packing tiles for the x8p4vsx4 matmul operator. | |
| 37 | +[[nodiscard]] bool is_shape_suitable_lhs_x8p4vsx4_x8_sme( | |
| 38 | + size_t shape_m, size_t shape_n, size_t shape_k, const MatrixPortion& portion); | |
| 39 | + | |
| 40 | +/// Checks if the portion produces non-empty LHS packing tiles for the qai8dxp1vlx8/qsi4cxp4vlx8 matmul operator. | |
| 41 | +[[nodiscard]] bool is_shape_suitable_lhs_qai8dxp1vlx8_qsi4cxp4vlx8_1vlx4vl_sme2_mopa( | |
| 42 | + size_t shape_m, size_t shape_n, size_t shape_k, const MatrixPortion& portion); | |
| 43 | + | |
| 44 | +/// Checks if the portion produces non-empty LHS packing tiles for the qai8dxp1vlx8/qsi4cxp4vlx8 matmul operator. | |
| 45 | +[[nodiscard]] bool is_shape_suitable_lhs_qai8dxp1vlx4_qsi4cxp4vlx4_1vlx4vl_sme_mopa( | |
| 46 | + size_t shape_m, size_t shape_n, size_t shape_k, const MatrixPortion& portion); | |
| 47 | + | |
| 48 | +/// Checks if the portion produces non-empty LHS packing tiles for the qai8dxp1x4/qsi4cxp4vlx4 matmul operator. | |
| 49 | +[[nodiscard]] bool is_shape_suitable_lhs_qai8dxp1x4_qsi4cxp4vlx4_1x4vl_sme2_sdot( | |
| 50 | + size_t shape_m, size_t shape_n, size_t shape_k, const MatrixPortion& portion); | |
| 51 | + | |
| 52 | +/// Checks if the portion produces non-empty LHS packing tiles for the f32p2vlx1 matmul operator. | |
| 53 | +[[nodiscard]] bool is_shape_suitable_lhs_f32p2vlx1_f32p2vlx1biasf32_sme2_mopa( | |
| 54 | + size_t shape_m, size_t shape_n, size_t shape_k, const MatrixPortion& portion); | |
| 55 | + | |
| 56 | +} // namespace kai::test |
deleted test/nextgen/operators/matmul/pack_rhs/matmul_pack_rhs_wrapper.cpp +0 −207
| @@ -1,207 +0,0 @@ | ||
| 1 | -// | |
| 2 | -// SPDX-FileCopyrightText: Copyright 2025-2026 Arm Limited and/or its affiliates <open-source-office@arm.com> | |
| 3 | -// | |
| 4 | -// SPDX-License-Identifier: Apache-2.0 | |
| 5 | -// | |
| 6 | - | |
| 7 | -#include "test/nextgen/operators/matmul/pack_rhs/matmul_pack_rhs_wrapper.hpp" | |
| 8 | - | |
| 9 | -#include <array> | |
| 10 | -#include <memory> | |
| 11 | - | |
| 12 | -#include "kai/ukernels/matmul/kai_matmul_pack_rhs.h" | |
| 13 | -#include "kai/ukernels/matmul/matmul_clamp_f32_qai8dxp_qsi4cxp/kai_matmul_clamp_f32_qai8dxp1vlx4_qsi4cxp4vlx4_1vlx4vl_sme_mopa.h" | |
| 14 | -#include "kai/ukernels/matmul/matmul_clamp_f32_qai8dxp_qsi4cxp/kai_matmul_clamp_f32_qai8dxp1vlx8_qsi4cxp4vlx8_1vlx4vl_sme2_mopa.h" | |
| 15 | -#include "kai/ukernels/matmul/matmul_clamp_f32_qai8dxp_qsi4cxp/kai_matmul_clamp_f32_qai8dxp1x4_qsi4cxp4vlx4_1x4vl_sme2_sdot.h" | |
| 16 | -#include "kai/ukernels/matmul/pack/kai_rhs_pack_kxn_f32p2vlx1biasf32_f32_f32_sme.h" | |
| 17 | -#include "kai/ukernels/matmul/pack/kai_rhs_pack_nxk_qsi4cxps1s0_qsu4cxs1s0_neon.h" | |
| 18 | -#include "test/common/data_type.hpp" | |
| 19 | -#include "test/common/sme.hpp" | |
| 20 | -#include "test/nextgen/common/poly.hpp" | |
| 21 | -#include "test/nextgen/format/block2d_row_format.hpp" | |
| 22 | -#include "test/nextgen/format/plain_format.hpp" | |
| 23 | -#include "test/nextgen/harness/kernel_wrapper.hpp" | |
| 24 | -#include "test/nextgen/operators/matmul/pack_rhs/matmul_pack_rhs_fp_nt_wrapper.hpp" | |
| 25 | -#include "test/nextgen/operators/matmul/pack_rhs/matmul_pack_rhs_interface.hpp" | |
| 26 | -#include "test/nextgen/operators/matmul/pack_rhs/matmul_pack_rhs_quant_wrapper.hpp" | |
| 27 | -#include "test/nextgen/operators/matmul/pack_rhs/matmul_pack_rhs_ukerapi_t_wrapper.hpp" | |
| 28 | -#include "test/nextgen/operators/matmul/pack_rhs/matmul_pack_rhs_ukerapi_wrapper.hpp" | |
| 29 | - | |
| 30 | -namespace kai::test { | |
| 31 | - | |
| 32 | -namespace { | |
| 33 | - | |
| 34 | -bool portion_non_empty( | |
| 35 | - size_t full_height, size_t full_width, size_t scheduler_block_height, size_t scheduler_block_width, | |
| 36 | - const MatrixPortion& portion) { | |
| 37 | - const Rect rect = portion.compute_portion(full_height, full_width, scheduler_block_height, scheduler_block_width); | |
| 38 | - return rect.height() > 0 && rect.width() > 0; | |
| 39 | -} | |
| 40 | - | |
| 41 | -bool is_shape_suitable_rhs_uker_api( | |
| 42 | - size_t shape_n, size_t shape_k, const MatrixPortion& portion, const kai_matmul_pack_rhs_uker_api& api) { | |
| 43 | - if (shape_n == 0 || shape_k == 0) { | |
| 44 | - return false; | |
| 45 | - } | |
| 46 | - | |
| 47 | - const kai_matmul_pack_rhs_uker_config config = {}; | |
| 48 | - | |
| 49 | - const kai_matmul_pack_rhs_uker_dim_args step = api.get_step(&config); | |
| 50 | - | |
| 51 | - const size_t block_n = (step.n == 0) ? shape_n : step.n; | |
| 52 | - const size_t block_k = (step.k == 0) ? shape_k : step.k; | |
| 53 | - | |
| 54 | - return portion_non_empty(shape_n, shape_k, block_n, block_k, portion); | |
| 55 | -} | |
| 56 | - | |
| 57 | -/// Creates a placeholder format used to explicitly indicate that bias is unused. | |
| 58 | -Poly<Format> unused_bias_format() { | |
| 59 | - return make_poly<PlainFormat>(DataType::UNKNOWN); | |
| 60 | -} | |
| 61 | - | |
| 62 | -} // namespace | |
| 63 | - | |
| 64 | -std::unique_ptr<KernelWrapper<MatShape>> create_matmul_rhs_pack_nxk_qsi4cxp4vlx4s1s0_qsu4cxs1s0_neon() { | |
| 65 | - return std::make_unique<MatMulPackRhsQuantWrapper>( | |
| 66 | - "matmul_rhs_pack_nxk_qsi4cxps1s0_qsu4cxs1s0_neon", | |
| 67 | - MatMulPackRhsQuantInterface{ | |
| 68 | - kai_get_n_step_rhs_pack_nxk_qsi4cxps1s0_qsu4cxs1s0_neon, | |
| 69 | - kai_get_rhs_offset_rhs_pack_nxk_qsi4cxps1s0_qsu4cxs1s0_neon, | |
| 70 | - kai_get_rhs_packed_stride_rhs_pack_nxk_qsi4cxps1s0_qsu4cxs1s0_neon, | |
| 71 | - kai_get_rhs_packed_offset_rhs_pack_nxk_qsi4cxps1s0_qsu4cxs1s0_neon, | |
| 72 | - kai_get_rhs_packed_size_rhs_pack_nxk_qsi4cxps1s0_qsu4cxs1s0_neon, | |
| 73 | - kai_run_rhs_pack_nxk_qsi4cxps1s0_qsu4cxs1s0_neon, | |
| 74 | - }, | |
| 75 | - make_poly<PlainFormat>(DataType::U4), make_poly<PlainFormat>(DataType::FP32), | |
| 76 | - make_poly<PlainFormat>(DataType::FP32), make_poly<PlainFormat>(DataType::I32), | |
| 77 | - make_poly<Block2dRowFormat>( | |
| 78 | - 4 * get_sme_vector_length<float>(), 4, 32, false, DataType::I4, std::array<DataType, 0>{}, | |
| 79 | - std::array{DataType::I32, DataType::FP32, DataType::FP32})); | |
| 80 | -} | |
| 81 | - | |
| 82 | -std::unique_ptr<KernelWrapper<MatShape>> create_matmul_rhs_pack_kxn_f32p2vlx1biasf32_f32_f32_sme() { | |
| 83 | - return std::make_unique<MatMulPackRhsFpNtWrapper>( | |
| 84 | - "matmul_rhs_pack_kxn_f32p2vlx1biasf32_f32_f32_sme", | |
| 85 | - MatMulPackRhsFpInterface{ | |
| 86 | - kai_get_n_step_rhs_pack_kxn_f32p2vlx1biasf32_f32_f32_sme, | |
| 87 | - kai_get_rhs_offset_rhs_pack_kxn_f32p2vlx1biasf32_f32_f32_sme, | |
| 88 | - kai_get_bias_offset_rhs_pack_kxn_f32p2vlx1biasf32_f32_f32_sme, | |
| 89 | - kai_get_rhs_packed_stride_rhs_pack_kxn_f32p2vlx1biasf32_f32_f32_sme, | |
| 90 | - kai_get_rhs_packed_offset_rhs_pack_kxn_f32p2vlx1biasf32_f32_f32_sme, | |
| 91 | - kai_get_rhs_packed_size_rhs_pack_kxn_f32p2vlx1biasf32_f32_f32_sme, | |
| 92 | - kai_run_rhs_pack_kxn_f32p2vlx1biasf32_f32_f32_sme, | |
| 93 | - }, | |
| 94 | - make_poly<PlainFormat>(DataType::FP32), make_poly<PlainFormat>(DataType::FP32), | |
| 95 | - make_poly<Block2dRowFormat>( | |
| 96 | - 2 * get_sme_vector_length<float>(), 1, 1, false, DataType::FP32, std::array{DataType::FP32}, | |
| 97 | - std::array<DataType, 0>{})); | |
| 98 | -} | |
| 99 | - | |
| 100 | -std::unique_ptr<KernelWrapper<MatShape>> create_matmul_pack_rhs_kxn_x32p4vsx1bx32_x32_x32_sme() { | |
| 101 | - return std::make_unique<MatMulPackRhsUkerApiWrapper>( | |
| 102 | - "create_matmul_pack_rhs_kxn_x32p4vsx1bx32_x32_x32_sme", kai_matmul_pack_rhs_kxn_x32p4vsx1bx32_x32_x32_sme(), | |
| 103 | - make_poly<PlainFormat>(DataType::FP32), make_poly<PlainFormat>(DataType::FP32), | |
| 104 | - make_poly<Block2dRowFormat>( | |
| 105 | - 4 * get_sme_vector_scale(), 1, 1, false, DataType::FP32, std::array{DataType::FP32}, | |
| 106 | - std::array<DataType, 0>{}), | |
| 107 | - MatMulUkerApiBiasDeliveryStage::PACK_RHS); | |
| 108 | -} | |
| 109 | - | |
| 110 | -std::unique_ptr<KernelWrapper<MatShape>> create_matmul_pack_rhs_nxk_x32p4vsx1bx32_x32_x32_sme() { | |
| 111 | - return std::make_unique<MatMulPackRhsUkerApiTWrapper>( | |
| 112 | - "create_matmul_pack_rhs_nxk_x32p4vsx1bx32_x32_x32_sme", kai_matmul_pack_rhs_nxk_x32p4vsx1bx32_x32_x32_sme(), | |
| 113 | - make_poly<PlainFormat>(DataType::FP32), make_poly<PlainFormat>(DataType::FP32), | |
| 114 | - make_poly<Block2dRowFormat>( | |
| 115 | - 4 * get_sme_vector_scale(), 1, 1, false, DataType::FP32, std::array{DataType::FP32}, | |
| 116 | - std::array<DataType, 0>{}), | |
| 117 | - MatMulUkerApiBiasDeliveryStage::PACK_RHS); | |
| 118 | -} | |
| 119 | - | |
| 120 | -std::unique_ptr<KernelWrapper<MatShape>> create_matmul_pack_rhs_nxk_x8p4vsx4_x8_sme() { | |
| 121 | - return std::make_unique<MatMulPackRhsUkerApiTWrapper>( | |
| 122 | - "matmul_pack_rhs_nxk_x8p4vsx4_x8_sme", kai_matmul_pack_rhs_nxk_x8p4vsx4_x8_sme(), | |
| 123 | - make_poly<PlainFormat>(DataType::U8), unused_bias_format(), | |
| 124 | - make_poly<Block2dRowFormat>( | |
| 125 | - 4 * get_sme_vector_scale(), 4, 4, false, DataType::U8, std::array<DataType, 0>{}, | |
| 126 | - std::array<DataType, 0>{}), | |
| 127 | - MatMulUkerApiBiasDeliveryStage::MATMUL); | |
| 128 | -} | |
| 129 | - | |
| 130 | -std::unique_ptr<KernelWrapper<MatShape>> create_matmul_pack_rhs_kxn_x8p4vsx4_x8_sme() { | |
| 131 | - return std::make_unique<MatMulPackRhsUkerApiWrapper>( | |
| 132 | - "matmul_pack_rhs_kxn_x8p4vsx4_x8_sme", kai_matmul_pack_rhs_kxn_x8p4vsx4_x8_sme(), | |
| 133 | - make_poly<PlainFormat>(DataType::U8), unused_bias_format(), | |
| 134 | - make_poly<Block2dRowFormat>( | |
| 135 | - 4 * get_sme_vector_scale(), 4, 4, false, DataType::U8, std::array<DataType, 0>{}, | |
| 136 | - std::array<DataType, 0>{}), | |
| 137 | - MatMulUkerApiBiasDeliveryStage::MATMUL); | |
| 138 | -} | |
| 139 | - | |
| 140 | -bool is_shape_suitable_rhs_qai8dxp1vlx8_qsi4cxp4vlx8_1vlx4vl_sme2_mopa( | |
| 141 | - [[maybe_unused]] size_t shape_m, size_t shape_n, size_t shape_k, const MatrixPortion& portion) { | |
| 142 | - if (shape_n == 0 || shape_k == 0) { | |
| 143 | - return false; | |
| 144 | - } | |
| 145 | - | |
| 146 | - const size_t nr = kai_get_nr_matmul_clamp_f32_qai8dxp1vlx8_qsi4cxp4vlx8_1vlx4vl_sme2_mopa(); | |
| 147 | - const size_t rhs_n_step = kai_get_n_step_rhs_pack_nxk_qsi4cxps1s0_qsu4cxs1s0_neon(nr); | |
| 148 | - | |
| 149 | - return portion_non_empty(shape_n, shape_k, rhs_n_step, shape_k, portion); | |
| 150 | -} | |
| 151 | - | |
| 152 | -bool is_shape_suitable_rhs_qai8dxp1vlx4_qsi4cxp4vlx4_1vlx4vl_sme_mopa( | |
| 153 | - [[maybe_unused]] size_t shape_m, size_t shape_n, size_t shape_k, const MatrixPortion& portion) { | |
| 154 | - if (shape_n == 0 || shape_k == 0) { | |
| 155 | - return false; | |
| 156 | - } | |
| 157 | - | |
| 158 | - const size_t nr = kai_get_nr_matmul_clamp_f32_qai8dxp1vlx4_qsi4cxp4vlx4_1vlx4vl_sme_mopa(); | |
| 159 | - const size_t rhs_n_step = kai_get_n_step_rhs_pack_nxk_qsi4cxps1s0_qsu4cxs1s0_neon(nr); | |
| 160 | - | |
| 161 | - return portion_non_empty(shape_n, shape_k, rhs_n_step, shape_k, portion); | |
| 162 | -} | |
| 163 | - | |
| 164 | -bool is_shape_suitable_rhs_qai8dxp1x4_qsi4cxp4vlx4_1x4vl_sme2_sdot( | |
| 165 | - [[maybe_unused]] size_t shape_m, size_t shape_n, size_t shape_k, const MatrixPortion& portion) { | |
| 166 | - if (shape_n == 0 || shape_k == 0) { | |
| 167 | - return false; | |
| 168 | - } | |
| 169 | - | |
| 170 | - const size_t nr = kai_get_nr_matmul_clamp_f32_qai8dxp1x4_qsi4cxp4vlx4_1x4vl_sme2_sdot(); | |
| 171 | - const size_t rhs_n_step = kai_get_n_step_rhs_pack_nxk_qsi4cxps1s0_qsu4cxs1s0_neon(nr); | |
| 172 | - | |
| 173 | - return portion_non_empty(shape_n, shape_k, rhs_n_step, shape_k, portion); | |
| 174 | -} | |
| 175 | - | |
| 176 | -bool is_shape_suitable_rhs_f32p2vlx1_f32p2vlx1biasf32_sme2_mopa( | |
| 177 | - [[maybe_unused]] size_t shape_m, size_t shape_n, size_t shape_k, const MatrixPortion& portion) { | |
| 178 | - if (shape_n == 0 || shape_k == 0) { | |
| 179 | - return false; | |
| 180 | - } | |
| 181 | - | |
| 182 | - const size_t rhs_n_step = kai_get_n_step_rhs_pack_kxn_f32p2vlx1biasf32_f32_f32_sme(); | |
| 183 | - return portion_non_empty(shape_n, shape_k, rhs_n_step, shape_k, portion); | |
| 184 | -} | |
| 185 | - | |
| 186 | -bool is_shape_suitable_rhs_kxn_x32p4vsx1bx32_x32_x32_sme( | |
| 187 | - [[maybe_unused]] size_t shape_m, size_t shape_n, size_t shape_k, const MatrixPortion& portion) { | |
| 188 | - return is_shape_suitable_rhs_uker_api( | |
| 189 | - shape_n, shape_k, portion, kai_matmul_pack_rhs_kxn_x32p4vsx1bx32_x32_x32_sme()); | |
| 190 | -} | |
| 191 | - | |
| 192 | -bool is_shape_suitable_rhs_nxk_x32p4vsx1bx32_x32_x32_sme( | |
| 193 | - [[maybe_unused]] size_t shape_m, size_t shape_n, size_t shape_k, const MatrixPortion& portion) { | |
| 194 | - return is_shape_suitable_rhs_uker_api( | |
| 195 | - shape_n, shape_k, portion, kai_matmul_pack_rhs_nxk_x32p4vsx1bx32_x32_x32_sme()); | |
| 196 | -} | |
| 197 | - | |
| 198 | -bool is_shape_suitable_rhs_nxk_x8p4vsx4_x8_sme( | |
| 199 | - [[maybe_unused]] size_t shape_m, size_t shape_n, size_t shape_k, const MatrixPortion& portion) { | |
| 200 | - return is_shape_suitable_rhs_uker_api(shape_n, shape_k, portion, kai_matmul_pack_rhs_nxk_x8p4vsx4_x8_sme()); | |
| 201 | -} | |
| 202 | - | |
| 203 | -bool is_shape_suitable_rhs_kxn_x8p4vsx4_x8_sme( | |
| 204 | - [[maybe_unused]] size_t shape_m, size_t shape_n, size_t shape_k, const MatrixPortion& portion) { | |
| 205 | - return is_shape_suitable_rhs_uker_api(shape_n, shape_k, portion, kai_matmul_pack_rhs_kxn_x8p4vsx4_x8_sme()); | |
| 206 | -} | |
| 207 | -} // namespace kai::test |
deleted test/nextgen/operators/matmul/pack_rhs/matmul_pack_rhs_wrapper.hpp +0 −67
| @@ -1,67 +0,0 @@ | ||
| 1 | -// | |
| 2 | -// SPDX-FileCopyrightText: Copyright 2025-2026 Arm Limited and/or its affiliates <open-source-office@arm.com> | |
| 3 | -// | |
| 4 | -// SPDX-License-Identifier: Apache-2.0 | |
| 5 | -// | |
| 6 | - | |
| 7 | -#pragma once | |
| 8 | - | |
| 9 | -#include <memory> | |
| 10 | - | |
| 11 | -#include "test/common/matrix_portion.hpp" | |
| 12 | -#include "test/nextgen/harness/kernel_wrapper.hpp" | |
| 13 | -#include "test/nextgen/operators/matmul/matmul_dims.hpp" | |
| 14 | - | |
| 15 | -namespace kai::test { | |
| 16 | - | |
| 17 | -/// Creates a wrapper for kai_rhs_pack_nxk_qsi4cxps1s0_qsu4cxs1s0_neon kernel. | |
| 18 | -[[nodiscard]] std::unique_ptr<KernelWrapper<MatShape>> create_matmul_rhs_pack_nxk_qsi4cxp4vlx4s1s0_qsu4cxs1s0_neon(); | |
| 19 | - | |
| 20 | -/// Creates a wrapper for kai_rhs_pack_kxn_f32p2vlx1biasf32_f32_f32_sme kernel. | |
| 21 | -[[nodiscard]] std::unique_ptr<KernelWrapper<MatShape>> create_matmul_rhs_pack_kxn_f32p2vlx1biasf32_f32_f32_sme(); | |
| 22 | - | |
| 23 | -/// Creates a wrapper for kai_matmul_pack_rhs_kxn_x32p4vsx1bx32_x32_x32_sme kernel. | |
| 24 | -[[nodiscard]] std::unique_ptr<KernelWrapper<MatShape>> create_matmul_pack_rhs_kxn_x32p4vsx1bx32_x32_x32_sme(); | |
| 25 | - | |
| 26 | -/// Creates a wrapper for kai_matmul_pack_rhs_nxk_x32p4vsx1bx32_x32_x32_sme kernel. | |
| 27 | -[[nodiscard]] std::unique_ptr<KernelWrapper<MatShape>> create_matmul_pack_rhs_nxk_x32p4vsx1bx32_x32_x32_sme(); | |
| 28 | - | |
| 29 | -/// Creates a wrapper for kai_matmul_pack_rhs_nxk_x8p4vsx4_x8_sme kernel. | |
| 30 | -[[nodiscard]] std::unique_ptr<KernelWrapper<MatShape>> create_matmul_pack_rhs_nxk_x8p4vsx4_x8_sme(); | |
| 31 | - | |
| 32 | -/// Creates a wrapper for kai_matmul_pack_rhs_kxn_x8p4vsx4_x8_sme kernel. | |
| 33 | -[[nodiscard]] std::unique_ptr<KernelWrapper<MatShape>> create_matmul_pack_rhs_kxn_x8p4vsx4_x8_sme(); | |
| 34 | - | |
| 35 | -/// Checks if the portion produces non-empty RHS packing tiles for the x32p4vsx1 KxN matmul operator. | |
| 36 | -[[nodiscard]] bool is_shape_suitable_rhs_kxn_x32p4vsx1bx32_x32_x32_sme( | |
| 37 | - size_t shape_m, size_t shape_n, size_t shape_k, const MatrixPortion& portion); | |
| 38 | - | |
| 39 | -/// Checks if the portion produces non-empty RHS packing tiles for the x32p4vsx1 NxK matmul operator. | |
| 40 | -[[nodiscard]] bool is_shape_suitable_rhs_nxk_x32p4vsx1bx32_x32_x32_sme( | |
| 41 | - size_t shape_m, size_t shape_n, size_t shape_k, const MatrixPortion& portion); | |
| 42 | - | |
| 43 | -/// Checks if the portion produces non-empty RHS packing tiles for the x8p4vsx4 NxK matmul operator. | |
| 44 | -[[nodiscard]] bool is_shape_suitable_rhs_nxk_x8p4vsx4_x8_sme( | |
| 45 | - size_t shape_m, size_t shape_n, size_t shape_k, const MatrixPortion& portion); | |
| 46 | - | |
| 47 | -/// Checks if the portion produces non-empty RHS packing tiles for the x8p4vsx4 KxN matmul operator. | |
| 48 | -[[nodiscard]] bool is_shape_suitable_rhs_kxn_x8p4vsx4_x8_sme( | |
| 49 | - size_t shape_m, size_t shape_n, size_t shape_k, const MatrixPortion& portion); | |
| 50 | - | |
| 51 | -/// Checks if the portion produces non-empty RHS packing tiles for the qai8dxp1vlx8/qsi4cxp4vlx8 matmul operator. | |
| 52 | -[[nodiscard]] bool is_shape_suitable_rhs_qai8dxp1vlx8_qsi4cxp4vlx8_1vlx4vl_sme2_mopa( | |
| 53 | - size_t shape_m, size_t shape_n, size_t shape_k, const MatrixPortion& portion); | |
| 54 | - | |
| 55 | -/// Checks if the portion produces non-empty RHS packing tiles for the qai8dxp1vlx8/qsi4cxp4vlx8 matmul operator. | |
| 56 | -[[nodiscard]] bool is_shape_suitable_rhs_qai8dxp1vlx4_qsi4cxp4vlx4_1vlx4vl_sme_mopa( | |
| 57 | - size_t shape_m, size_t shape_n, size_t shape_k, const MatrixPortion& portion); | |
| 58 | - | |
| 59 | -/// Checks if the portion produces non-empty RHS packing tiles for the qai8dxp1x4/qsi4cxp4vlx4 matmul operator. | |
| 60 | -[[nodiscard]] bool is_shape_suitable_rhs_qai8dxp1x4_qsi4cxp4vlx4_1x4vl_sme2_sdot( | |
| 61 | - size_t shape_m, size_t shape_n, size_t shape_k, const MatrixPortion& portion); | |
| 62 | - | |
| 63 | -/// Checks if the portion produces non-empty RHS packing tiles for the f32p2vlx1 matmul operator. | |
| 64 | -[[nodiscard]] bool is_shape_suitable_rhs_f32p2vlx1_f32p2vlx1biasf32_sme2_mopa( | |
| 65 | - size_t shape_m, size_t shape_n, size_t shape_k, const MatrixPortion& portion); | |
| 66 | - | |
| 67 | -} // namespace kai::test |
added test/nextgen/operators/matmul/pack_rhs/matmul_pack_rhs_wrapper_registry.cpp +207 −0
| @@ -0,0 +1,207 @@ | ||
| 1 | +// | |
| 2 | +// SPDX-FileCopyrightText: Copyright 2025-2026 Arm Limited and/or its affiliates <open-source-office@arm.com> | |
| 3 | +// | |
| 4 | +// SPDX-License-Identifier: Apache-2.0 | |
| 5 | +// | |
| 6 | + | |
| 7 | +#include "test/nextgen/operators/matmul/pack_rhs/matmul_pack_rhs_wrapper_registry.hpp" | |
| 8 | + | |
| 9 | +#include <array> | |
| 10 | +#include <memory> | |
| 11 | + | |
| 12 | +#include "kai/ukernels/matmul/kai_matmul_pack_rhs.h" | |
| 13 | +#include "kai/ukernels/matmul/matmul_clamp_f32_qai8dxp_qsi4cxp/kai_matmul_clamp_f32_qai8dxp1vlx4_qsi4cxp4vlx4_1vlx4vl_sme_mopa.h" | |
| 14 | +#include "kai/ukernels/matmul/matmul_clamp_f32_qai8dxp_qsi4cxp/kai_matmul_clamp_f32_qai8dxp1vlx8_qsi4cxp4vlx8_1vlx4vl_sme2_mopa.h" | |
| 15 | +#include "kai/ukernels/matmul/matmul_clamp_f32_qai8dxp_qsi4cxp/kai_matmul_clamp_f32_qai8dxp1x4_qsi4cxp4vlx4_1x4vl_sme2_sdot.h" | |
| 16 | +#include "kai/ukernels/matmul/pack/kai_rhs_pack_kxn_f32p2vlx1biasf32_f32_f32_sme.h" | |
| 17 | +#include "kai/ukernels/matmul/pack/kai_rhs_pack_nxk_qsi4cxps1s0_qsu4cxs1s0_neon.h" | |
| 18 | +#include "test/common/data_type.hpp" | |
| 19 | +#include "test/common/sme.hpp" | |
| 20 | +#include "test/nextgen/common/poly.hpp" | |
| 21 | +#include "test/nextgen/format/block2d_row_format.hpp" | |
| 22 | +#include "test/nextgen/format/plain_format.hpp" | |
| 23 | +#include "test/nextgen/harness/kernel_wrapper.hpp" | |
| 24 | +#include "test/nextgen/operators/matmul/pack_rhs/matmul_pack_rhs_fp_nt_wrapper.hpp" | |
| 25 | +#include "test/nextgen/operators/matmul/pack_rhs/matmul_pack_rhs_interface.hpp" | |
| 26 | +#include "test/nextgen/operators/matmul/pack_rhs/matmul_pack_rhs_quant_wrapper.hpp" | |
| 27 | +#include "test/nextgen/operators/matmul/pack_rhs/matmul_pack_rhs_ukerapi_t_wrapper.hpp" | |
| 28 | +#include "test/nextgen/operators/matmul/pack_rhs/matmul_pack_rhs_ukerapi_wrapper.hpp" | |
| 29 | + | |
| 30 | +namespace kai::test { | |
| 31 | + | |
| 32 | +namespace { | |
| 33 | + | |
| 34 | +bool portion_non_empty( | |
| 35 | + size_t full_height, size_t full_width, size_t scheduler_block_height, size_t scheduler_block_width, | |
| 36 | + const MatrixPortion& portion) { | |
| 37 | + const Rect rect = portion.compute_portion(full_height, full_width, scheduler_block_height, scheduler_block_width); | |
| 38 | + return rect.height() > 0 && rect.width() > 0; | |
| 39 | +} | |
| 40 | + | |
| 41 | +bool is_shape_suitable_rhs_uker_api( | |
| 42 | + size_t shape_n, size_t shape_k, const MatrixPortion& portion, const kai_matmul_pack_rhs_uker_api& api) { | |
| 43 | + if (shape_n == 0 || shape_k == 0) { | |
| 44 | + return false; | |
| 45 | + } | |
| 46 | + | |
| 47 | + const kai_matmul_pack_rhs_uker_config config = {}; | |
| 48 | + | |
| 49 | + const kai_matmul_pack_rhs_uker_dim_args step = api.get_step(&config); | |
| 50 | + | |
| 51 | + const size_t block_n = (step.n == 0) ? shape_n : step.n; | |
| 52 | + const size_t block_k = (step.k == 0) ? shape_k : step.k; | |
| 53 | + | |
| 54 | + return portion_non_empty(shape_n, shape_k, block_n, block_k, portion); | |
| 55 | +} | |
| 56 | + | |
| 57 | +/// Creates a placeholder format used to explicitly indicate that bias is unused. | |
| 58 | +Poly<Format> unused_bias_format() { | |
| 59 | + return make_poly<PlainFormat>(DataType::UNKNOWN); | |
| 60 | +} | |
| 61 | + | |
| 62 | +} // namespace | |
| 63 | + | |
| 64 | +std::unique_ptr<KernelWrapper<MatShape>> create_matmul_rhs_pack_nxk_qsi4cxp4vlx4s1s0_qsu4cxs1s0_neon() { | |
| 65 | + return std::make_unique<MatMulPackRhsQuantWrapper>( | |
| 66 | + "matmul_rhs_pack_nxk_qsi4cxps1s0_qsu4cxs1s0_neon", | |
| 67 | + MatMulPackRhsQuantInterface{ | |
| 68 | + kai_get_n_step_rhs_pack_nxk_qsi4cxps1s0_qsu4cxs1s0_neon, | |
| 69 | + kai_get_rhs_offset_rhs_pack_nxk_qsi4cxps1s0_qsu4cxs1s0_neon, | |
| 70 | + kai_get_rhs_packed_stride_rhs_pack_nxk_qsi4cxps1s0_qsu4cxs1s0_neon, | |
| 71 | + kai_get_rhs_packed_offset_rhs_pack_nxk_qsi4cxps1s0_qsu4cxs1s0_neon, | |
| 72 | + kai_get_rhs_packed_size_rhs_pack_nxk_qsi4cxps1s0_qsu4cxs1s0_neon, | |
| 73 | + kai_run_rhs_pack_nxk_qsi4cxps1s0_qsu4cxs1s0_neon, | |
| 74 | + }, | |
| 75 | + make_poly<PlainFormat>(DataType::U4), make_poly<PlainFormat>(DataType::FP32), | |
| 76 | + make_poly<PlainFormat>(DataType::FP32), make_poly<PlainFormat>(DataType::I32), | |
| 77 | + make_poly<Block2dRowFormat>( | |
| 78 | + 4 * get_sme_vector_length<float>(), 4, 32, false, DataType::I4, std::array<DataType, 0>{}, | |
| 79 | + std::array{DataType::I32, DataType::FP32, DataType::FP32})); | |
| 80 | +} | |
| 81 | + | |
| 82 | +std::unique_ptr<KernelWrapper<MatShape>> create_matmul_rhs_pack_kxn_f32p2vlx1biasf32_f32_f32_sme() { | |
| 83 | + return std::make_unique<MatMulPackRhsFpNtWrapper>( | |
| 84 | + "matmul_rhs_pack_kxn_f32p2vlx1biasf32_f32_f32_sme", | |
| 85 | + MatMulPackRhsFpInterface{ | |
| 86 | + kai_get_n_step_rhs_pack_kxn_f32p2vlx1biasf32_f32_f32_sme, | |
| 87 | + kai_get_rhs_offset_rhs_pack_kxn_f32p2vlx1biasf32_f32_f32_sme, | |
| 88 | + kai_get_bias_offset_rhs_pack_kxn_f32p2vlx1biasf32_f32_f32_sme, | |
| 89 | + kai_get_rhs_packed_stride_rhs_pack_kxn_f32p2vlx1biasf32_f32_f32_sme, | |
| 90 | + kai_get_rhs_packed_offset_rhs_pack_kxn_f32p2vlx1biasf32_f32_f32_sme, | |
| 91 | + kai_get_rhs_packed_size_rhs_pack_kxn_f32p2vlx1biasf32_f32_f32_sme, | |
| 92 | + kai_run_rhs_pack_kxn_f32p2vlx1biasf32_f32_f32_sme, | |
| 93 | + }, | |
| 94 | + make_poly<PlainFormat>(DataType::FP32), make_poly<PlainFormat>(DataType::FP32), | |
| 95 | + make_poly<Block2dRowFormat>( | |
| 96 | + 2 * get_sme_vector_length<float>(), 1, 1, false, DataType::FP32, std::array{DataType::FP32}, | |
| 97 | + std::array<DataType, 0>{})); | |
| 98 | +} | |
| 99 | + | |
| 100 | +std::unique_ptr<KernelWrapper<MatShape>> create_matmul_pack_rhs_kxn_x32p4vsx1bx32_x32_x32_sme() { | |
| 101 | + return std::make_unique<MatMulPackRhsUkerApiWrapper>( | |
| 102 | + "create_matmul_pack_rhs_kxn_x32p4vsx1bx32_x32_x32_sme", kai_matmul_pack_rhs_kxn_x32p4vsx1bx32_x32_x32_sme(), | |
| 103 | + make_poly<PlainFormat>(DataType::FP32), make_poly<PlainFormat>(DataType::FP32), | |
| 104 | + make_poly<Block2dRowFormat>( | |
| 105 | + 4 * get_sme_vector_scale(), 1, 1, false, DataType::FP32, std::array{DataType::FP32}, | |
| 106 | + std::array<DataType, 0>{}), | |
| 107 | + MatMulUkerApiBiasDeliveryStage::PACK_RHS); | |
| 108 | +} | |
| 109 | + | |
| 110 | +std::unique_ptr<KernelWrapper<MatShape>> create_matmul_pack_rhs_nxk_x32p4vsx1bx32_x32_x32_sme() { | |
| 111 | + return std::make_unique<MatMulPackRhsUkerApiTWrapper>( | |
| 112 | + "create_matmul_pack_rhs_nxk_x32p4vsx1bx32_x32_x32_sme", kai_matmul_pack_rhs_nxk_x32p4vsx1bx32_x32_x32_sme(), | |
| 113 | + make_poly<PlainFormat>(DataType::FP32), make_poly<PlainFormat>(DataType::FP32), | |
| 114 | + make_poly<Block2dRowFormat>( | |
| 115 | + 4 * get_sme_vector_scale(), 1, 1, false, DataType::FP32, std::array{DataType::FP32}, | |
| 116 | + std::array<DataType, 0>{}), | |
| 117 | + MatMulUkerApiBiasDeliveryStage::PACK_RHS); | |
| 118 | +} | |
| 119 | + | |
| 120 | +std::unique_ptr<KernelWrapper<MatShape>> create_matmul_pack_rhs_nxk_x8p4vsx4_x8_sme() { | |
| 121 | + return std::make_unique<MatMulPackRhsUkerApiTWrapper>( | |
| 122 | + "matmul_pack_rhs_nxk_x8p4vsx4_x8_sme", kai_matmul_pack_rhs_nxk_x8p4vsx4_x8_sme(), | |
| 123 | + make_poly<PlainFormat>(DataType::U8), unused_bias_format(), | |
| 124 | + make_poly<Block2dRowFormat>( | |
| 125 | + 4 * get_sme_vector_scale(), 4, 4, false, DataType::U8, std::array<DataType, 0>{}, | |
| 126 | + std::array<DataType, 0>{}), | |
| 127 | + MatMulUkerApiBiasDeliveryStage::MATMUL); | |
| 128 | +} | |
| 129 | + | |
| 130 | +std::unique_ptr<KernelWrapper<MatShape>> create_matmul_pack_rhs_kxn_x8p4vsx4_x8_sme() { | |
| 131 | + return std::make_unique<MatMulPackRhsUkerApiWrapper>( | |
| 132 | + "matmul_pack_rhs_kxn_x8p4vsx4_x8_sme", kai_matmul_pack_rhs_kxn_x8p4vsx4_x8_sme(), | |
| 133 | + make_poly<PlainFormat>(DataType::U8), unused_bias_format(), | |
| 134 | + make_poly<Block2dRowFormat>( | |
| 135 | + 4 * get_sme_vector_scale(), 4, 4, false, DataType::U8, std::array<DataType, 0>{}, | |
| 136 | + std::array<DataType, 0>{}), | |
| 137 | + MatMulUkerApiBiasDeliveryStage::MATMUL); | |
| 138 | +} | |
| 139 | + | |
| 140 | +bool is_shape_suitable_rhs_qai8dxp1vlx8_qsi4cxp4vlx8_1vlx4vl_sme2_mopa( | |
| 141 | + [[maybe_unused]] size_t shape_m, size_t shape_n, size_t shape_k, const MatrixPortion& portion) { | |
| 142 | + if (shape_n == 0 || shape_k == 0) { | |
| 143 | + return false; | |
| 144 | + } | |
| 145 | + | |
| 146 | + const size_t nr = kai_get_nr_matmul_clamp_f32_qai8dxp1vlx8_qsi4cxp4vlx8_1vlx4vl_sme2_mopa(); | |
| 147 | + const size_t rhs_n_step = kai_get_n_step_rhs_pack_nxk_qsi4cxps1s0_qsu4cxs1s0_neon(nr); | |
| 148 | + | |
| 149 | + return portion_non_empty(shape_n, shape_k, rhs_n_step, shape_k, portion); | |
| 150 | +} | |
| 151 | + | |
| 152 | +bool is_shape_suitable_rhs_qai8dxp1vlx4_qsi4cxp4vlx4_1vlx4vl_sme_mopa( | |
| 153 | + [[maybe_unused]] size_t shape_m, size_t shape_n, size_t shape_k, const MatrixPortion& portion) { | |
| 154 | + if (shape_n == 0 || shape_k == 0) { | |
| 155 | + return false; | |
| 156 | + } | |
| 157 | + | |
| 158 | + const size_t nr = kai_get_nr_matmul_clamp_f32_qai8dxp1vlx4_qsi4cxp4vlx4_1vlx4vl_sme_mopa(); | |
| 159 | + const size_t rhs_n_step = kai_get_n_step_rhs_pack_nxk_qsi4cxps1s0_qsu4cxs1s0_neon(nr); | |
| 160 | + | |
| 161 | + return portion_non_empty(shape_n, shape_k, rhs_n_step, shape_k, portion); | |
| 162 | +} | |
| 163 | + | |
| 164 | +bool is_shape_suitable_rhs_qai8dxp1x4_qsi4cxp4vlx4_1x4vl_sme2_sdot( | |
| 165 | + [[maybe_unused]] size_t shape_m, size_t shape_n, size_t shape_k, const MatrixPortion& portion) { | |
| 166 | + if (shape_n == 0 || shape_k == 0) { | |
| 167 | + return false; | |
| 168 | + } | |
| 169 | + | |
| 170 | + const size_t nr = kai_get_nr_matmul_clamp_f32_qai8dxp1x4_qsi4cxp4vlx4_1x4vl_sme2_sdot(); | |
| 171 | + const size_t rhs_n_step = kai_get_n_step_rhs_pack_nxk_qsi4cxps1s0_qsu4cxs1s0_neon(nr); | |
| 172 | + | |
| 173 | + return portion_non_empty(shape_n, shape_k, rhs_n_step, shape_k, portion); | |
| 174 | +} | |
| 175 | + | |
| 176 | +bool is_shape_suitable_rhs_f32p2vlx1_f32p2vlx1biasf32_sme2_mopa( | |
| 177 | + [[maybe_unused]] size_t shape_m, size_t shape_n, size_t shape_k, const MatrixPortion& portion) { | |
| 178 | + if (shape_n == 0 || shape_k == 0) { | |
| 179 | + return false; | |
| 180 | + } | |
| 181 | + | |
| 182 | + const size_t rhs_n_step = kai_get_n_step_rhs_pack_kxn_f32p2vlx1biasf32_f32_f32_sme(); | |
| 183 | + return portion_non_empty(shape_n, shape_k, rhs_n_step, shape_k, portion); | |
| 184 | +} | |
| 185 | + | |
| 186 | +bool is_shape_suitable_rhs_kxn_x32p4vsx1bx32_x32_x32_sme( | |
| 187 | + [[maybe_unused]] size_t shape_m, size_t shape_n, size_t shape_k, const MatrixPortion& portion) { | |
| 188 | + return is_shape_suitable_rhs_uker_api( | |
| 189 | + shape_n, shape_k, portion, kai_matmul_pack_rhs_kxn_x32p4vsx1bx32_x32_x32_sme()); | |
| 190 | +} | |
| 191 | + | |
| 192 | +bool is_shape_suitable_rhs_nxk_x32p4vsx1bx32_x32_x32_sme( | |
| 193 | + [[maybe_unused]] size_t shape_m, size_t shape_n, size_t shape_k, const MatrixPortion& portion) { | |
| 194 | + return is_shape_suitable_rhs_uker_api( | |
| 195 | + shape_n, shape_k, portion, kai_matmul_pack_rhs_nxk_x32p4vsx1bx32_x32_x32_sme()); | |
| 196 | +} | |
| 197 | + | |
| 198 | +bool is_shape_suitable_rhs_nxk_x8p4vsx4_x8_sme( | |
| 199 | + [[maybe_unused]] size_t shape_m, size_t shape_n, size_t shape_k, const MatrixPortion& portion) { | |
| 200 | + return is_shape_suitable_rhs_uker_api(shape_n, shape_k, portion, kai_matmul_pack_rhs_nxk_x8p4vsx4_x8_sme()); | |
| 201 | +} | |
| 202 | + | |
| 203 | +bool is_shape_suitable_rhs_kxn_x8p4vsx4_x8_sme( | |
| 204 | + [[maybe_unused]] size_t shape_m, size_t shape_n, size_t shape_k, const MatrixPortion& portion) { | |
| 205 | + return is_shape_suitable_rhs_uker_api(shape_n, shape_k, portion, kai_matmul_pack_rhs_kxn_x8p4vsx4_x8_sme()); | |
| 206 | +} | |
| 207 | +} // namespace kai::test |
added test/nextgen/operators/matmul/pack_rhs/matmul_pack_rhs_wrapper_registry.hpp +67 −0
| @@ -0,0 +1,67 @@ | ||
| 1 | +// | |
| 2 | +// SPDX-FileCopyrightText: Copyright 2025-2026 Arm Limited and/or its affiliates <open-source-office@arm.com> | |
| 3 | +// | |
| 4 | +// SPDX-License-Identifier: Apache-2.0 | |
| 5 | +// | |
| 6 | + | |
| 7 | +#pragma once | |
| 8 | + | |
| 9 | +#include <memory> | |
| 10 | + | |
| 11 | +#include "test/common/matrix_portion.hpp" | |
| 12 | +#include "test/nextgen/harness/kernel_wrapper.hpp" | |
| 13 | +#include "test/nextgen/operators/matmul/matmul_dims.hpp" | |
| 14 | + | |
| 15 | +namespace kai::test { | |
| 16 | + | |
| 17 | +/// Creates a wrapper for kai_rhs_pack_nxk_qsi4cxps1s0_qsu4cxs1s0_neon kernel. | |
| 18 | +[[nodiscard]] std::unique_ptr<KernelWrapper<MatShape>> create_matmul_rhs_pack_nxk_qsi4cxp4vlx4s1s0_qsu4cxs1s0_neon(); | |
| 19 | + | |
| 20 | +/// Creates a wrapper for kai_rhs_pack_kxn_f32p2vlx1biasf32_f32_f32_sme kernel. | |
| 21 | +[[nodiscard]] std::unique_ptr<KernelWrapper<MatShape>> create_matmul_rhs_pack_kxn_f32p2vlx1biasf32_f32_f32_sme(); | |
| 22 | + | |
| 23 | +/// Creates a wrapper for kai_matmul_pack_rhs_kxn_x32p4vsx1bx32_x32_x32_sme kernel. | |
| 24 | +[[nodiscard]] std::unique_ptr<KernelWrapper<MatShape>> create_matmul_pack_rhs_kxn_x32p4vsx1bx32_x32_x32_sme(); | |
| 25 | + | |
| 26 | +/// Creates a wrapper for kai_matmul_pack_rhs_nxk_x32p4vsx1bx32_x32_x32_sme kernel. | |
| 27 | +[[nodiscard]] std::unique_ptr<KernelWrapper<MatShape>> create_matmul_pack_rhs_nxk_x32p4vsx1bx32_x32_x32_sme(); | |
| 28 | + | |
| 29 | +/// Creates a wrapper for kai_matmul_pack_rhs_nxk_x8p4vsx4_x8_sme kernel. | |
| 30 | +[[nodiscard]] std::unique_ptr<KernelWrapper<MatShape>> create_matmul_pack_rhs_nxk_x8p4vsx4_x8_sme(); | |
| 31 | + | |
| 32 | +/// Creates a wrapper for kai_matmul_pack_rhs_kxn_x8p4vsx4_x8_sme kernel. | |
| 33 | +[[nodiscard]] std::unique_ptr<KernelWrapper<MatShape>> create_matmul_pack_rhs_kxn_x8p4vsx4_x8_sme(); | |
| 34 | + | |
| 35 | +/// Checks if the portion produces non-empty RHS packing tiles for the x32p4vsx1 KxN matmul operator. | |
| 36 | +[[nodiscard]] bool is_shape_suitable_rhs_kxn_x32p4vsx1bx32_x32_x32_sme( | |
| 37 | + size_t shape_m, size_t shape_n, size_t shape_k, const MatrixPortion& portion); | |
| 38 | + | |
| 39 | +/// Checks if the portion produces non-empty RHS packing tiles for the x32p4vsx1 NxK matmul operator. | |
| 40 | +[[nodiscard]] bool is_shape_suitable_rhs_nxk_x32p4vsx1bx32_x32_x32_sme( | |
| 41 | + size_t shape_m, size_t shape_n, size_t shape_k, const MatrixPortion& portion); | |
| 42 | + | |
| 43 | +/// Checks if the portion produces non-empty RHS packing tiles for the x8p4vsx4 NxK matmul operator. | |
| 44 | +[[nodiscard]] bool is_shape_suitable_rhs_nxk_x8p4vsx4_x8_sme( | |
| 45 | + size_t shape_m, size_t shape_n, size_t shape_k, const MatrixPortion& portion); | |
| 46 | + | |
| 47 | +/// Checks if the portion produces non-empty RHS packing tiles for the x8p4vsx4 KxN matmul operator. | |
| 48 | +[[nodiscard]] bool is_shape_suitable_rhs_kxn_x8p4vsx4_x8_sme( | |
| 49 | + size_t shape_m, size_t shape_n, size_t shape_k, const MatrixPortion& portion); | |
| 50 | + | |
| 51 | +/// Checks if the portion produces non-empty RHS packing tiles for the qai8dxp1vlx8/qsi4cxp4vlx8 matmul operator. | |
| 52 | +[[nodiscard]] bool is_shape_suitable_rhs_qai8dxp1vlx8_qsi4cxp4vlx8_1vlx4vl_sme2_mopa( | |
| 53 | + size_t shape_m, size_t shape_n, size_t shape_k, const MatrixPortion& portion); | |
| 54 | + | |
| 55 | +/// Checks if the portion produces non-empty RHS packing tiles for the qai8dxp1vlx8/qsi4cxp4vlx8 matmul operator. | |
| 56 | +[[nodiscard]] bool is_shape_suitable_rhs_qai8dxp1vlx4_qsi4cxp4vlx4_1vlx4vl_sme_mopa( | |
| 57 | + size_t shape_m, size_t shape_n, size_t shape_k, const MatrixPortion& portion); | |
| 58 | + | |
| 59 | +/// Checks if the portion produces non-empty RHS packing tiles for the qai8dxp1x4/qsi4cxp4vlx4 matmul operator. | |
| 60 | +[[nodiscard]] bool is_shape_suitable_rhs_qai8dxp1x4_qsi4cxp4vlx4_1x4vl_sme2_sdot( | |
| 61 | + size_t shape_m, size_t shape_n, size_t shape_k, const MatrixPortion& portion); | |
| 62 | + | |
| 63 | +/// Checks if the portion produces non-empty RHS packing tiles for the f32p2vlx1 matmul operator. | |
| 64 | +[[nodiscard]] bool is_shape_suitable_rhs_f32p2vlx1_f32p2vlx1biasf32_sme2_mopa( | |
| 65 | + size_t shape_m, size_t shape_n, size_t shape_k, const MatrixPortion& portion); | |
| 66 | + | |
| 67 | +} // namespace kai::test |