From: 박세희/동작제어Lab(SR)/Principal Engineer/삼성전자 Date: Wed, 21 Nov 2018 02:51:21 +0000 (+0900) Subject: [tflchef] Call tflchef from Driver (#2350) X-Git-Tag: nncc_backup~1294 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1aae5aa057301f226b7bca744089ab37f14240a4;p=platform%2Fcore%2Fml%2Fnnfw.git [tflchef] Call tflchef from Driver (#2350) This will make Driver call tflchef tflite load and save functions Signed-off-by: SaeHie Park --- diff --git a/contrib/tflchef/tools/reverse/CMakeLists.txt b/contrib/tflchef/tools/reverse/CMakeLists.txt index f6bbcb3..63cb36c 100644 --- a/contrib/tflchef/tools/reverse/CMakeLists.txt +++ b/contrib/tflchef/tools/reverse/CMakeLists.txt @@ -1,2 +1,3 @@ add_executable(tflchef-reverse Driver.cpp) +target_link_libraries(tflchef-reverse tflchef_tflite) target_link_libraries(tflchef-reverse safemain) diff --git a/contrib/tflchef/tools/reverse/Driver.cpp b/contrib/tflchef/tools/reverse/Driver.cpp index d570db5..5497564 100644 --- a/contrib/tflchef/tools/reverse/Driver.cpp +++ b/contrib/tflchef/tools/reverse/Driver.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +#include +#include + +#include #include int entry(int argc, char **argv) @@ -26,9 +30,35 @@ int entry(int argc, char **argv) return 255; } - // TODO load tflite + // Load TF lite model from a tflite file + std::unique_ptr 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 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; }