From: 박종현/동작제어Lab(SR)/Staff Engineer/삼성전자 Date: Thu, 30 Aug 2018 05:32:19 +0000 (+0900) Subject: [enco] Emit identifyInputsAndOutputs call (#1244) X-Git-Tag: nncc_backup~2009 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=24a5ccee4b90ecf4b6b866472489ed9c5eb01e7a;p=platform%2Fcore%2Fml%2Fnnfw.git [enco] Emit identifyInputsAndOutputs call (#1244) Generated C++ code will invoke ANeuralNetworksModel_identifyInputsAndOutputs with this commit. Signed-off-by: Jonghyun Park --- diff --git a/contrib/enco/core/src/CppGen/Subnet.cpp b/contrib/enco/core/src/CppGen/Subnet.cpp index 876b78e..5087dc3 100644 --- a/contrib/enco/core/src/CppGen/Subnet.cpp +++ b/contrib/enco/core/src/CppGen/Subnet.cpp @@ -272,6 +272,51 @@ private: const ann::Operation *_op; }; +/** + * @brief Code fragment that calls ANeuralNetworksModel_identifyInputsAndOutputs + */ +class ArgumentDecl final : public CodeFragment +{ +public: + ArgumentDecl(const std::string &mname, const ANNBinder *binder) : _mname{mname}, _binder{binder} + { + // DO NOTHING + } + +public: + void dump(pp::LinearDocument *doc) const override + { + doc->append("{"); + doc->indent(); + + auto module = _binder->module(); + const uint32_t input_count = module->input()->size(); + + doc->append("uint32_t inputs[", input_count, "];"); + for (uint32_t n = 0; n < input_count; ++n) + { + doc->append("inputs[", n, "] = ", module->input()->at(n), ";"); + } + + const uint32_t output_count = module->output()->size(); + + doc->append("uint32_t outputs[", output_count, "];"); + for (uint32_t n = 0; n < output_count; ++n) + { + doc->append("outputs[", n, "] = ", module->output()->at(n), ";"); + } + + doc->append("ANeuralNetworksModel_identifyInputsAndOutputs(", _mname, ", ", input_count, + ", inputs, ", output_count, ", outputs);"); + doc->unindent(); + doc->append("}"); + } + +private: + std::string _mname; + const ANNBinder *_binder; +}; + } // namespace namespace enco @@ -322,7 +367,9 @@ std::unique_ptr SubnetStructBuilder::build(const ANNBinder *binder res->ctor() << OperationDecl{mname, op}; } - // TODO Emit ANeuralNetworksModel_identifyInputsAndOutputs call + // Emit ANeuralNetworksModel_identifyInputsAndOutputs call + res->ctor() << ArgumentDecl{mname, binder}; + // TODO Emit ANeuralNetworksModel_finish call res->ctor()->append(S(assert("NYI");));