SiCong Li | 240b79d | 2019-09-24 15:50:34 +0100 | [diff] [blame] | 1 | /* |
Gian Marco Iodice | ca419dd | 2021-03-03 17:25:07 +0000 | [diff] [blame] | 2 | * Copyright (c) 2019-2021 Arm Limited. |
SiCong Li | 240b79d | 2019-09-24 15:50:34 +0100 | [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_EXAMPLES_GEMM_TUNER_COMMON_GEMM_EXAMPLE_OPTIONS |
| 25 | #define ARM_COMPUTE_EXAMPLES_GEMM_TUNER_COMMON_GEMM_EXAMPLE_OPTIONS |
| 26 | |
Eren Kopuz | 350099e | 2020-06-09 15:37:43 +0100 | [diff] [blame] | 27 | #include "arm_compute/core/Types.h" |
SiCong Li | e357a25 | 2020-08-09 20:05:52 +0100 | [diff] [blame] | 28 | #include "arm_compute/core/Utils.h" |
Gian Marco Iodice | ca419dd | 2021-03-03 17:25:07 +0000 | [diff] [blame] | 29 | #include "arm_compute/runtime/CL/CLTuner.h" |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 30 | |
SiCong Li | 240b79d | 2019-09-24 15:50:34 +0100 | [diff] [blame] | 31 | #include "utils/command_line/CommandLineOptions.h" |
| 32 | #include "utils/command_line/CommandLineParser.h" |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 33 | #include "utils/TypePrinter.h" |
SiCong Li | 240b79d | 2019-09-24 15:50:34 +0100 | [diff] [blame] | 34 | |
| 35 | namespace gemm_tuner |
| 36 | { |
| 37 | /** Structure holding all the common gemm example parameters */ |
| 38 | struct CommonGemmExampleParams |
| 39 | { |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 40 | size_t M{100}; /**< Number of lhs matrix rows */ |
| 41 | size_t N{100}; /**< Number of rhs matrix columns */ |
| 42 | size_t K{50}; /**< Number of lhs matrix columns/rhs matrix rows */ |
| 43 | size_t B{1}; /**< Batch size */ |
| 44 | arm_compute::DataType data_type{arm_compute::DataType::F32}; /**< Data type */ |
| 45 | arm_compute::CLTunerMode tuner_mode{arm_compute::CLTunerMode::RAPID}; /**< OpenCL tuner mode */ |
SiCong Li | 240b79d | 2019-09-24 15:50:34 +0100 | [diff] [blame] | 46 | }; |
| 47 | |
| 48 | /** Formatted output of the CommonGemmExampleParams type |
| 49 | * |
| 50 | * @param[out] os Output stream. |
| 51 | * @param[in] common_params Common parameters to output |
| 52 | * |
| 53 | * @return Modified output stream. |
| 54 | */ |
| 55 | ::std::ostream &operator<<(::std::ostream &os, const CommonGemmExampleParams &common_params); |
| 56 | |
| 57 | /** Common command line options used to configure the gemm examples |
| 58 | * |
| 59 | * The options in this object get populated when "parse()" is called on the parser used to construct it. |
| 60 | * The expected workflow is: |
| 61 | * |
| 62 | * CommandLineParser parser; |
| 63 | * CommonOptions options( parser ); |
| 64 | * parser.parse(argc, argv); |
| 65 | */ |
| 66 | class CommonGemmExampleOptions |
| 67 | { |
| 68 | public: |
| 69 | /** Constructor |
| 70 | * |
SiCong Li | 98e33b9 | 2020-12-03 14:52:53 +0000 | [diff] [blame] | 71 | * @param[in,out] parser A parser on which "parse()" hasn't been called yet. |
| 72 | * @param[in] default_data_type Default data type if unspecified. |
SiCong Li | 240b79d | 2019-09-24 15:50:34 +0100 | [diff] [blame] | 73 | */ |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 74 | CommonGemmExampleOptions(arm_compute::utils::CommandLineParser &parser, |
| 75 | arm_compute::DataType default_data_type = arm_compute::DataType::F32); |
SiCong Li | 240b79d | 2019-09-24 15:50:34 +0100 | [diff] [blame] | 76 | /** Prevent instances of this class from being copied (As this class contains pointers) */ |
| 77 | CommonGemmExampleOptions(const CommonGemmExampleOptions &) = delete; |
| 78 | /** Prevent instances of this class from being copied (As this class contains pointers) */ |
| 79 | CommonGemmExampleOptions &operator=(const CommonGemmExampleOptions &) = delete; |
| 80 | /** Allow instances of this class to be moved */ |
| 81 | CommonGemmExampleOptions(CommonGemmExampleOptions &&) = default; |
| 82 | /** Allow instances of this class to be moved */ |
| 83 | CommonGemmExampleOptions &operator=(CommonGemmExampleOptions &&) = default; |
| 84 | /** Default destructor */ |
| 85 | ~CommonGemmExampleOptions() = default; |
| 86 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 87 | arm_compute::utils::ToggleOption *help; /**< Show help option */ |
| 88 | arm_compute::utils::SimpleOption<size_t> *M; /**< Number of lhs matrix rows option */ |
| 89 | arm_compute::utils::SimpleOption<size_t> *N; /**< Number of rhs matrix columns option */ |
| 90 | arm_compute::utils::SimpleOption<size_t> *K; /**< Number of lhs matrix columns/rhs matrix rows option */ |
| 91 | arm_compute::utils::SimpleOption<size_t> *B; /**< Batch size option */ |
Gian Marco Iodice | ca419dd | 2021-03-03 17:25:07 +0000 | [diff] [blame] | 92 | arm_compute::utils::EnumOption<arm_compute::DataType> *data_type; /**< Data type */ |
| 93 | arm_compute::utils::EnumOption<arm_compute::CLTunerMode> *tuner_mode; /**< OpenCL tuner mode */ |
SiCong Li | 240b79d | 2019-09-24 15:50:34 +0100 | [diff] [blame] | 94 | }; |
| 95 | |
| 96 | /** Consumes the common gemm example options and creates a structure containing all information |
| 97 | * |
| 98 | * @param[in] options Options to consume |
| 99 | * |
| 100 | * @return Structure containing the common gemm example parameters |
| 101 | */ |
| 102 | CommonGemmExampleParams consume_common_gemm_example_parameters(const CommonGemmExampleOptions &options); |
| 103 | } // namespace gemm_tuner |
| 104 | #endif /* ARM_COMPUTE_EXAMPLES_GEMM_TUNER_COMMON_GEMM_EXAMPLE_OPTIONS */ |