2 * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
24 Args::Args(const int argc, char **argv)
31 catch (const std::exception &e)
33 std::cerr << "The argments that cannot be parsed: " << e.what() << '\n';
39 void Args::print(char **argv)
41 std::cout << "nnapi_test\n\n";
42 std::cout << "Usage: " << argv[0] << " <.tflite> [<options>]\n\n";
43 std::cout << _options;
47 void Args::Initialize(void)
50 po::options_description general("General options", 100);
54 ("help,h", "Print available options")
55 ("tflite", po::value<std::string>()->required())
56 ("seed", po::value<int>()->default_value(0), "The seed of random inputs")
57 ("num_runs", po::value<int>()->default_value(2), "The number of runs")
61 _options.add(general);
62 _positional.add("tflite", 1);
63 _positional.add("seed", 2);
66 void Args::Parse(const int argc, char **argv)
69 po::store(po::command_line_parser(argc, argv).options(_options).positional(_positional).run(),
80 if (vm.count("tflite"))
82 _tflite_filename = vm["tflite"].as<std::string>();
84 if (_tflite_filename.empty())
86 std::cerr << "Please specify tflite file.\n";
92 if (access(_tflite_filename.c_str(), F_OK) == -1)
94 std::cerr << "tflite file not found: " << _tflite_filename << "\n";
100 if (vm.count("seed"))
102 _seed = vm["seed"].as<int>();
105 if (vm.count("num_runs"))
107 _num_runs = vm["num_runs"].as<int>();
110 std::cerr << "num_runs value must be greater than 0.\n";
116 } // end of namespace nnapi_test