From d448b6c41908fee11fbf07056011371c72e71437 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EB=B0=95=EC=84=B8=ED=9D=AC/=EB=8F=99=EC=9E=91=EC=A0=9C?= =?utf8?q?=EC=96=B4Lab=28SR=29/Principal=20Engineer/=EC=82=BC=EC=84=B1?= =?utf8?q?=EC=A0=84=EC=9E=90?= Date: Wed, 21 Nov 2018 14:10:39 +0900 Subject: [PATCH] [tflchef] Store ModelRecipe to file (#2352) This will implement storing ModelRecipe to a file Signed-off-by: SaeHie Park --- contrib/tflchef/tflite/src/RecipeChef.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/contrib/tflchef/tflite/src/RecipeChef.cpp b/contrib/tflchef/tflite/src/RecipeChef.cpp index 7f0ae6d..51438cd 100644 --- a/contrib/tflchef/tflite/src/RecipeChef.cpp +++ b/contrib/tflchef/tflite/src/RecipeChef.cpp @@ -16,6 +16,8 @@ #include +#include + namespace tflchef { @@ -29,7 +31,18 @@ std::unique_ptr generate_recipe(const tflite::Model *model) bool write_recipe(const std::string &filename, std::unique_ptr &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; } -- 2.7.4