ONE - On-device Neural Engine
Loading...
Searching...
No Matches
Driver.cpp File Reference
#include "circlechef/ModelChef.h"
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/io/zero_copy_stream_impl.h>
#include <google/protobuf/text_format.h>
#include <iostream>

Go to the source code of this file.

Functions

int entry_stream (std::istream &is)
 
int entry (int, char **)
 

Function Documentation

◆ entry()

int entry ( int  argc,
char **  argv 
)

Definition at line 60 of file Driver.cpp.

61{
62 // forward to entry_stream
63 return entry_stream(std::cin);
64}
int entry_stream(std::istream &is)
Definition Driver.cpp:25

References entry_stream().

◆ entry_stream()

int entry_stream ( std::istream &  is)

Definition at line 25 of file Driver.cpp.

26{
27 int32_t model_version = 1;
28
29 ::circlechef::ModelRecipe model_recipe;
30
31 // Read a model recipe from standard input
32 {
33 google::protobuf::io::IstreamInputStream iis{&is};
34 if (!google::protobuf::TextFormat::Parse(&iis, &model_recipe))
35 {
36 std::cerr << "ERROR: Failed to parse recipe" << std::endl;
37 return 255;
38 }
39
40 if (model_recipe.has_version())
41 {
42 model_version = model_recipe.version();
43 }
44 }
45
46 if (model_version > 1)
47 {
48 std::cerr << "ERROR: Unsupported recipe version: " << model_version << std::endl;
49 return 255;
50 }
51
52 auto generated_model = circlechef::cook(model_recipe);
53
54 // Write a generated model into standard output
55 std::cout.write(generated_model.base(), generated_model.size());
56
57 return 0;
58}
GeneratedModel cook(const ModelRecipe &model_recipe)

References circlechef::cook().

Referenced by entry().