From 4c460ff33409d6393dad50aeedafff390748164a 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, 6 Sep 2018 14:37:34 +0900 Subject: [PATCH] [enco] Build ANN IR for AvgPool2D with padding (#1377) This commit enables ANN IR build for AvgPool2D with padding. Signed-off-by: Jonghyun Park --- contrib/enco/core/src/Transforms/Split.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/contrib/enco/core/src/Transforms/Split.cpp b/contrib/enco/core/src/Transforms/Split.cpp index ea08241..ca8c465 100644 --- a/contrib/enco/core/src/Transforms/Split.cpp +++ b/contrib/enco/core/src/Transforms/Split.cpp @@ -65,8 +65,15 @@ Compatibility ANNGroupBuilder::kind(const coco::Instr *ins) const return true; } - bool visit(const coco::AvgPool2D *) override + bool visit(const coco::AvgPool2D *avgpool) override { + if (avgpool->divisor() != coco::AvgPool2D::Divisor::PaddingExcluded) + { + // When ANN runtime computes the average of each receptive field, + // it uses the number of valid(=non-padding) elements as a divisor. + return false; + } + // TODO Check data layout return true; } @@ -291,15 +298,14 @@ public: { auto ifm = _binder->addOperand(unit->ifm()); - // TODO Support padding auto left = _binder->addOperand(); - _binder->setOperand(left, 0); + _binder->setOperand(left, avgpool->pad()->left()); auto right = _binder->addOperand(); - _binder->setOperand(right, 0); + _binder->setOperand(right, avgpool->pad()->right()); auto top = _binder->addOperand(); - _binder->setOperand(top, 0); + _binder->setOperand(top, avgpool->pad()->top()); auto bottom = _binder->addOperand(); - _binder->setOperand(bottom, 0); + _binder->setOperand(bottom, avgpool->pad()->bottom()); // Set horizontal/vertical stride auto hstride = _binder->addOperand(); -- 2.7.4