Bugfix for NumPyBinLoader with SubTensor output. (#345)
authorhakanardo <hakan@debian.org>
Fri, 16 Feb 2018 09:06:34 +0000 (10:06 +0100)
committerAnthony Barbier <Anthony.barbier@arm.com>
Fri, 16 Feb 2018 09:06:34 +0000 (09:06 +0000)
* Bugfix for NumPyBinLoader with SubTensor output.

When a SubTensor is used as output from a NumPyBinLoader, data should
not be written to the begining of the buffer.

Change-Id: I6ed4b24710ac09b41ca92c7e21f24d44a3ed2881

* Reduce the buffer size with the same amount

Change-Id: Id260f58209ce2fbee877f7d6f4afbe95c6c74036

* SubTensor's has to be accessed through execution windows

utils/GraphUtils.cpp

index 2ff40b7..f190af4 100644 (file)
@@ -24,6 +24,7 @@
 
 #include "utils/GraphUtils.h"
 #include "utils/Utils.h"
+#include "arm_compute/runtime/SubTensor.h"
 
 #ifdef ARM_COMPUTE_CL
 #include "arm_compute/core/CL/OpenCL.h"
@@ -206,7 +207,7 @@ void RandomAccessor::fill(ITensor &tensor, D &&distribution)
 {
     std::mt19937 gen(_seed);
 
-    if(tensor.info()->padding().empty())
+    if(tensor.info()->padding().empty() && !dynamic_cast<SubTensor*>(&tensor))
     {
         for(size_t offset = 0; offset < tensor.info()->total_size(); offset += tensor.info()->element_size())
         {
@@ -349,7 +350,7 @@ bool NumPyBinLoader::access_tensor(ITensor &tensor)
     }
 
     // Read data
-    if(tensor.info()->padding().empty())
+    if(tensor.info()->padding().empty() && !dynamic_cast<SubTensor*>(&tensor))
     {
         // If tensor has no padding read directly from stream.
         stream.read(reinterpret_cast<char *>(tensor.buffer()), tensor.info()->total_size());