* limitations under the License.
*/
+#include <tflchef/RawModel.h>
+#include <tflchef/RecipeChef.h>
+
+#include <memory>
#include <iostream>
int entry(int argc, char **argv)
return 255;
}
- // TODO load tflite
+ // Load TF lite model from a tflite file
+ std::unique_ptr<tflchef::RawModel> rawmodel = tflchef::load_tflite(argv[1]);
+ if (rawmodel == nullptr)
+ {
+ std::cerr << "ERROR: Failed to load tflite '" << argv[1] << "'" << std::endl;
+ return 255;
+ }
+
+ const tflite::Model *tflmodel = rawmodel->model();
+ if (tflmodel == nullptr)
+ {
+ std::cerr << "ERROR: Failed to load tflite '" << argv[1] << "'" << std::endl;
+ return 255;
+ }
- // TODO store to recipe
+ // Generate ModelRecipe recipe
+ std::unique_ptr<tflchef::ModelRecipe> recipe = tflchef::generate_recipe(tflmodel);
+ if (recipe.get() == nullptr)
+ {
+ std::cerr << "ERROR: Failed to generate recipe" << std::endl;
+ return 255;
+ }
+ // Save to a file
+ bool result = tflchef::write_recipe(argv[2], recipe);
+ if (!result)
+ {
+ std::cerr << "ERROR: Failed to write to recipe '" << argv[2] << "'" << std::endl;
+ return 255;
+ }
return 0;
}