From: 박세희/동작제어Lab(SR)/Principal Engineer/삼성전자 Date: Fri, 9 Nov 2018 07:04:12 +0000 (+0900) Subject: [enco/frontend] Functions to set coco module IO (#2190) X-Git-Tag: nncc_backup~1385 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bb24a571e1c8b5aa18f7d0ee86f7106ce871f955;p=platform%2Fcore%2Fml%2Fnnfw.git [enco/frontend] Functions to set coco module IO (#2190) This will add two methods set_module_inputs and set_module_outputs to set coco::Module inputs and outputs from TensorContext and TensorBags Signed-off-by: SaeHie Park --- diff --git a/contrib/enco/frontend/tflite/src/Frontend.cpp b/contrib/enco/frontend/tflite/src/Frontend.cpp index 7e1417c..1a75596 100644 --- a/contrib/enco/frontend/tflite/src/Frontend.cpp +++ b/contrib/enco/frontend/tflite/src/Frontend.cpp @@ -17,6 +17,7 @@ #include "Frontend.h" #include "IRBuilder.h" +#include #include #include @@ -115,6 +116,54 @@ private: }; /** + * @brief Set module input operands and its information + */ +void set_module_inputs(coco::Module *m, TensorContext &ctx, TensorBags &bags, + const IndexVector &inputs) +{ + for (uint32_t n = 0; n < inputs.size(); ++n) + { + auto const tensor_id = inputs.at(n); + + auto const tensor_name = ctx.name(tensor_id); + auto const tensor_shape = ctx.shape(tensor_id); + auto const tensor_bag = bags.bag(tensor_id); + + auto input = m->entity()->input()->create(tensor_shape); + + input->name(tensor_name); + input->bag(tensor_bag); + input->reorder(); + + m->input()->insert(input); + } +} + +/** + * @brief Set module output operands and its information + */ +void set_module_outputs(coco::Module *m, TensorContext &ctx, TensorBags &bags, + const IndexVector &outputs) +{ + for (uint32_t n = 0; n < outputs.size(); ++n) + { + auto const tensor_id = outputs.at(n); + + auto const tensor_name = ctx.name(tensor_id); + auto const tensor_shape = ctx.shape(tensor_id); + auto const tensor_bag = bags.bag(tensor_id); + + auto output = m->entity()->output()->create(tensor_shape); + + output->name(tensor_name); + output->bag(tensor_bag); + output->reorder(); + + m->output()->insert(output); + } +} + +/** * @brief Class to store context to build IR from tflite */ class GraphBuilderContext