blob: 5f079abfc1f96060909484732190d9e354ca2953 [file] [log] [blame]
SiCong Li240b79d2019-09-24 15:50:34 +01001/*
2 * Copyright (c) 2019 ARM Limited.
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
27#include "utils/command_line/CommandLineOptions.h"
28#include "utils/command_line/CommandLineParser.h"
29
30namespace gemm_tuner
31{
32/** Structure holding all the common gemm example parameters */
33struct CommonGemmExampleParams
34{
35 size_t M{ 100 }; /**< Number of lhs matrix rows */
36 size_t N{ 100 }; /**< Number of rhs matrix columns */
37 size_t K{ 50 }; /**< Number of lhs matrix columns/rhs matrix rows */
38 size_t B{ 1 }; /**< Batch size */
39};
40
41/** Formatted output of the CommonGemmExampleParams type
42 *
43 * @param[out] os Output stream.
44 * @param[in] common_params Common parameters to output
45 *
46 * @return Modified output stream.
47 */
48::std::ostream &operator<<(::std::ostream &os, const CommonGemmExampleParams &common_params);
49
50/** Common command line options used to configure the gemm examples
51 *
52 * The options in this object get populated when "parse()" is called on the parser used to construct it.
53 * The expected workflow is:
54 *
55 * CommandLineParser parser;
56 * CommonOptions options( parser );
57 * parser.parse(argc, argv);
58 */
59class CommonGemmExampleOptions
60{
61public:
62 /** Constructor
63 *
64 * @param[in,out] parser A parser on which "parse()" hasn't been called yet.
65 */
66 CommonGemmExampleOptions(arm_compute::utils::CommandLineParser &parser);
67 /** Prevent instances of this class from being copied (As this class contains pointers) */
68 CommonGemmExampleOptions(const CommonGemmExampleOptions &) = delete;
69 /** Prevent instances of this class from being copied (As this class contains pointers) */
70 CommonGemmExampleOptions &operator=(const CommonGemmExampleOptions &) = delete;
71 /** Allow instances of this class to be moved */
72 CommonGemmExampleOptions(CommonGemmExampleOptions &&) = default;
73 /** Allow instances of this class to be moved */
74 CommonGemmExampleOptions &operator=(CommonGemmExampleOptions &&) = default;
75 /** Default destructor */
76 ~CommonGemmExampleOptions() = default;
77
78 arm_compute::utils::ToggleOption *help; /**< Show help option */
79 arm_compute::utils::SimpleOption<size_t> *M; /**< Number of lhs matrix rows option */
80 arm_compute::utils::SimpleOption<size_t> *N; /**< Number of rhs matrix columns option */
81 arm_compute::utils::SimpleOption<size_t> *K; /**< Number of lhs matrix columns/rhs matrix rows option */
82 arm_compute::utils::SimpleOption<size_t> *B; /**< Batch size option */
83};
84
85/** Consumes the common gemm example options and creates a structure containing all information
86 *
87 * @param[in] options Options to consume
88 *
89 * @return Structure containing the common gemm example parameters
90 */
91CommonGemmExampleParams consume_common_gemm_example_parameters(const CommonGemmExampleOptions &options);
92} // namespace gemm_tuner
93#endif /* ARM_COMPUTE_EXAMPLES_GEMM_TUNER_COMMON_GEMM_EXAMPLE_OPTIONS */