2 * Copyright (c) 2019 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.
21 #include <boost/filesystem.hpp>
26 Args::Args(const int argc, char **argv) noexcept
32 void Args::Initialize(void)
35 po::options_description general("General options");
39 ("help,h", "Display available options")
40 ("tflite", po::value<std::string>()->default_value("")->required(), "Input tflite model file for serialization")
41 ("data,d", po::value<std::vector<std::string>>()->multitoken()->default_value(std::vector<std::string>{}, ""), "Input data file for model");
44 _options.add(general);
45 _positional.add("tflite", 1);
48 void Args::print(char **argv)
50 std::cout << "tflite_loader" << std::endl << std::endl;
51 std::cout << "Load tflite model by Loader and TFLite and compare their output" << std::endl;
52 std::cout << "Usage:" << std::endl;
53 std::cout << argv[0] << " --tflite model_file.tflite --data input_data.dat" << std::endl;
54 std::cout << _options;
55 std::cout << std::endl;
58 void Args::Parse(const int argc, char **argv)
61 po::store(po::command_line_parser(argc, argv).options(_options).positional(_positional).run(),
74 if (vm.count("tflite"))
76 _tflite_filename = vm["tflite"].as<std::string>();
81 _data_filenames = vm["data"].as<std::vector<std::string>>();
84 catch (const std::bad_cast &e)
86 std::cerr << e.what() << '\n';
92 } // end of namespace TFLiteRun