ONE - On-device Neural Engine
Loading...
Searching...
No Matches
Driver.cpp File Reference
#include <tflchef/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)
 Dump IR for given arguments.
 

Function Documentation

◆ entry()

int entry ( int  argc,
char **  argv 
)

Dump IR for given arguments.

Call example: $ ./build/compiler/encodump/encodump \ –frontend build/compiler/enco/frontend/caffe/libenco_caffe_frontend.so \ –frontend-arg build/compiler/enco/test/caffe/Convolution_003.prototxt \ –frontend-arg build/compiler/enco/test/caffe/Convolution_003.caffemodel

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

26{
28 arser.add_argument("tflite").help("Source tflite 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 tflite_path = arser.get<std::string>("tflite");
43 // Load TF lite model from a tflite file
44 const foder::FileLoader fileLoader{tflite_path};
45 std::vector<char> modelData = fileLoader.load();
46 const tflite::Model *tflmodel = tflite::GetModel(modelData.data());
47 if (tflmodel == nullptr)
48 {
49 std::cerr << "ERROR: Failed to load tflite '" << tflite_path << "'" << std::endl;
50 return 255;
51 }
52
53 // Generate ModelRecipe recipe
54 std::unique_ptr<tflchef::ModelRecipe> recipe = tflchef::generate_recipe(tflmodel);
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 = tflchef::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
result
Definition infer.py:103
bool write_recipe(const std::string &filename, std::unique_ptr< ModelRecipe > &recipe)
Write ModelRecipe to file with given name.
std::unique_ptr< ModelRecipe > generate_recipe(const tflite::Model *model)
Create ModelRecipe from tflite::Model.

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