ONE - On-device Neural Engine
Loading...
Searching...
No Matches
Driver.cpp File Reference
#include "Dump.h"
#include <arser/arser.h>
#include <foder/FileLoader.h>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <string>
#include <vector>

Go to the source code of this file.

Functions

int entry (int argc, char **argv)
 

Function Documentation

◆ entry()

int entry ( int  argc,
char **  argv 
)

Definition at line 29 of file Driver.cpp.

30{
32 "circle-tensordump allows users to retrieve tensor information from a Circle model file"};
33
34 arser.add_argument("circle").help("Circle file path to dump");
35 arser.add_argument("--tensors").nargs(0).help("Dump to console");
36 arser.add_argument("--tensors_to_hdf5")
37 .help("Dump to hdf5 file. Specify hdf5 file path to be dumped");
38
39 try
40 {
41 arser.parse(argc, argv);
42 }
43 catch (const std::runtime_error &err)
44 {
45 std::cout << err.what() << std::endl;
46 std::cout << arser;
47 return 255;
48 }
49
50 if (arser["--tensors_to_hdf5"] == arser["--tensors"])
51 {
52 std::cout << "[Error] You must specify one option for how to print." << std::endl;
53 std::cout << arser;
54 return 255;
55 }
56
57 std::unique_ptr<circletensordump::DumpInterface> dump;
58
59 std::string model_file = arser.get<std::string>("circle");
60 std::string output_path;
61 if (arser["--tensors_to_hdf5"])
62 {
63 dump = std::move(std::make_unique<circletensordump::DumpTensorsToHdf5>());
64 output_path = arser.get<std::string>("--tensors_to_hdf5");
65 }
66 if (arser["--tensors"])
67 {
68 dump = std::move(std::make_unique<circletensordump::DumpTensors>());
69 }
70
71 // Load Circle model from a circle file
72 foder::FileLoader fileLoader{model_file};
73 std::vector<char> modelData = fileLoader.load();
74 const circle::Model *circleModel = circle::GetModel(modelData.data());
75 if (circleModel == nullptr)
76 {
77 std::cerr << "ERROR: Failed to load circle '" << model_file << "'" << std::endl;
78 return EXIT_FAILURE;
79 }
80
81 dump->run(std::cout, circleModel, output_path);
82
83 return EXIT_SUCCESS;
84}
DataBuffer load(void) const
Definition FileLoader.h:39
void dump(const coco::Op *op, int indent)
Definition Dump.cpp:177
Definition arser.h:39

References dump(), and foder::FileLoader::load().