ONE - On-device Neural Engine
Loading...
Searching...
No Matches
Driver.cpp File Reference
#include <circlechef/RecipeChef.h>
#include <arser/arser.h>
#include <foder/FileLoader.h>
#include <memory>
#include <iostream>

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 25 of file Driver.cpp.

26{
28 arser.add_argument("circle").help("Source circle file path to convert");
29 arser.add_argument("recipe").help("Target recipe file path");
30
31 try
32 {
33 arser.parse(argc, argv);
34 }
35 catch (const std::runtime_error &err)
36 {
37 std::cout << err.what() << std::endl;
38 std::cout << arser;
39 return 255;
40 }
41
42 std::string circle_path = arser.get<std::string>("circle");
43 // Load TF lite model from a circle file
44 const foder::FileLoader fileLoader{circle_path};
45 std::vector<char> modelData = fileLoader.load();
46 const circle::Model *circlemodel = circle::GetModel(modelData.data());
47 if (circlemodel == nullptr)
48 {
49 std::cerr << "ERROR: Failed to load circle '" << circle_path << "'" << std::endl;
50 return 255;
51 }
52
53 // Generate ModelRecipe recipe
54 std::unique_ptr<circlechef::ModelRecipe> recipe = circlechef::generate_recipe(circlemodel);
55 if (recipe.get() == nullptr)
56 {
57 std::cerr << "ERROR: Failed to generate recipe" << std::endl;
58 return 255;
59 }
60
61 std::string recipe_path = arser.get<std::string>("recipe");
62 // Save to a file
63 bool result = circlechef::write_recipe(recipe_path, recipe);
64 if (!result)
65 {
66 std::cerr << "ERROR: Failed to write to recipe '" << recipe_path << "'" << std::endl;
67 return 255;
68 }
69 return 0;
70}
DataBuffer load(void) const
Definition FileLoader.h:39
Definition arser.h:39
std::unique_ptr< ModelRecipe > generate_recipe(const circle::Model *model)
Create ModelRecipe from circle::Model.
bool write_recipe(const std::string &filename, std::unique_ptr< ModelRecipe > &recipe)
Write ModelRecipe to file with given name.
result
Definition infer.py:103

References circlechef::generate_recipe(), foder::FileLoader::load(), and circlechef::write_recipe().