[enco] Build ANN IR for AvgPool2D with padding (#1377)
author박종현/동작제어Lab(SR)/Staff Engineer/삼성전자 <jh1302.park@samsung.com>
Thu, 6 Sep 2018 05:37:34 +0000 (14:37 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Thu, 6 Sep 2018 05:37:34 +0000 (14:37 +0900)
This commit enables ANN IR build for AvgPool2D with padding.

Signed-off-by: Jonghyun Park <jh1302.park@samsung.com>
contrib/enco/core/src/Transforms/Split.cpp

index ea08241..ca8c465 100644 (file)
@@ -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<float>(unit->ifm());
 
-      // TODO Support padding
       auto left = _binder->addOperand<int32_t>();
-      _binder->setOperand(left, 0);
+      _binder->setOperand(left, avgpool->pad()->left());
       auto right = _binder->addOperand<int32_t>();
-      _binder->setOperand(right, 0);
+      _binder->setOperand(right, avgpool->pad()->right());
       auto top = _binder->addOperand<int32_t>();
-      _binder->setOperand(top, 0);
+      _binder->setOperand(top, avgpool->pad()->top());
       auto bottom = _binder->addOperand<int32_t>();
-      _binder->setOperand(bottom, 0);
+      _binder->setOperand(bottom, avgpool->pad()->bottom());
 
       // Set horizontal/vertical stride
       auto hstride = _binder->addOperand<int32_t>();