From 930dbd6dd671f5525a4f04fa38556b9f63187a64 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EB=B0=95=EC=A2=85=ED=98=84/=EB=8F=99=EC=9E=91=EC=A0=9C?= =?utf8?q?=EC=96=B4Lab=28SR=29/Staff=20Engineer/=EC=82=BC=EC=84=B1?= =?utf8?q?=EC=A0=84=EC=9E=90?= Date: Thu, 30 Aug 2018 10:02:25 +0900 Subject: [PATCH] [enco] Support subnet in/out identification (#1234) This commit introduces identifyInputs and identifyOutputs method which allows Backend to record android NN subnet's input and output. Signed-off-by: Jonghyun Park --- contrib/enco/core/src/ANN/Binder.h | 56 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/contrib/enco/core/src/ANN/Binder.h b/contrib/enco/core/src/ANN/Binder.h index 16b69e5..bbae045 100644 --- a/contrib/enco/core/src/ANN/Binder.h +++ b/contrib/enco/core/src/ANN/Binder.h @@ -102,12 +102,68 @@ public: _module->operation()->create(code, inputs, outputs); } +public: + // @brief Identify a sequence of coco::Bag * as subnet's inputs + // + // NOTE 1. This method takes input iterator over coco::Bag * values + // NOTE 2. All the identifyInputs class except the last one will be ignored if there are + // multiple identifyInputs calls + template void identifyInputs(It beg, It end) + { + _inputs.clear(); + _module->input()->clear(); + + for (auto it = beg; it != end; ++it) + { + auto const bag = *it; + _inputs.emplace_back(*it); + _module->input()->emplace_back(_operands.at(bag)); + } + } + + template void identifyInputs(T &&values) + { + identifyInputs(std::begin(values), std::end(values)); + } + +public: + // @brief Identify a sequence of coco::Bag * as subnet's outputs + // + // NOTE 1. This method takes input iterator over coco::Bag * values + // NOTE 2. All the identifyOutputs class except the last one will be ignored if there are + // multiple identifyOutputs calls + template void identifyOutputs(It beg, It end) + { + _outputs.clear(); + _module->output()->clear(); + + for (auto it = beg; it != end; ++it) + { + auto const bag = *it; + _outputs.emplace_back(bag); + _module->output()->emplace_back(_operands.at(bag)); + } + } + + template void identifyOutputs(T &&values) + { + identifyOutputs(std::begin(values), std::end(values)); + } + +public: + coco::Bag *input(uint32_t n) const { return _inputs.at(n); } + coco::Bag *output(uint32_t n) const { return _outputs.at(n); } + private: uint32_t const _id; coco::Block *const _block; std::unique_ptr _module; private: + std::vector _inputs; + std::vector _outputs; + +private: // @brief Operand ID assigned for each coco::Bag std::map _operands; }; -- 2.7.4