• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2019-2020 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 #include "CommonGemmExampleOptions.h"
25 
26 namespace gemm_tuner
27 {
28 using namespace arm_compute;
29 using namespace utils;
30 
operator <<(::std::ostream & os,const CommonGemmExampleParams & common_params)31 ::std::ostream &operator<<(::std::ostream &os, const CommonGemmExampleParams &common_params)
32 {
33     os << "M : " << common_params.M << std::endl;
34     os << "N : " << common_params.N << std::endl;
35     os << "K : " << common_params.K << std::endl;
36     os << "B : " << common_params.B << std::endl;
37     os << "Data type : " << common_params.data_type << std::endl;
38     return os;
39 }
40 
CommonGemmExampleOptions(CommandLineParser & parser)41 CommonGemmExampleOptions::CommonGemmExampleOptions(CommandLineParser &parser)
42     : help(parser.add_option<ToggleOption>("help")),
43       M(parser.add_positional_option<SimpleOption<size_t>>("M", 100)),
44       N(parser.add_positional_option<SimpleOption<size_t>>("N", 100)),
45       K(parser.add_positional_option<SimpleOption<size_t>>("K", 50)),
46       B(parser.add_positional_option<SimpleOption<size_t>>("B", 1)),
47       data_type()
48 {
49     const std::set<DataType> supported_data_types
50     {
51         DataType::F16,
52         DataType::F32,
53     };
54 
55     data_type = parser.add_option<EnumOption<DataType>>("type", supported_data_types, DataType::F32);
56 
57     help->set_help("Show this help message.");
58     M->set_help("Number of lhs matrix rows.");
59     N->set_help("Number of rhs matrix columns.");
60     K->set_help("Number of lhs matrix columns/rhs matrix rows.");
61     B->set_help("Batch size.");
62     data_type->set_help("Data type to use");
63 }
64 
consume_common_gemm_example_parameters(const CommonGemmExampleOptions & options)65 CommonGemmExampleParams consume_common_gemm_example_parameters(const CommonGemmExampleOptions &options)
66 {
67     CommonGemmExampleParams common_params;
68     common_params.M         = options.M->value();
69     common_params.N         = options.N->value();
70     common_params.K         = options.K->value();
71     common_params.B         = options.B->value();
72     common_params.data_type = options.data_type->value();
73     return common_params;
74 }
75 } // namespace gemm_tuner
76