ONE - On-device Neural Engine
Loading...
Searching...
No Matches
Driver.cpp File Reference
#include "Dalgona.h"
#include <arser/arser.h>
#include <pybind11/embed.h>

Go to the source code of this file.

Functions

int entry (const int argc, char **argv)
 

Function Documentation

◆ entry()

int entry ( const int  argc,
char **  argv 
)

HDF5 layout is like below

GROUP "/" ㄴGROUP "name" ㄴATTRIBUTE "0" ㄴDATA (0): "input_01:0" ㄴATTRIBUTE "1" ㄴDATA (0): "input_02:0" ㄴGROUP "value" ㄴDATASET "0" ㄴDATA ... ㄴDATASET "1" ㄴDATA ...

Definition at line 26 of file Driver.cpp.

27{
28 arser::Arser arser("Dalgona: Dynamic analysis tool for DNN");
29
30 arser.add_argument("--input_model")
31 .nargs(1)
32 .type(arser::DataType::STR)
33 .required(true)
34 .help("Input model filepath (.circle)");
35
36 arser.add_argument("--input_data")
37 .nargs(1)
38 .type(arser::DataType::STR)
39 .help("Input data filepath (.h5) (if not given, random data will be used)");
40
41 arser.add_argument("--analysis")
42 .nargs(1)
43 .type(arser::DataType::STR)
44 .required(true)
45 .help("Analysis code filepath (.py)");
46
47 arser.add_argument("--analysis_args")
48 .nargs(1)
49 .type(arser::DataType::STR)
50 .help("String argument passed to the analysis code");
51
52 try
53 {
54 arser.parse(argc, argv);
55 }
56 catch (const std::runtime_error &err)
57 {
58 std::cout << err.what() << std::endl;
59 std::cout << arser;
60 return EXIT_FAILURE;
61 }
62
63 auto input_model_path = arser.get<std::string>("--input_model");
64 auto analysis_path = arser.get<std::string>("--analysis");
65 std::string analysis_args = "";
66 if (arser["--analysis_args"])
67 analysis_args = arser.get<std::string>("--analysis_args");
68
69 // Initialize python interpreter
70 py::scoped_interpreter guard{};
71
73
74 // Initialize interpreter and operator hooks
75 dalgona.initialize(input_model_path);
76
77 // Run analysis
78 if (arser["--input_data"])
79 {
80 const auto input_data_path = arser.get<std::string>("--input_data");
81 dalgona.runAnalysisWithH5Input(input_data_path, analysis_path, analysis_args);
82 }
83 else
84 {
85 std::cout << "--input_data was not specified. Run with a random input." << std::endl;
86 dalgona.runAnalysisWithRandomInput(analysis_path, analysis_args);
87 }
88
89 return EXIT_SUCCESS;
90}
Definition arser.h:39