4bc3e6c622fa8a00cf3d532db59fc669f2916ee5
[platform/core/ml/nnfw.git] / tests / tools / nnpackage_run / src / args.h
1 /*
2  * Copyright (c) 2019 Samsung Electronics Co., Ltd. All Rights Reserved
3  *
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
7  *
8  *    http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 #ifndef __NNPACKAGE_RUN_ARGS_H__
18 #define __NNPACKAGE_RUN_ARGS_H__
19
20 #include <string>
21 #include <unordered_map>
22 #include <vector>
23 #include <boost/program_options.hpp>
24
25 namespace po = boost::program_options;
26
27 namespace nnpkg_run
28 {
29
30 using TensorShapeMap = std::unordered_map<uint32_t, std::vector<int>>;
31
32 class Args
33 {
34 public:
35   Args(const int argc, char **argv);
36   void print(void);
37
38   const std::string &getPackageFilename(void) const { return _package_filename; }
39 #if defined(ONERT_HAVE_HDF5) && ONERT_HAVE_HDF5 == 1
40   const std::string &getDumpFilename(void) const { return _dump_filename; }
41   const std::string &getLoadFilename(void) const { return _load_filename; }
42 #endif
43   const int getNumRuns(void) const { return _num_runs; }
44   const int getWarmupRuns(void) const { return _warmup_runs; }
45   const int getRunDelay(void) const { return _run_delay; }
46   std::unordered_map<uint32_t, uint32_t> getOutputSizes(void) const { return _output_sizes; }
47   const bool getGpuMemoryPoll(void) const { return _gpumem_poll; }
48   const bool getMemoryPoll(void) const { return _mem_poll; }
49   const bool getWriteReport(void) const { return _write_report; }
50   const bool printVersion(void) const { return _print_version; }
51   const TensorShapeMap &getShapeMapForPrepare() { return _shape_prepare; }
52   const TensorShapeMap &getShapeMapForRun() { return _shape_run; }
53   const int getVerboseLevel(void) const { return _verbose_level; }
54
55 private:
56   void Initialize();
57   void Parse(const int argc, char **argv);
58
59 private:
60   po::positional_options_description _positional;
61   po::options_description _options;
62
63   std::string _package_filename;
64 #if defined(ONERT_HAVE_HDF5) && ONERT_HAVE_HDF5 == 1
65   std::string _dump_filename;
66   std::string _load_filename;
67 #endif
68   TensorShapeMap _shape_prepare;
69   TensorShapeMap _shape_run;
70   int _num_runs;
71   int _warmup_runs;
72   int _run_delay;
73   std::unordered_map<uint32_t, uint32_t> _output_sizes;
74   bool _gpumem_poll;
75   bool _mem_poll;
76   bool _write_report;
77   bool _print_version = false;
78   int _verbose_level;
79 };
80
81 } // end of namespace nnpkg_run
82
83 #endif // __NNPACKAGE_RUN_ARGS_H__