From: 박종현/동작제어Lab(SR)/Staff Engineer/삼성전자 Date: Fri, 24 Aug 2018 00:58:03 +0000 (+0900) Subject: [enco] Check the existence of in/out bag (#1154) X-Git-Tag: nncc_backup~2064 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3924e9f2bf1566741c28f8c7cd1c08b86cc27584;p=platform%2Fcore%2Fml%2Fnnfw.git [enco] Check the existence of in/out bag (#1154) * [enco] Check the existence of in/out bag The current design of enco NNAPI backend does not work if there is an in/out bag. This commit introduces a corresponding assert to make it easy to detect such a case. Signed-off-by: Jonghyun Park * Update comment --- diff --git a/contrib/enco/core/src/Backend.cpp b/contrib/enco/core/src/Backend.cpp index ba7769e..58edd2e 100644 --- a/contrib/enco/core/src/Backend.cpp +++ b/contrib/enco/core/src/Backend.cpp @@ -5,6 +5,27 @@ #include +namespace +{ + +// has_inout_bag(m) returns true if there is a pair of coco::Input and coco::Output that share +// the same bag as their backing storage +bool has_inout_bag(const coco::Module *m) +{ + for (uint32_t n = 0; n < m->entity()->bag()->size(); ++n) + { + auto bag = m->entity()->bag()->at(n); + + if (bag->isInput() && bag->isOutput()) + { + return true; + } + } + return false; +} + +} // namespace + namespace enco { @@ -12,6 +33,15 @@ void Backend::compile(coco::Module *m, coco::Data *d) { Code code{m, d}; + // The current implementation will assign memory region for each bag as follows: + // Bind input bag to the region provided by Network_input_bind + // Bind output bag to the region provided by Network_output_bind + // Bind intermediate bag to the region allocated during execution + // + // Note that this scheme does not work if there is a pair of input/output + // that share the same bag as their underlying bag + assert(!has_inout_bag(code.module())); + // TODO Run various transforms over enco::Code _os << CppCode{&code} << std::endl;