31 arser.add_argument(
"recipe").help(
"Source recipe file path to convert");
32 arser.add_argument(
"tflite").help(
"Target tflite file path");
36 arser.parse(argc, argv);
38 catch (
const std::runtime_error &err)
40 std::cout << err.what() << std::endl;
45 int32_t model_version = 1;
47 ::tflchef::ModelRecipe model_recipe;
49 std::string recipe_path =
arser.get<std::string>(
"recipe");
52 std::ifstream is{recipe_path};
53 google::protobuf::io::IstreamInputStream iis{&is};
54 if (!google::protobuf::TextFormat::Parse(&iis, &model_recipe))
56 std::cerr <<
"ERROR: Failed to parse recipe '" << recipe_path <<
"'" << std::endl;
60 if (model_recipe.has_version())
62 model_version = model_recipe.version();
66 if (model_version > 1)
68 std::cerr <<
"ERROR: Unsupported recipe version: " << model_version <<
", '" << recipe_path
75 std::string tflite_path =
arser.get<std::string>(
"tflite");
78 std::ofstream os{tflite_path, std::ios::binary};
79 os.write(generated_model.base(), generated_model.size());