aboutsummaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorGeorgios Pinitas <georgios.pinitas@arm.com>2018-08-17 15:33:39 +0100
committerAnthony Barbier <anthony.barbier@arm.com>2018-11-02 16:54:54 +0000
commitbe2772a6b0b88cc3170f6527e07e8bcb426a4b1c (patch)
treee806f0f2c52360a16bf456be4ec94b5c56c9f3fd /utils
parent6c95c2dd574ebc3217c949a17016eb071935bc3b (diff)
downloadComputeLibrary-be2772a6b0b88cc3170f6527e07e8bcb426a4b1c.tar.gz
COMPMID-1508: Add Inception ResNet V2 model
Change-Id: Iab860a43aa831690fab49b96c124528cc4cb14f2 Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/144621 Tested-by: Jenkins <bsgcomp@arm.com> Reviewed-by: Giorgio Arena <giorgio.arena@arm.com> Reviewed-by: Michalis Spyrou <michalis.spyrou@arm.com>
Diffstat (limited to 'utils')
-rw-r--r--utils/GraphUtils.cpp10
-rw-r--r--utils/GraphUtils.h12
2 files changed, 20 insertions, 2 deletions
diff --git a/utils/GraphUtils.cpp b/utils/GraphUtils.cpp
index f07323cdf8..f33d8a2e2f 100644
--- a/utils/GraphUtils.cpp
+++ b/utils/GraphUtils.cpp
@@ -57,16 +57,22 @@ std::pair<arm_compute::TensorShape, arm_compute::PermutationVector> compute_perm
}
} // namespace
+TFPreproccessor::TFPreproccessor(float min_range, float max_range)
+ : _min_range(min_range), _max_range(max_range)
+{
+}
void TFPreproccessor::preprocess(ITensor &tensor)
{
Window window;
window.use_tensor_dimensions(tensor.info()->tensor_shape());
+ const float range = _max_range - _min_range;
+
execute_window_loop(window, [&](const Coordinates & id)
{
const float value = *reinterpret_cast<float *>(tensor.ptr_to_element(id));
- float res = value / 255.f; // Normalize to [0, 1]
- res = (res - 0.5f) * 2.f; // Map to [-1, 1]
+ float res = value / 255.f; // Normalize to [0, 1]
+ res = res * range + _min_range; // Map to [min_range, max_range]
*reinterpret_cast<float *>(tensor.ptr_to_element(id)) = res;
});
}
diff --git a/utils/GraphUtils.h b/utils/GraphUtils.h
index 52180ca495..bc7699b70c 100644
--- a/utils/GraphUtils.h
+++ b/utils/GraphUtils.h
@@ -77,7 +77,19 @@ private:
class TFPreproccessor : public IPreprocessor
{
public:
+ /** Constructor
+ *
+ * @param[in] min_range Min normalization range. (Defaults to -1.f)
+ * @param[in] max_range Max normalization range. (Defaults to 1.f)
+ */
+ TFPreproccessor(float min_range = -1.f, float max_range = 1.f);
+
+ // Inherited overriden methods
void preprocess(ITensor &tensor) override;
+
+private:
+ float _min_range;
+ float _max_range;
};
/** PPM writer class */