Use N/H/W/C ordering for fromNNShape (#530)
author박종현/동작제어Lab(SR)/Senior Engineer/삼성전자 <jh1302.park@samsung.com>
Tue, 10 Apr 2018 08:41:16 +0000 (17:41 +0900)
committer김정현/동작제어Lab(SR)/Senior Engineer/삼성전자 <jh0822.kim@samsung.com>
Tue, 10 Apr 2018 08:41:16 +0000 (17:41 +0900)
NNAPI assumes that N/H/W/C binding for 3D feature map tensor.

Signed-off-by: Jonghyun Park <jh1302.park@samsung.com>
src/kernel/acl/src/Conv2D_acl.cpp

index 44fea16..9c9ca01 100644 (file)
@@ -24,12 +24,17 @@ namespace acl {
 
 arm_compute::TensorShape fromNNShape(const android::nn::Shape& shape)
 {
-  // NOTE order may be not correct
-  // TODO check and fix order if incorrect
-  uint32_t c = android::nn::getSizeOfDimension(shape, 0);
+  // NNAPI assumes the following ordering:
+  //
+  //  dim(0) -> N
+  //  dim(1) -> H
+  //  dim(2) -> W
+  //  dim(3) -> C
+  //
+  uint32_t c = android::nn::getSizeOfDimension(shape, 3);
   uint32_t h = android::nn::getSizeOfDimension(shape, 1);
   uint32_t w = android::nn::getSizeOfDimension(shape, 2);
-  uint32_t n = android::nn::getSizeOfDimension(shape, 3);
+  uint32_t n = android::nn::getSizeOfDimension(shape, 0);
 
   return arm_compute::TensorShape(w, h, c, n);
 }