This will implement storing ModelRecipe to a file
Signed-off-by: SaeHie Park <saehie.park@samsung.com>
#include <tflchef/RecipeChef.h>
+#include <fstream>
+
namespace tflchef
{
bool write_recipe(const std::string &filename, std::unique_ptr<ModelRecipe> &recipe)
{
- // TODO fill this
+ std::fstream fo(filename, std::ios::binary | std::ios::out);
+
+ if (!fo.is_open())
+ {
+ throw std::runtime_error{"file store failed"};
+ }
+
+ // Note: SerializeToString() or SerializeToOstream() writes in binary mode
+ // DebugString() and Utf8DebugString() will print as a human readable text
+ fo << recipe->Utf8DebugString();
+
+ fo.close();
return true;
}