Disable Hw Avg Pooling for small output tensors if excludePad=true (#772)
authorChance Luo <chance.xiaochen.luo@intel.com>
Fri, 5 Jun 2020 16:47:53 +0000 (00:47 +0800)
committerGitHub <noreply@github.com>
Fri, 5 Jun 2020 16:47:53 +0000 (19:47 +0300)
inference-engine/src/vpu/graph_transformer/src/stages/pooling.cpp

index 2877522d85926f571192dcf91d2d4888a9a7d7b3..11b367303f1f5a4829b8c1fe7885fa8445cb4874 100644 (file)
@@ -117,11 +117,12 @@ bool canTryHW(const ie::PoolingLayer::PoolType poolType,
     }
 
     //  FIX #14949, enable HW AVG pooling, need SW postproc
-    if (excludePad && poolType == ie::PoolingLayer::PoolType::AVG) {
-        if (outputWidth == 5 &&
-            outputHeight == 5 &&
-            kernelSizeX == 5 &&
-            kernelSizeY == 5) {
+    //  HW AVG pooling will output wrong results in borders when excludePad=true
+    bool hasPad = padLeft || padTop || padRight || padBottom;
+    if (excludePad && hasPad && poolType == ie::PoolingLayer::PoolType::AVG) {
+        // Only apply to small output tensors for now
+        // May need to loose the condition if accuracy issues are met
+        if (outputWidth <= 5 && outputHeight <= 5) {
             tryHW = false;
         }
     }