ONE - On-device Neural Engine
Loading...
Searching...
No Matches
onnx2circle.cpp File Reference
#include "exo/LoggingContext.h"
#include "exo/CircleExporter.h"
#include "mir2loco.h"
#include "ONNXImporterImpl.h"
#include "locop/FormattedGraph.h"
#include "hermes/ConsoleReporter.h"
#include "hermes/EnvConfig.h"
#include <cassert>
#include <memory>
#include <iostream>
#include <stdexcept>
#include <string>

Go to the source code of this file.

Macros

#define LOGGER(name)    ::Logger name { ::LoggingContext::get() }
 
#define INFO(name)   HERMES_INFO(name)
 

Functions

int main (int argc, char **argv)
 

Macro Definition Documentation

◆ INFO

#define INFO (   name)    HERMES_INFO(name)

Definition at line 75 of file onnx2circle.cpp.

◆ LOGGER

#define LOGGER (   name)     ::Logger name { ::LoggingContext::get() }

Definition at line 72 of file onnx2circle.cpp.

73 { ::LoggingContext::get() }

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 77 of file onnx2circle.cpp.

78{
80
81 // This line allows users to control all the exo-circle loggers via ONNX2CIRCLE_Log_Backend
82 exo::LoggingContext::get()->config(std::make_unique<EnvConfig>("ONNX2CIRCLE_Log_Backend"));
83
84 LOGGER(l);
85
86 // TODO We need better args parsing in future
87 if (!(argc == 3))
88 {
89 print_help();
90 return 255;
91 }
92
93 std::string onnx_path{argv[1]}; // .pb file
94 std::string circle_path{argv[2]};
95
96 std::cout << "Import from '" << onnx_path << "'" << std::endl;
97 auto mir_g = mir_onnx::loadModel(onnx_path);
98 auto loco_g = mir2loco::Transformer().transform(mir_g.get());
99 std::cout << "Import from '" << onnx_path << "' - Done" << std::endl;
100
101 INFO(l) << "Import Graph" << std::endl;
102 INFO(l) << locop::fmt<locop::Formatter::LinearV1>(loco_g) << std::endl;
103
104 std::cout << "Export into '" << circle_path << "'" << std::endl;
105 exo::CircleExporter(loco_g.get()).dumpToFile(circle_path.c_str());
106 std::cout << "Export into '" << circle_path << "' - Done" << std::endl;
107
108 return 0;
109}
void dumpToFile(const char *path) const
write to a file
const Config * config(void) const
Get the global configuration.
Definition Context.cpp:24
std::unique_ptr< loco::Graph > transform(mir::Graph *mir_graph)
Definition mir2loco.cpp:710
std::unique_ptr< mir::Graph > loadModel(const std::string &filename)
#define LOGGER(name)
#define INFO(name)
static hermes::Context * get(void)

References hermes::Context::config(), exo::CircleExporter::dumpToFile(), exo::LoggingContext::get(), INFO, mir_onnx::loadModel(), LOGGER, and mir2loco::Transformer::transform().