aboutsummaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorPablo Tello <pablo.tello@arm.com>2018-11-15 14:43:10 +0000
committerAnthony Barbier <Anthony.barbier@arm.com>2018-11-19 09:58:20 +0000
commit32521430ad67172d372721979e8a32b7d4317620 (patch)
treec18921290341c1d730fbff406960dc7ea7f61306 /utils
parentd696cb6d18c2fe66f1abce88bbd14faf2137ef89 (diff)
downloadComputeLibrary-32521430ad67172d372721979e8a32b7d4317620.tar.gz
COMPMID-1750: Add PriorBox operator to graph API.
Change-Id: I5d2ed5dcc342abff8124762f7bdee587cdf20032
Diffstat (limited to 'utils')
-rw-r--r--utils/GraphUtils.cpp6
-rw-r--r--utils/GraphUtils.h6
-rw-r--r--utils/Utils.h8
3 files changed, 11 insertions, 9 deletions
diff --git a/utils/GraphUtils.cpp b/utils/GraphUtils.cpp
index 19fba4c0bf..2f1df7aef2 100644
--- a/utils/GraphUtils.cpp
+++ b/utils/GraphUtils.cpp
@@ -77,8 +77,8 @@ void TFPreproccessor::preprocess(ITensor &tensor)
});
}
-CaffePreproccessor::CaffePreproccessor(std::array<float, 3> mean, bool bgr)
- : _mean(mean), _bgr(bgr)
+CaffePreproccessor::CaffePreproccessor(std::array<float, 3> mean, float scale, bool bgr)
+ : _mean(mean), _scale(scale), _bgr(bgr)
{
if(_bgr)
{
@@ -96,7 +96,7 @@ void CaffePreproccessor::preprocess(ITensor &tensor)
execute_window_loop(window, [&](const Coordinates & id)
{
const float value = *reinterpret_cast<float *>(tensor.ptr_to_element(id)) - _mean[id[channel_idx]];
- *reinterpret_cast<float *>(tensor.ptr_to_element(id)) = value;
+ *reinterpret_cast<float *>(tensor.ptr_to_element(id)) = value * _scale;
});
}
diff --git a/utils/GraphUtils.h b/utils/GraphUtils.h
index a6d670d761..d7f24afdd8 100644
--- a/utils/GraphUtils.h
+++ b/utils/GraphUtils.h
@@ -63,14 +63,16 @@ public:
/** Default Constructor
*
* @param mean Mean array in RGB ordering
+ * @param scale Scale value
* @param bgr Boolean specifying if the preprocessing should assume BGR format
*/
- CaffePreproccessor(std::array<float, 3> mean = std::array<float, 3> { { 0, 0, 0 } }, bool bgr = true);
+ CaffePreproccessor(std::array<float, 3> mean = std::array<float, 3> { { 0, 0, 0 } }, float scale = 1.f, bool bgr = true);
void preprocess(ITensor &tensor) override;
private:
std::array<float, 3> _mean;
- bool _bgr;
+ float _scale;
+ bool _bgr;
};
/** TF preproccessor */
diff --git a/utils/Utils.h b/utils/Utils.h
index 92ab1a30b9..8cac857178 100644
--- a/utils/Utils.h
+++ b/utils/Utils.h
@@ -607,7 +607,6 @@ void save_to_ppm(T &tensor, const std::string &ppm_filename)
/** Template helper function to save a tensor image to a NPY file.
*
* @note Only F32 data type supported.
- * @note Only works with 2D tensors.
* @note If the input tensor is a CLTensor, the function maps and unmaps the image
*
* @param[in] tensor The tensor to save as NPY file
@@ -627,9 +626,9 @@ void save_to_npy(T &tensor, const std::string &npy_filename, bool fortran_order)
std::vector<npy::ndarray_len_t> shape(tensor.info()->num_dimensions());
- for(unsigned int i = 0; i < tensor.info()->num_dimensions(); ++i)
+ for(unsigned int i = 0, j = tensor.info()->num_dimensions() - 1; i < tensor.info()->num_dimensions(); ++i, --j)
{
- shape[i] = tensor.info()->tensor_shape()[i];
+ shape[i] = tensor.info()->tensor_shape()[!fortran_order ? j : i];
}
// Map buffer if creating a CLTensor
@@ -802,12 +801,13 @@ int compare_tensor(ITensor &tensor1, ITensor &tensor2)
map(tensor1, true);
map(tensor2, true);
+
Iterator itensor1(&tensor1, window);
Iterator itensor2(&tensor2, window);
execute_window_loop(window, [&](const Coordinates & id)
{
- if(std::abs(*reinterpret_cast<T *>(itensor1.ptr()) - *reinterpret_cast<T *>(itensor2.ptr())) > 0.00001)
+ if(std::abs(*reinterpret_cast<T *>(itensor1.ptr()) - *reinterpret_cast<T *>(itensor2.ptr())) > 0.0001)
{
++num_mismatches;
}