SiCongLi | 282f324 | 2020-11-24 15:24:16 +0000 | [diff] [blame] | 1 | /* |
Gian Marco Iodice | 60ab4e6 | 2023-04-28 10:40:07 +0100 | [diff] [blame] | 2 | * Copyright (c) 2020-2021, 2023 Arm Limited. |
SiCongLi | 282f324 | 2020-11-24 15:24:16 +0000 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: MIT |
| 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | * of this software and associated documentation files (the "Software"), to |
| 8 | * deal in the Software without restriction, including without limitation the |
| 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
| 10 | * sell copies of the Software, and to permit persons to whom the Software is |
| 11 | * furnished to do so, subject to the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice shall be included in all |
| 14 | * copies or substantial portions of the Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 22 | * SOFTWARE. |
| 23 | */ |
| 24 | #ifndef ARM_COMPUTE_CL /* Needed by Utils.cpp to handle OpenCL exceptions properly */ |
| 25 | #error "This example needs to be built with -DARM_COMPUTE_CL" |
| 26 | #endif /* ARM_COMPUTE_CL */ |
| 27 | |
| 28 | #include "arm_compute/core/Helpers.h" |
| 29 | #include "arm_compute/core/KernelDescriptors.h" |
| 30 | #include "arm_compute/core/Types.h" |
| 31 | #include "arm_compute/core/utils/misc/ShapeCalculator.h" |
| 32 | #include "arm_compute/runtime/CL/CLScheduler.h" |
| 33 | #include "arm_compute/runtime/CL/CLTuner.h" |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 34 | |
SiCongLi | 282f324 | 2020-11-24 15:24:16 +0000 | [diff] [blame] | 35 | #include "examples/gemm_tuner/CommonGemmExampleOptions.h" |
| 36 | #include "examples/gemm_tuner/GemmTunerHelpers.h" |
Georgios Pinitas | 7891a73 | 2021-08-20 21:39:25 +0100 | [diff] [blame] | 37 | #include "src/gpu/cl/kernels/ClGemmLowpMatrixMultiplyReshapedKernel.h" |
| 38 | #include "src/gpu/cl/kernels/ClGemmReshapeLhsMatrixKernel.h" |
SiCongLi | 282f324 | 2020-11-24 15:24:16 +0000 | [diff] [blame] | 39 | #include "tests/CL/Helper.h" |
SiCongLi | 282f324 | 2020-11-24 15:24:16 +0000 | [diff] [blame] | 40 | #include "utils/command_line/CommandLineOptions.h" |
| 41 | #include "utils/command_line/CommandLineParser.h" |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 42 | #include "utils/Utils.h" |
SiCongLi | 282f324 | 2020-11-24 15:24:16 +0000 | [diff] [blame] | 43 | |
| 44 | #include <cstdlib> |
| 45 | |
| 46 | using namespace arm_compute; |
Georgios Pinitas | 856f66e | 2021-04-22 21:13:21 +0100 | [diff] [blame] | 47 | using namespace arm_compute::opencl::kernels; |
SiCongLi | 282f324 | 2020-11-24 15:24:16 +0000 | [diff] [blame] | 48 | using namespace utils; |
| 49 | using namespace arm_compute::misc::shape_calculator; |
| 50 | using namespace gemm_tuner; |
| 51 | |
| 52 | namespace |
| 53 | { |
| 54 | /** Structure holding all tunable gemm configs specific to this example/strategy */ |
| 55 | struct GemmConfigs |
| 56 | { |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 57 | size_t m0{4}; /**< Number of rows processed by the matrix multiplication */ |
| 58 | size_t n0{4}; /**< Number of columns processed by the matrix multiplication */ |
| 59 | size_t k0{4}; /**< Number of partial accumulations performed by the matrix multiplication */ |
| 60 | size_t v0{1}; /**< Number of vertical blocks of size (m0xk0) stored on the same output row */ |
| 61 | size_t h0{1}; /**< Number of horizontal blocks of size (k0xn0) stored on the same output row */ |
| 62 | bool interleave_lhs{true}; /**< Interleave lhs matrix */ |
| 63 | bool transpose_lhs{true}; /**< Transpose lhs matrix. */ |
| 64 | bool interleave_rhs{true}; /**< Interleave rhs matrix */ |
| 65 | bool transpose_rhs{true}; /**< Transpose rhs matrix. */ |
SiCongLi | 282f324 | 2020-11-24 15:24:16 +0000 | [diff] [blame] | 66 | }; |
| 67 | |
| 68 | /** Formatted output of the GemmConfigs type |
| 69 | * |
| 70 | * @param[out] os Output stream. |
| 71 | * @param[in] configs Tunable configurations to output |
| 72 | * |
| 73 | * @return Modified output stream. |
| 74 | */ |
| 75 | ::std::ostream &operator<<(::std::ostream &os, const GemmConfigs &configs) |
| 76 | { |
| 77 | std::string false_str = std::string("false"); |
| 78 | std::string true_str = std::string("true"); |
| 79 | |
| 80 | os << "m0 : " << configs.m0 << std::endl; |
| 81 | os << "n0 : " << configs.n0 << std::endl; |
| 82 | os << "k0 : " << configs.k0 << std::endl; |
| 83 | os << "v0 : " << configs.v0 << std::endl; |
| 84 | os << "h0 : " << configs.h0 << std::endl; |
| 85 | os << "interleave_lhs : " << (configs.interleave_lhs ? true_str : false_str) << std::endl; |
| 86 | os << "transpose_lhs : " << (configs.transpose_lhs ? true_str : false_str) << std::endl; |
| 87 | os << "interleave_rhs : " << (configs.interleave_rhs ? true_str : false_str) << std::endl; |
| 88 | os << "transpose_rhs : " << (configs.transpose_rhs ? true_str : false_str) << std::endl; |
| 89 | return os; |
| 90 | } |
| 91 | |
| 92 | /** Command line options for gemm configs */ |
| 93 | class GemmConfigOptions |
| 94 | { |
| 95 | public: |
| 96 | /** Constructor |
| 97 | * |
| 98 | * @param[in,out] parser A parser on which "parse()" hasn't been called yet. |
| 99 | */ |
| 100 | GemmConfigOptions(CommandLineParser &parser) |
| 101 | : m0(parser.add_positional_option<SimpleOption<size_t>>("m0", 4)), |
| 102 | n0(parser.add_positional_option<SimpleOption<size_t>>("n0", 4)), |
| 103 | k0(parser.add_positional_option<SimpleOption<size_t>>("k0", 4)), |
| 104 | v0(parser.add_positional_option<SimpleOption<size_t>>("v0", 1)), |
| 105 | h0(parser.add_positional_option<SimpleOption<size_t>>("h0", 1)), |
| 106 | interleave_lhs(parser.add_positional_option<SimpleOption<size_t>>("interleave_lhs", 1)), |
| 107 | interleave_rhs(parser.add_positional_option<SimpleOption<size_t>>("interleave_rhs", 1)), |
| 108 | transpose_rhs(parser.add_positional_option<SimpleOption<size_t>>("transpose_rhs", 1)) |
| 109 | { |
| 110 | m0->set_help("Number of rows processed by the matrix multiplication"); |
| 111 | n0->set_help("Number of columns processed by the matrix multiplication"); |
| 112 | k0->set_help("Number of partial accumulations performed by the matrix multiplication"); |
| 113 | v0->set_help("Number of vertical blocks of size (m0xk0) stored on the same output row"); |
| 114 | h0->set_help("Number of horizontal blocks of size (k0xn0) stored on the same output row"); |
| 115 | interleave_lhs->set_help("Interleave lhs matrix (1) / Do not interleave lhs matrix (0)"); |
| 116 | interleave_rhs->set_help("Interleave rhs matrix (1) / Do not interleave rhs matrix (0)"); |
| 117 | // FIXME: Currently we only support 2 variants of the gemm reshaped kernels in which transpose_lhs and |
| 118 | // transpose_rhs are the opposites of each other. In the future we may extend the kernels to include the other |
| 119 | // 2 variants (both transposed and none transposed) |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 120 | transpose_rhs->set_help("Transpose rhs matrix but not lhs matrix (1) / Do not transpose rhs matrix but do " |
| 121 | "transpose lhs matrix (0)"); |
SiCongLi | 282f324 | 2020-11-24 15:24:16 +0000 | [diff] [blame] | 122 | } |
| 123 | /** Prevent instances of this class from being copied (As this class contains pointers) */ |
| 124 | GemmConfigOptions(const GemmConfigOptions &) = delete; |
| 125 | /** Prevent instances of this class from being copied (As this class contains pointers) */ |
| 126 | GemmConfigOptions &operator=(const GemmConfigOptions &) = delete; |
| 127 | /** Allow instances of this class to be moved */ |
| 128 | GemmConfigOptions(GemmConfigOptions &&) = default; |
| 129 | /** Allow instances of this class to be moved */ |
| 130 | GemmConfigOptions &operator=(GemmConfigOptions &&) = default; |
| 131 | /** Default destructor */ |
| 132 | ~GemmConfigOptions() = default; |
| 133 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 134 | SimpleOption<size_t> *m0; /**< Number of rows processed by the matrix multiplication option */ |
| 135 | SimpleOption<size_t> *n0; /**< Number of columns processed by the matrix multiplication option */ |
| 136 | SimpleOption<size_t> *k0; /**< Number of partial accumulations performed by the matrix multiplication option */ |
| 137 | SimpleOption<size_t> *v0; /**< Number of vertical blocks of size (m0xk0) stored on the same output row option */ |
| 138 | SimpleOption<size_t> *h0; /**< Number of horizontal blocks of size (k0xn0) stored on the same output row option */ |
SiCongLi | 282f324 | 2020-11-24 15:24:16 +0000 | [diff] [blame] | 139 | SimpleOption<size_t> *interleave_lhs; /**< Interleave lhs matrix option (1 enable; 0 disable) */ |
| 140 | SimpleOption<size_t> *interleave_rhs; /**< Interleave rhs matrix option (1 enable; 0 disable) */ |
| 141 | // FIXME: Currently we only support 2 variants of the gemm reshaped kernels in which transpose_lhs and |
| 142 | // transpose_rhs are the opposites of each other. In the future we may extend the kernels to include the other |
| 143 | // 2 variants (both transposed and none transposed) |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 144 | SimpleOption<size_t> * |
| 145 | transpose_rhs; /**< Transpose rhs matrix option (1 enable; 0 disable). Also set the lhs matrix transpose option to the opposite. */ |
SiCongLi | 282f324 | 2020-11-24 15:24:16 +0000 | [diff] [blame] | 146 | }; |
| 147 | |
| 148 | /** Consumes the gemm configuration options and creates a structure containing all information |
| 149 | * |
| 150 | * @param[in] options Options to consume |
| 151 | * |
| 152 | * @return Structure containing the gemm configurations |
| 153 | */ |
| 154 | GemmConfigs consume_gemm_configs(const GemmConfigOptions &options) |
| 155 | { |
| 156 | GemmConfigs configs; |
| 157 | configs.m0 = options.m0->value(); |
| 158 | configs.n0 = options.n0->value(); |
| 159 | configs.k0 = options.k0->value(); |
| 160 | configs.v0 = options.v0->value(); |
| 161 | configs.h0 = options.h0->value(); |
| 162 | configs.interleave_lhs = options.interleave_lhs->value() != 0; |
| 163 | // FIXME: Currently we only support 2 variants of the gemm reshaped kernels in which transpose_lhs and |
| 164 | // transpose_rhs are the opposites of each other. In the future we may extend the kernels to include the other |
| 165 | // 2 variants (both transposed and none transposed) |
| 166 | configs.transpose_lhs = options.transpose_rhs->value() == 0; |
| 167 | configs.interleave_rhs = options.interleave_rhs->value() != 0; |
| 168 | configs.transpose_rhs = options.transpose_rhs->value() != 0; |
| 169 | return configs; |
| 170 | } |
| 171 | |
| 172 | } // namespace |
| 173 | |
Georgios Pinitas | 4a578b9 | 2021-06-25 12:13:49 +0100 | [diff] [blame] | 174 | using ClGemmReshapeLHSMatrix = test::CLSynthetizeOperator<ClGemmReshapeLhsMatrixKernel>; |
| 175 | using ClGemmLowpMatrixMultiplyReshaped = test::CLSynthetizeOperator<ClGemmLowpMatrixMultiplyReshapedKernel>; |
SiCongLi | 282f324 | 2020-11-24 15:24:16 +0000 | [diff] [blame] | 176 | |
| 177 | class CLGEMMLowpMatrixMultiplyReshapedExample : public Example |
| 178 | { |
| 179 | public: |
| 180 | bool do_setup(int argc, char **argv) override |
| 181 | { |
| 182 | // Default parameters |
| 183 | CommonGemmExampleParams params; |
| 184 | GemmConfigs configs; |
| 185 | |
| 186 | // Parse command line options |
| 187 | CommandLineParser parser; |
SiCong Li | 98e33b9 | 2020-12-03 14:52:53 +0000 | [diff] [blame] | 188 | CommonGemmExampleOptions param_options(parser, DataType::QASYMM8); |
SiCongLi | 282f324 | 2020-11-24 15:24:16 +0000 | [diff] [blame] | 189 | GemmConfigOptions config_options(parser); |
| 190 | |
| 191 | parser.parse(argc, argv); |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 192 | if (param_options.help->is_set() && param_options.help->value()) |
SiCongLi | 282f324 | 2020-11-24 15:24:16 +0000 | [diff] [blame] | 193 | { |
| 194 | parser.print_help(argv[0]); |
| 195 | return false; |
| 196 | } |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 197 | if (!parser.validate()) |
SiCongLi | 282f324 | 2020-11-24 15:24:16 +0000 | [diff] [blame] | 198 | { |
| 199 | // Invalid arguments. Use default parameters and configs |
| 200 | std::cerr << "Invalid arguments." << std::endl; |
| 201 | parser.print_help(argv[0]); |
| 202 | std::cerr << "Falling back to default parameters and configs" << std::endl; |
| 203 | } |
| 204 | else |
| 205 | { |
| 206 | params = consume_common_gemm_example_parameters(param_options); |
| 207 | configs = consume_gemm_configs(config_options); |
| 208 | } |
| 209 | |
| 210 | std::cout << "Gemm parameters:" << std::endl; |
| 211 | std::cout << params << std::endl; |
| 212 | std::cout << "Gemm configurations:" << std::endl; |
| 213 | std::cout << configs << std::endl; |
| 214 | |
Gian Marco Iodice | ca419dd | 2021-03-03 17:25:07 +0000 | [diff] [blame] | 215 | tuner.set_tuner_mode(params.tuner_mode); |
| 216 | |
SiCongLi | 282f324 | 2020-11-24 15:24:16 +0000 | [diff] [blame] | 217 | CLScheduler::get().default_init(&tuner); |
| 218 | |
| 219 | lhs.allocator()->init(TensorInfo(TensorShape(params.K, params.M, params.B), 1, params.data_type)); |
| 220 | rhs.allocator()->init(TensorInfo(TensorShape(params.N, params.K, params.B), 1, params.data_type)); |
| 221 | |
| 222 | // Set arbitrary quantization information |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 223 | const QuantizationInfo q_info{0.012, 3}; |
SiCong Li | 98e33b9 | 2020-12-03 14:52:53 +0000 | [diff] [blame] | 224 | lhs.info()->set_quantization_info(q_info); |
| 225 | rhs.info()->set_quantization_info(q_info); |
| 226 | dst.info()->set_quantization_info(q_info); |
SiCongLi | 282f324 | 2020-11-24 15:24:16 +0000 | [diff] [blame] | 227 | |
| 228 | GEMMLHSMatrixInfo lhs_info; |
| 229 | lhs_info.m0 = configs.m0; |
| 230 | lhs_info.k0 = configs.k0; |
| 231 | lhs_info.v0 = configs.v0; |
| 232 | lhs_info.interleave = configs.interleave_lhs; |
| 233 | lhs_info.transpose = configs.transpose_lhs; |
| 234 | |
| 235 | GEMMRHSMatrixInfo rhs_info; |
| 236 | rhs_info.n0 = configs.n0; |
| 237 | rhs_info.k0 = configs.k0; |
| 238 | rhs_info.h0 = configs.h0; |
| 239 | rhs_info.interleave = configs.interleave_rhs; |
| 240 | rhs_info.transpose = configs.transpose_rhs; |
| 241 | rhs_info.export_to_cl_image = false; // CL image not supported for quantized cases yet |
| 242 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 243 | if (rhs_info.h0 == 0) |
Gian Marco Iodice | 60ab4e6 | 2023-04-28 10:40:07 +0100 | [diff] [blame] | 244 | { |
| 245 | rhs_info.h0 = std::max(static_cast<unsigned int>(params.N) / rhs_info.n0, 1U); |
| 246 | } |
| 247 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 248 | lhs_reshaped.allocator()->init( |
| 249 | TensorInfo(compute_lhs_reshaped_shape(*lhs.info(), lhs_info), 1, params.data_type)); |
| 250 | rhs_reshaped.allocator()->init( |
| 251 | TensorInfo(compute_rhs_reshaped_shape(*rhs.info(), rhs_info), 1, params.data_type)); |
SiCong Li | 98e33b9 | 2020-12-03 14:52:53 +0000 | [diff] [blame] | 252 | lhs_reshaped.info()->set_quantization_info(q_info); |
| 253 | rhs_reshaped.info()->set_quantization_info(q_info); |
SiCongLi | 282f324 | 2020-11-24 15:24:16 +0000 | [diff] [blame] | 254 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 255 | if (rhs_info.export_to_cl_image) |
SiCongLi | 282f324 | 2020-11-24 15:24:16 +0000 | [diff] [blame] | 256 | { |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 257 | if (!examples::gemm_tuner_helpers::update_padding_for_cl_image(rhs_reshaped.info())) |
Manuel Bottini | 7b42786 | 2021-02-08 13:45:19 +0000 | [diff] [blame] | 258 | { |
| 259 | std::cerr << "cl_image is not supported on the device, disable export_to_cl_image" << std::endl; |
| 260 | return false; |
| 261 | } |
SiCongLi | 282f324 | 2020-11-24 15:24:16 +0000 | [diff] [blame] | 262 | } |
| 263 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 264 | GEMMReshapeInfo gemm_info{static_cast<int>(params.M), |
| 265 | static_cast<int>(params.N), |
| 266 | static_cast<int>(params.K), |
| 267 | static_cast<int>(configs.h0), |
| 268 | static_cast<int>(configs.v0), |
| 269 | 0, |
| 270 | false, |
| 271 | true}; |
SiCongLi | 282f324 | 2020-11-24 15:24:16 +0000 | [diff] [blame] | 272 | |
| 273 | // Validate argments |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 274 | if (!reshape_lhs.validate(lhs.info(), lhs_reshaped.info(), lhs_info, gemm_info.reinterpret_input_as_3d())) |
SiCongLi | 282f324 | 2020-11-24 15:24:16 +0000 | [diff] [blame] | 275 | { |
Georgios Pinitas | 4a578b9 | 2021-06-25 12:13:49 +0100 | [diff] [blame] | 276 | std::cerr << "Invalid arguments for ClGemmReshapeLHSMatrixKernel." << std::endl; |
SiCongLi | 282f324 | 2020-11-24 15:24:16 +0000 | [diff] [blame] | 277 | return false; |
| 278 | } |
| 279 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 280 | if (!gemm.validate(lhs_reshaped.info(), rhs_reshaped.info(), dst.info(), lhs_info, rhs_info, gemm_info)) |
SiCongLi | 282f324 | 2020-11-24 15:24:16 +0000 | [diff] [blame] | 281 | { |
Georgios Pinitas | 4a578b9 | 2021-06-25 12:13:49 +0100 | [diff] [blame] | 282 | std::cerr << "Invalid arguments for ClGemmLowpMatrixMultiplyReshapedKernel." << std::endl; |
SiCongLi | 282f324 | 2020-11-24 15:24:16 +0000 | [diff] [blame] | 283 | return false; |
| 284 | } |
| 285 | |
| 286 | // Configure functions |
Georgios Pinitas | 856f66e | 2021-04-22 21:13:21 +0100 | [diff] [blame] | 287 | reshape_lhs.configure(lhs.info(), lhs_reshaped.info(), lhs_info); |
SiCongLi | 282f324 | 2020-11-24 15:24:16 +0000 | [diff] [blame] | 288 | |
Georgios Pinitas | 4a578b9 | 2021-06-25 12:13:49 +0100 | [diff] [blame] | 289 | gemm.configure(lhs_reshaped.info(), rhs_reshaped.info(), dst.info(), lhs_info, rhs_info, gemm_info); |
SiCongLi | 282f324 | 2020-11-24 15:24:16 +0000 | [diff] [blame] | 290 | |
| 291 | // Allocate tensors |
| 292 | lhs.allocator()->allocate(); |
| 293 | rhs.allocator()->allocate(); |
| 294 | lhs_reshaped.allocator()->allocate(); |
| 295 | rhs_reshaped.allocator()->allocate(); |
| 296 | dst.allocator()->allocate(); |
| 297 | |
| 298 | return true; |
| 299 | } |
| 300 | void do_run() override |
| 301 | { |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 302 | ITensorPack reshape_lsh_pack({{ACL_SRC, &lhs}, {ACL_DST, &lhs_reshaped}}); |
Georgios Pinitas | 856f66e | 2021-04-22 21:13:21 +0100 | [diff] [blame] | 303 | reshape_lhs.run(reshape_lsh_pack); |
| 304 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 305 | ITensorPack gemm_pack({{ACL_SRC_0, &lhs_reshaped}, {ACL_SRC_1, &rhs_reshaped}, {ACL_DST, &dst}}); |
Georgios Pinitas | 4a578b9 | 2021-06-25 12:13:49 +0100 | [diff] [blame] | 306 | gemm.run(gemm_pack); |
SiCongLi | 282f324 | 2020-11-24 15:24:16 +0000 | [diff] [blame] | 307 | |
| 308 | // Make sure all the OpenCL jobs are done executing: |
| 309 | CLScheduler::get().sync(); |
| 310 | } |
| 311 | |
| 312 | void do_teardown() override |
| 313 | { |
| 314 | } |
| 315 | |
| 316 | private: |
| 317 | CLTensor lhs{}; |
| 318 | CLTensor rhs{}; |
| 319 | CLTensor lhs_reshaped{}; |
| 320 | CLTensor rhs_reshaped{}; |
| 321 | CLTensor dst{}; |
| 322 | CLTuner tuner{}; |
Georgios Pinitas | 4a578b9 | 2021-06-25 12:13:49 +0100 | [diff] [blame] | 323 | ClGemmReshapeLHSMatrix reshape_lhs{}; |
| 324 | ClGemmLowpMatrixMultiplyReshaped gemm{}; |
SiCongLi | 282f324 | 2020-11-24 15:24:16 +0000 | [diff] [blame] | 325 | }; |
| 326 | |
| 327 | /** Main test program for gemmlowp reshaped |
| 328 | * |
| 329 | * @param[in] argc Number of arguments |
| 330 | * @param[in] argv Arguments ( [optional] M, [optional] N, [optional] K, [optional] B, [optional] m0, [optional] n0, [optional] k0, [optional] v0, [optional] h0, [optional] interleave_lhs, [optional] interleave_rhs, [optional] transpose_rhs ) |
| 331 | */ |
| 332 | int main(int argc, char **argv) |
| 333 | { |
| 334 | return run_example<CLGEMMLowpMatrixMultiplyReshapedExample>(argc, argv); |
| 335 | } |