IVGCVSW-2833 Add Dynamic Quantization

Change-Id: Iba91e3f3625639f01d66f81a9f3e419e0e285d66
Signed-off-by: Jim Flynn <jim.flynn@arm.com>
diff --git a/src/armnnUtils/TensorUtils.cpp b/src/armnnUtils/TensorUtils.cpp
index 57f823f..c2fbbe0 100644
--- a/src/armnnUtils/TensorUtils.cpp
+++ b/src/armnnUtils/TensorUtils.cpp
@@ -4,6 +4,7 @@
 //
 
 #include "TensorUtils.hpp"
+#include <backendsCommon/ITensorHandle.hpp>
 
 namespace armnnUtils
 {
@@ -47,4 +48,31 @@
     }
 }
 
+std::pair<float, float> FindMinMax(armnn::ITensorHandle* tensorHandle)
+{
+    auto tensor_data = static_cast<const float *>(tensorHandle->Map(true));
+    auto tensor_size = tensorHandle->GetShape().GetNumElements();
+
+    // Set min/max initially to first value in tensor
+    float min = tensor_data[0];
+    float max = tensor_data[0];
+
+    // Loop over rest of tensor and update min/max if necessary
+    for (unsigned int val = 1; val < tensor_size; val++)
+    {
+        if (tensor_data[val] < min)
+        {
+            min = tensor_data[val];
+        }
+        else if (tensor_data[val] > max)
+        {
+            max = tensor_data[val];
+        }
+    }
+
+    tensorHandle->Unmap();
+
+    return std::make_pair(min, max);
+}
+
 }