ONE - On-device Neural Engine
Loading...
Searching...
No Matches
Driver.cpp File Reference
#include <ONNXImporterImpl.h>
#include <mir2loco.h>
#include <exo/TFLExporter.h>
#include <iostream>

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 52 of file Driver.cpp.

53{
54 // onnx2tflite <mode> <path/to/onnx> <path/to/output>
55 // modes: -t (text file); -b (binary file)
56 if (argc != 4)
57 {
58 printHelp();
59 exit(1);
60 }
61 std::string mode{argv[1]};
62 std::string onnx_path{argv[2]};
63 std::string tflite_path{argv[3]};
64
65 std::cout << "Import " << quote(onnx_path) << std::endl;
66 std::unique_ptr<mir::Graph> mir_graph;
67 if (mode == "-t")
68 mir_graph = mir_onnx::importModelFromTextFile(onnx_path);
69 else if (mode == "-b")
70 mir_graph = mir_onnx::importModelFromBinaryFile(onnx_path);
71 else
72 {
73 printHelp();
74 exit(1);
75 }
76 std::cout << "Import " << quote(onnx_path) << " - Done" << std::endl;
77
78 auto loco_graph = transform(mir_graph);
79
80 exo::TFLExporter(loco_graph.get()).dumpToFile(tflite_path.c_str());
81
82 return 0;
83}
void dumpToFile(const char *path) const
write to a file
std::unique_ptr< mir::Graph > importModelFromTextFile(const std::string &filename)
std::unique_ptr< mir::Graph > importModelFromBinaryFile(const std::string &filename)

References exo::TFLExporter::dumpToFile(), mir_onnx::importModelFromBinaryFile(), and mir_onnx::importModelFromTextFile().