aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPablo Tello <pablo.tello@arm.com>2018-08-07 11:23:54 +0100
committerAnthony Barbier <anthony.barbier@arm.com>2018-11-02 16:54:54 +0000
commitd8b03dd029261091e34dd8831d546299c60ce094 (patch)
treeced5c96940aa018f0a5a5a3a5fb0769d8dadcd1e
parent7da6dcfc199580828dbedfed15afdcc7a789192c (diff)
downloadComputeLibrary-d8b03dd029261091e34dd8831d546299c60ce094.tar.gz
MLCE-13: Sanitizing matrix argument in the Warp.
This changes help to prevent errors like passing a matrix with less elements than required into the warp functions. Change-Id: I863f933a5e0568258717cffed3a20788d3d03083 Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/143044 Tested-by: Jenkins <bsgcomp@arm.com> Reviewed-by: Anthony Barbier <anthony.barbier@arm.com>
-rw-r--r--arm_compute/core/CL/kernels/CLWarpAffineKernel.h7
-rw-r--r--arm_compute/core/CL/kernels/CLWarpPerspectiveKernel.h4
-rw-r--r--arm_compute/core/NEON/kernels/NEWarpKernel.h7
-rw-r--r--arm_compute/runtime/CL/functions/CLWarpAffine.h5
-rw-r--r--arm_compute/runtime/CL/functions/CLWarpPerspective.h6
-rw-r--r--arm_compute/runtime/NEON/functions/NEWarpAffine.h5
-rw-r--r--arm_compute/runtime/NEON/functions/NEWarpPerspective.h4
-rw-r--r--src/core/CL/kernels/CLWarpAffineKernel.cpp10
-rw-r--r--src/core/CL/kernels/CLWarpPerspectiveKernel.cpp10
-rw-r--r--src/core/NEON/kernels/NEWarpKernel.cpp7
-rw-r--r--src/runtime/CL/functions/CLWarpAffine.cpp4
-rw-r--r--src/runtime/CL/functions/CLWarpPerspective.cpp4
-rw-r--r--src/runtime/NEON/functions/NEWarpAffine.cpp5
-rw-r--r--src/runtime/NEON/functions/NEWarpPerspective.cpp5
-rw-r--r--tests/benchmark/fixtures/WarpAffineFixture.h4
-rw-r--r--tests/validation/CL/WarpAffine.cpp8
-rw-r--r--tests/validation/CL/WarpPerspective.cpp4
-rw-r--r--tests/validation/NEON/WarpAffine.cpp8
-rw-r--r--tests/validation/NEON/WarpPerspective.cpp4
-rw-r--r--tests/validation/fixtures/WarpAffineFixture.h16
-rw-r--r--tests/validation/fixtures/WarpPerspectiveFixture.h14
21 files changed, 72 insertions, 69 deletions
diff --git a/arm_compute/core/CL/kernels/CLWarpAffineKernel.h b/arm_compute/core/CL/kernels/CLWarpAffineKernel.h
index b01bebf258..cfce2ff753 100644
--- a/arm_compute/core/CL/kernels/CLWarpAffineKernel.h
+++ b/arm_compute/core/CL/kernels/CLWarpAffineKernel.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, 2017 ARM Limited.
+ * Copyright (c) 2016-2018 ARM Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -39,10 +39,11 @@ public:
*
* @param[in] input Source tensor. Data types supported: U8.
* @param[out] output Destination tensor, Data types supported: U8.
- * @param[in] matrix The perspective matrix. Must be 2x3 of type float.
+ * @param[in] matrix The perspective matrix. Must be 2x3 of type float
+ * The matrix argument requires 9 values, the last 3 values are ignored.
* @param[in] policy The interpolation type.
*/
- void configure(const ICLTensor *input, ICLTensor *output, const float *matrix, InterpolationPolicy policy);
+ void configure(const ICLTensor *input, ICLTensor *output, const std::array<float, 9> &matrix, InterpolationPolicy policy);
// Inherited methods overridden:
BorderSize border_size() const override;
diff --git a/arm_compute/core/CL/kernels/CLWarpPerspectiveKernel.h b/arm_compute/core/CL/kernels/CLWarpPerspectiveKernel.h
index 0989d523f0..febcb3d038 100644
--- a/arm_compute/core/CL/kernels/CLWarpPerspectiveKernel.h
+++ b/arm_compute/core/CL/kernels/CLWarpPerspectiveKernel.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, 2017 ARM Limited.
+ * Copyright (c) 2016-2018 ARM Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -41,7 +41,7 @@ public:
* @param[in] matrix The perspective matrix. Must be 3x3 of type float.
* @param[in] policy The interpolation type.
*/
- void configure(const ICLTensor *input, ICLTensor *output, const float *matrix, InterpolationPolicy policy);
+ void configure(const ICLTensor *input, ICLTensor *output, const std::array<float, 9> &matrix, InterpolationPolicy policy);
// Inherited methods overridden:
BorderSize border_size() const override;
diff --git a/arm_compute/core/NEON/kernels/NEWarpKernel.h b/arm_compute/core/NEON/kernels/NEWarpKernel.h
index a147d57f28..879bc44d05 100644
--- a/arm_compute/core/NEON/kernels/NEWarpKernel.h
+++ b/arm_compute/core/NEON/kernels/NEWarpKernel.h
@@ -27,8 +27,8 @@
#include "arm_compute/core/NEON/INEKernel.h"
#include "arm_compute/core/Types.h"
+#include <array>
#include <cstdint>
-
namespace arm_compute
{
class ITensor;
@@ -52,10 +52,11 @@ public:
* @param[in] input Source tensor. Data type supported: U8.
* @param[out] output Destination tensor. Data type supported: U8.
* @param[in] matrix The perspective or affine matrix to use. Must be 2x3 for affine and 3x3 for perspective of type float.
+ * The matrix argument requires 9 values, for the affine case the last 3 values are ignored.
* @param[in] border_mode Strategy to use for borders
* @param[in] constant_border_value Constant value used for filling the border.
*/
- virtual void configure(const ITensor *input, ITensor *output, const float *matrix, BorderMode border_mode, uint8_t constant_border_value);
+ virtual void configure(const ITensor *input, ITensor *output, const std::array<float, 9> &matrix, BorderMode border_mode, uint8_t constant_border_value);
// Inherited methods overridden:
void run(const Window &window, const ThreadInfo &info) override;
@@ -88,7 +89,7 @@ protected:
const ITensor *_input; /**< Input Tensor */
ITensor *_output; /**< Output Tensor */
uint8_t _constant_border_value; /**< Constant value used for filling the border. This value is used for those pixels out of the ROI when the border mode is CONSTANT */
- const float *_matrix; /**< The affine or perspective matrix. Must be 2x3 for warp affine or 3x3 for warp perspective of type float. */
+ std::array<float, 9> _matrix; /**< The affine or perspective matrix. Must be 2x3 for warp affine or 3x3 for warp perspective of type float. */
};
/** Template interface for the kernel to compute warp affine
diff --git a/arm_compute/runtime/CL/functions/CLWarpAffine.h b/arm_compute/runtime/CL/functions/CLWarpAffine.h
index aeab3f7b22..05a281567f 100644
--- a/arm_compute/runtime/CL/functions/CLWarpAffine.h
+++ b/arm_compute/runtime/CL/functions/CLWarpAffine.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, 2017 ARM Limited.
+ * Copyright (c) 2016-2018 ARM Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -42,11 +42,12 @@ public:
* @param[in,out] input Source temspr. Data types supported: U8. (Written to only for @p border_mode != UNDEFINED)
* @param[out] output Destination tensor, Data types supported: U8.
* @param[in] matrix The affine matrix. Must be 2x3 of type float.
+ * The matrix argument requires 9 values, the last 3 values are ignored.
* @param[in] policy The interpolation type.
* @param[in] border_mode Strategy to use for borders.
* @param[in] constant_border_value (Optional) Constant value to use for borders if border_mode is set to CONSTANT.
*/
- void configure(ICLTensor *input, ICLTensor *output, const float *matrix, InterpolationPolicy policy, BorderMode border_mode, uint8_t constant_border_value = 0);
+ void configure(ICLTensor *input, ICLTensor *output, const std::array<float, 9> &matrix, InterpolationPolicy policy, BorderMode border_mode, uint8_t constant_border_value = 0);
};
}
#endif /*__ARM_COMPUTE_CLWARPAFFINE_H__ */
diff --git a/arm_compute/runtime/CL/functions/CLWarpPerspective.h b/arm_compute/runtime/CL/functions/CLWarpPerspective.h
index 80237017aa..acefb11c07 100644
--- a/arm_compute/runtime/CL/functions/CLWarpPerspective.h
+++ b/arm_compute/runtime/CL/functions/CLWarpPerspective.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, 2017 ARM Limited.
+ * Copyright (c) 2016-2018 ARM Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -41,12 +41,12 @@ public:
*
* @param[in,out] input Source tensor. Data types supported: U8. (Written to only for @p border_mode != UNDEFINED)
* @param[out] output Destination tensor. Data types supported: U8.
- * @param[in] matrix The perspective matrix. Must be 2x3 of type float.
+ * @param[in] matrix The perspective matrix. Must be 3x3 of type float.
* @param[in] policy The interpolation type.
* @param[in] border_mode Strategy to use for borders.
* @param[in] constant_border_value (Optional) Constant value to use for borders if border_mode is set to CONSTANT.
*/
- void configure(ICLTensor *input, ICLTensor *output, const float *matrix, InterpolationPolicy policy, BorderMode border_mode, uint8_t constant_border_value = 0);
+ void configure(ICLTensor *input, ICLTensor *output, const std::array<float, 9> &matrix, InterpolationPolicy policy, BorderMode border_mode, uint8_t constant_border_value = 0);
};
}
#endif /*__ARM_COMPUTE_CLWARPPERSPECTIVE_H__ */
diff --git a/arm_compute/runtime/NEON/functions/NEWarpAffine.h b/arm_compute/runtime/NEON/functions/NEWarpAffine.h
index f8eebe8d2a..26237191b3 100644
--- a/arm_compute/runtime/NEON/functions/NEWarpAffine.h
+++ b/arm_compute/runtime/NEON/functions/NEWarpAffine.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, 2017 ARM Limited.
+ * Copyright (c) 2016-2018 ARM Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -42,11 +42,12 @@ public:
* @param[in, out] input Source tensor. Data type supported: U8. (Written to only for @p border_mode != UNDEFINED)
* @param[out] output Destination tensor. Data type supported: U8
* @param[in] matrix The perspective matrix. Must be 2x3 of type float.
+ * The matrix argument requires 9 values, the last 3 values are ignored.
* @param[in] policy The interpolation type.
* @param[in] border_mode Strategy to use for borders.
* @param[in] constant_border_value (Optional) Constant value to use for borders if border_mode is set to CONSTANT.
*/
- void configure(ITensor *input, ITensor *output, const float *matrix, InterpolationPolicy policy, BorderMode border_mode, uint8_t constant_border_value = 0);
+ void configure(ITensor *input, ITensor *output, const std::array<float, 9> &matrix, InterpolationPolicy policy, BorderMode border_mode, uint8_t constant_border_value = 0);
};
}
#endif /*__ARM_COMPUTE_NEWARPAFFINE_H__ */
diff --git a/arm_compute/runtime/NEON/functions/NEWarpPerspective.h b/arm_compute/runtime/NEON/functions/NEWarpPerspective.h
index d0699291b1..09bc5837be 100644
--- a/arm_compute/runtime/NEON/functions/NEWarpPerspective.h
+++ b/arm_compute/runtime/NEON/functions/NEWarpPerspective.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, 2017 ARM Limited.
+ * Copyright (c) 2016-2018 ARM Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -46,7 +46,7 @@ public:
* @param[in] border_mode Strategy to use for borders.
* @param[in] constant_border_value (Optional) Constant value to use for borders if border_mode is set to CONSTANT.
*/
- void configure(ITensor *input, ITensor *output, const float *matrix, InterpolationPolicy policy, BorderMode border_mode, uint8_t constant_border_value = 0);
+ void configure(ITensor *input, ITensor *output, const std::array<float, 9> &matrix, InterpolationPolicy policy, BorderMode border_mode, uint8_t constant_border_value = 0);
};
}
#endif /*__ARM_COMPUTE_NEWARPPERSPECTIVE_H__ */
diff --git a/src/core/CL/kernels/CLWarpAffineKernel.cpp b/src/core/CL/kernels/CLWarpAffineKernel.cpp
index be095f2c34..e0e09400af 100644
--- a/src/core/CL/kernels/CLWarpAffineKernel.cpp
+++ b/src/core/CL/kernels/CLWarpAffineKernel.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, 2017 ARM Limited.
+ * Copyright (c) 2016-2018 ARM Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -42,9 +42,9 @@ using namespace arm_compute;
namespace
{
-void options_add_matrix(std::set<std::string> &options, const float *matrix, size_t size)
+void options_add_matrix(std::set<std::string> &options, const std::array<float, 9> &matrix)
{
- for(size_t i = 0; i < size; ++i)
+ for(size_t i = 0; i < 6; ++i)
{
std::stringstream mat_str;
mat_str << "-DMAT" << i << "=" << matrix[i] << " ";
@@ -58,7 +58,7 @@ BorderSize CLWarpAffineKernel::border_size() const
return BorderSize(1);
}
-void CLWarpAffineKernel::configure(const ICLTensor *input, ICLTensor *output, const float *matrix, InterpolationPolicy policy)
+void CLWarpAffineKernel::configure(const ICLTensor *input, ICLTensor *output, const std::array<float, 9> &matrix, InterpolationPolicy policy)
{
ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::U8);
ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(output, 1, DataType::U8);
@@ -69,7 +69,7 @@ void CLWarpAffineKernel::configure(const ICLTensor *input, ICLTensor *output, co
// Create build options
std::set<std::string> options;
- options_add_matrix(options, matrix, 6);
+ options_add_matrix(options, matrix);
options.emplace(("-DDATA_TYPE=" + get_cl_type_from_data_type(input->info()->data_type())));
// Create kernel
diff --git a/src/core/CL/kernels/CLWarpPerspectiveKernel.cpp b/src/core/CL/kernels/CLWarpPerspectiveKernel.cpp
index a47952fc6b..d6fcb09658 100644
--- a/src/core/CL/kernels/CLWarpPerspectiveKernel.cpp
+++ b/src/core/CL/kernels/CLWarpPerspectiveKernel.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, 2017 ARM Limited.
+ * Copyright (c) 2016-2018 ARM Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -42,9 +42,9 @@ using namespace arm_compute;
namespace
{
-inline void options_add_matrix(std::set<std::string> &options, const float *matrix, size_t size)
+inline void options_add_matrix(std::set<std::string> &options, const std::array<float, 9> &matrix)
{
- for(size_t i = 0; i < size; ++i)
+ for(size_t i = 0; i < 9; ++i)
{
std::stringstream mat_str;
mat_str << "-DMAT" << i << "=" << matrix[i] << " ";
@@ -58,7 +58,7 @@ BorderSize CLWarpPerspectiveKernel::border_size() const
return BorderSize(1);
}
-void CLWarpPerspectiveKernel::configure(const ICLTensor *input, ICLTensor *output, const float *matrix, InterpolationPolicy policy)
+void CLWarpPerspectiveKernel::configure(const ICLTensor *input, ICLTensor *output, const std::array<float, 9> &matrix, InterpolationPolicy policy)
{
ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::U8);
ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(output, 1, DataType::U8);
@@ -69,7 +69,7 @@ void CLWarpPerspectiveKernel::configure(const ICLTensor *input, ICLTensor *outpu
// Create build options
std::set<std::string> options;
- options_add_matrix(options, matrix, 9);
+ options_add_matrix(options, matrix);
options.emplace(("-DDATA_TYPE=" + get_cl_type_from_data_type(input->info()->data_type())));
// Create kernel
diff --git a/src/core/NEON/kernels/NEWarpKernel.cpp b/src/core/NEON/kernels/NEWarpKernel.cpp
index 0fa8278fe3..d04bc07d3a 100644
--- a/src/core/NEON/kernels/NEWarpKernel.cpp
+++ b/src/core/NEON/kernels/NEWarpKernel.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, 2017 ARM Limited.
+ * Copyright (c) 2016-2018 ARM Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -45,7 +45,7 @@ inline uint8_t nearest_interpolation(const uint8_t *in_ptr, int x, int y, size_t
} // namespace
INEWarpKernel::INEWarpKernel()
- : _func(nullptr), _input(nullptr), _output(nullptr), _constant_border_value(0), _matrix(nullptr)
+ : _func(nullptr), _input(nullptr), _output(nullptr), _constant_border_value(0), _matrix()
{
}
@@ -64,11 +64,10 @@ void INEWarpKernel::run(const Window &window, const ThreadInfo &info)
(this->*_func)(window);
}
-void INEWarpKernel::configure(const ITensor *input, ITensor *output, const float *matrix, BorderMode border_mode, uint8_t constant_border_value)
+void INEWarpKernel::configure(const ITensor *input, ITensor *output, const std::array<float, 9> &matrix, BorderMode border_mode, uint8_t constant_border_value)
{
ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::U8);
ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(output, 1, DataType::U8);
- ARM_COMPUTE_ERROR_ON(nullptr == matrix);
_matrix = matrix;
_constant_border_value = constant_border_value;
diff --git a/src/runtime/CL/functions/CLWarpAffine.cpp b/src/runtime/CL/functions/CLWarpAffine.cpp
index f785c75a72..4286cf6ec3 100644
--- a/src/runtime/CL/functions/CLWarpAffine.cpp
+++ b/src/runtime/CL/functions/CLWarpAffine.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, 2017 ARM Limited.
+ * Copyright (c) 2016-2018 ARM Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -31,7 +31,7 @@
using namespace arm_compute;
-void CLWarpAffine::configure(ICLTensor *input, ICLTensor *output, const float *matrix, InterpolationPolicy policy, BorderMode border_mode, uint8_t constant_border_value)
+void CLWarpAffine::configure(ICLTensor *input, ICLTensor *output, const std::array<float, 9> &matrix, InterpolationPolicy policy, BorderMode border_mode, uint8_t constant_border_value)
{
auto k = arm_compute::support::cpp14::make_unique<CLWarpAffineKernel>();
k->configure(input, output, matrix, policy);
diff --git a/src/runtime/CL/functions/CLWarpPerspective.cpp b/src/runtime/CL/functions/CLWarpPerspective.cpp
index b445b3b9c5..4603ee084e 100644
--- a/src/runtime/CL/functions/CLWarpPerspective.cpp
+++ b/src/runtime/CL/functions/CLWarpPerspective.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, 2017 ARM Limited.
+ * Copyright (c) 2016-2018 ARM Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -31,7 +31,7 @@
using namespace arm_compute;
-void CLWarpPerspective::configure(ICLTensor *input, ICLTensor *output, const float *matrix, InterpolationPolicy policy, BorderMode border_mode, uint8_t constant_border_value)
+void CLWarpPerspective::configure(ICLTensor *input, ICLTensor *output, const std::array<float, 9> &matrix, InterpolationPolicy policy, BorderMode border_mode, uint8_t constant_border_value)
{
auto k = arm_compute::support::cpp14::make_unique<CLWarpPerspectiveKernel>();
k->configure(input, output, matrix, policy);
diff --git a/src/runtime/NEON/functions/NEWarpAffine.cpp b/src/runtime/NEON/functions/NEWarpAffine.cpp
index 889d827ed0..105646c114 100644
--- a/src/runtime/NEON/functions/NEWarpAffine.cpp
+++ b/src/runtime/NEON/functions/NEWarpAffine.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, 2017 ARM Limited.
+ * Copyright (c) 2016-2018 ARM Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -32,11 +32,10 @@
using namespace arm_compute;
-void NEWarpAffine::configure(ITensor *input, ITensor *output, const float *matrix, InterpolationPolicy policy, BorderMode border_mode, uint8_t constant_border_value)
+void NEWarpAffine::configure(ITensor *input, ITensor *output, const std::array<float, 9> &matrix, InterpolationPolicy policy, BorderMode border_mode, uint8_t constant_border_value)
{
ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::U8);
ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(output, 1, DataType::U8);
- ARM_COMPUTE_ERROR_ON(nullptr == matrix);
switch(policy)
{
diff --git a/src/runtime/NEON/functions/NEWarpPerspective.cpp b/src/runtime/NEON/functions/NEWarpPerspective.cpp
index ed5d6a0d27..80b97ceafa 100644
--- a/src/runtime/NEON/functions/NEWarpPerspective.cpp
+++ b/src/runtime/NEON/functions/NEWarpPerspective.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, 2017 ARM Limited.
+ * Copyright (c) 2016-2018 ARM Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -32,11 +32,10 @@
using namespace arm_compute;
-void NEWarpPerspective::configure(ITensor *input, ITensor *output, const float *matrix, InterpolationPolicy policy, BorderMode border_mode, uint8_t constant_border_value)
+void NEWarpPerspective::configure(ITensor *input, ITensor *output, const std::array<float, 9> &matrix, InterpolationPolicy policy, BorderMode border_mode, uint8_t constant_border_value)
{
ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::U8);
ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(output, 1, DataType::U8);
- ARM_COMPUTE_ERROR_ON(nullptr == matrix);
switch(policy)
{
diff --git a/tests/benchmark/fixtures/WarpAffineFixture.h b/tests/benchmark/fixtures/WarpAffineFixture.h
index 9f61c6ce1a..e1d6855c83 100644
--- a/tests/benchmark/fixtures/WarpAffineFixture.h
+++ b/tests/benchmark/fixtures/WarpAffineFixture.h
@@ -54,7 +54,7 @@ public:
dst = create_tensor<TensorType>(shape, data_type);
// Create and configure function
- warp_affine_func.configure(&src, &dst, matrix.data(), policy, border_mode, constant_border_value);
+ warp_affine_func.configure(&src, &dst, matrix, policy, border_mode, constant_border_value);
// Allocate tensors
src.allocator()->allocate();
@@ -79,7 +79,7 @@ public:
}
private:
- const std::array<float, 6> matrix{ { -0.9f, -0.6f, -0.3f, 0.3f, 0.6f, 0.9f } };
+ const std::array<float, 9> matrix{ { -0.9f, -0.6f, -0.3f, 0.3f, 0.6f, 0.9f, /* ignored*/ 1.f, 1.f, 1.f } };
TensorType src{};
TensorType dst{};
Function warp_affine_func{};
diff --git a/tests/validation/CL/WarpAffine.cpp b/tests/validation/CL/WarpAffine.cpp
index 7f3001cb57..29f24cc361 100644
--- a/tests/validation/CL/WarpAffine.cpp
+++ b/tests/validation/CL/WarpAffine.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017 ARM Limited.
+ * Copyright (c) 2017-2018 ARM Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -65,8 +65,8 @@ DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(combi
uint8_t constant_border_value = distribution_u8(gen);
// Create the matrix
- std::array<float, 6> matrix{ {} };
- fill_warp_matrix<6>(matrix);
+ std::array<float, 9> matrix{ {} };
+ fill_warp_matrix<9>(matrix);
// Create tensors
CLTensor src = create_tensor<CLTensor>(shape, data_type);
@@ -77,7 +77,7 @@ DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(combi
// Create and configure function
CLWarpAffine warp_affine;
- warp_affine.configure(&src, &dst, matrix.data(), policy, border_mode, constant_border_value);
+ warp_affine.configure(&src, &dst, matrix, policy, border_mode, constant_border_value);
// Validate valid region
const ValidRegion valid_region = shape_to_valid_region(shape);
diff --git a/tests/validation/CL/WarpPerspective.cpp b/tests/validation/CL/WarpPerspective.cpp
index a868e16b9e..e164a8088a 100644
--- a/tests/validation/CL/WarpPerspective.cpp
+++ b/tests/validation/CL/WarpPerspective.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017 ARM Limited.
+ * Copyright (c) 2017-2018 ARM Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -78,7 +78,7 @@ DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(combi
// Create and configure function
CLWarpPerspective warp_perspective;
- warp_perspective.configure(&src, &dst, matrix.data(), policy, border_mode, constant_border_value);
+ warp_perspective.configure(&src, &dst, matrix, policy, border_mode, constant_border_value);
// Validate valid region
const ValidRegion valid_region = shape_to_valid_region(shape);
diff --git a/tests/validation/NEON/WarpAffine.cpp b/tests/validation/NEON/WarpAffine.cpp
index 8c83507e95..6180d6941c 100644
--- a/tests/validation/NEON/WarpAffine.cpp
+++ b/tests/validation/NEON/WarpAffine.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017 ARM Limited.
+ * Copyright (c) 2017-2018 ARM Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -64,8 +64,8 @@ DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(combi
uint8_t constant_border_value = distribution_u8(gen);
// Create the matrix
- std::array<float, 6> matrix{ {} };
- fill_warp_matrix<6>(matrix);
+ std::array<float, 9> matrix{ {} };
+ fill_warp_matrix<9>(matrix);
// Create tensors
Tensor src = create_tensor<Tensor>(shape, data_type);
@@ -76,7 +76,7 @@ DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(combi
// Create and configure function
NEWarpAffine warp_affine;
- warp_affine.configure(&src, &dst, matrix.data(), policy, border_mode, constant_border_value);
+ warp_affine.configure(&src, &dst, matrix, policy, border_mode, constant_border_value);
// Validate valid region
const ValidRegion valid_region = shape_to_valid_region(shape);
diff --git a/tests/validation/NEON/WarpPerspective.cpp b/tests/validation/NEON/WarpPerspective.cpp
index 804c080890..6ec8bc296d 100644
--- a/tests/validation/NEON/WarpPerspective.cpp
+++ b/tests/validation/NEON/WarpPerspective.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017 ARM Limited.
+ * Copyright (c) 2017-2018 ARM Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -78,7 +78,7 @@ DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(combi
// Create and configure function
NEWarpPerspective warp_perspective;
- warp_perspective.configure(&src, &dst, matrix.data(), policy, border_mode, constant_border_value);
+ warp_perspective.configure(&src, &dst, matrix, policy, border_mode, constant_border_value);
// Validate valid region
const ValidRegion valid_region = shape_to_valid_region(shape);
diff --git a/tests/validation/fixtures/WarpAffineFixture.h b/tests/validation/fixtures/WarpAffineFixture.h
index c027072a13..3cbf86f92d 100644
--- a/tests/validation/fixtures/WarpAffineFixture.h
+++ b/tests/validation/fixtures/WarpAffineFixture.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017 ARM Limited.
+ * Copyright (c) 2017-2018 ARM Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -55,11 +55,11 @@ public:
uint8_t constant_border_value = distribution_u8(gen);
// Create the matrix
- std::array<float, 6> matrix{ {} };
- fill_warp_matrix<6>(matrix);
+ std::array<float, 9> matrix{ {} };
+ fill_warp_matrix<9>(matrix);
- _target = compute_target(shape, data_type, matrix.data(), policy, border_mode, constant_border_value);
- _reference = compute_reference(shape, data_type, matrix.data(), policy, border_mode, constant_border_value);
+ _target = compute_target(shape, data_type, matrix, policy, border_mode, constant_border_value);
+ _reference = compute_reference(shape, data_type, matrix, policy, border_mode, constant_border_value);
}
protected:
@@ -69,7 +69,7 @@ protected:
library->fill_tensor_uniform(tensor, 0);
}
- TensorType compute_target(const TensorShape &shape, DataType data_type, const float *matrix, InterpolationPolicy policy, BorderMode border_mode, uint8_t constant_border_value)
+ TensorType compute_target(const TensorShape &shape, DataType data_type, const std::array<float, 9> &matrix, InterpolationPolicy policy, BorderMode border_mode, uint8_t constant_border_value)
{
// Create tensors
TensorType src = create_tensor<TensorType>(shape, data_type);
@@ -97,7 +97,7 @@ protected:
return dst;
}
- SimpleTensor<T> compute_reference(const TensorShape &shape, DataType data_type, const float *matrix, InterpolationPolicy policy, BorderMode border_mode, uint8_t constant_border_value)
+ SimpleTensor<T> compute_reference(const TensorShape &shape, DataType data_type, const std::array<float, 9> &matrix, InterpolationPolicy policy, BorderMode border_mode, uint8_t constant_border_value)
{
// Create reference
SimpleTensor<T> src{ shape, data_type };
@@ -108,7 +108,7 @@ protected:
// Fill reference
fill(src);
- return reference::warp_affine<T>(src, _valid_mask, matrix, policy, border_mode, constant_border_value);
+ return reference::warp_affine<T>(src, _valid_mask, matrix.data(), policy, border_mode, constant_border_value);
}
TensorType _target{};
diff --git a/tests/validation/fixtures/WarpPerspectiveFixture.h b/tests/validation/fixtures/WarpPerspectiveFixture.h
index c804fa6da7..0eba97c47c 100644
--- a/tests/validation/fixtures/WarpPerspectiveFixture.h
+++ b/tests/validation/fixtures/WarpPerspectiveFixture.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017 ARM Limited.
+ * Copyright (c) 2017-2018 ARM Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -64,8 +64,8 @@ public:
std::array<float, 9> matrix = { { 0 } };
fill_warp_matrix<9>(matrix);
- _target = compute_target(input_shape, vmask_shape, matrix.data(), policy, border_mode, constant_border_value, data_type);
- _reference = compute_reference(input_shape, vmask_shape, matrix.data(), policy, border_mode, constant_border_value, data_type);
+ _target = compute_target(input_shape, vmask_shape, matrix, policy, border_mode, constant_border_value, data_type);
+ _reference = compute_reference(input_shape, vmask_shape, matrix, policy, border_mode, constant_border_value, data_type);
}
protected:
@@ -75,7 +75,8 @@ protected:
library->fill_tensor_uniform(tensor, 0);
}
- TensorType compute_target(const TensorShape &shape, const TensorShape &vmask_shape, const float *matrix, InterpolationPolicy policy, BorderMode border_mode, uint8_t constant_border_value,
+ TensorType compute_target(const TensorShape &shape, const TensorShape &vmask_shape, const std::array<float, 9> &matrix, InterpolationPolicy policy, BorderMode border_mode,
+ uint8_t constant_border_value,
DataType data_type)
{
// Create tensors
@@ -105,7 +106,8 @@ protected:
return dst;
}
- SimpleTensor<T> compute_reference(const TensorShape &shape, const TensorShape &vmask_shape, const float *matrix, InterpolationPolicy policy, BorderMode border_mode, uint8_t constant_border_value,
+ SimpleTensor<T> compute_reference(const TensorShape &shape, const TensorShape &vmask_shape, const std::array<float, 9> &matrix, InterpolationPolicy policy, BorderMode border_mode,
+ uint8_t constant_border_value,
DataType data_type)
{
ARM_COMPUTE_ERROR_ON(data_type != DataType::U8);
@@ -120,7 +122,7 @@ protected:
fill(src);
// Compute reference
- return reference::warp_perspective<T>(src, _valid_mask, matrix, policy, border_mode, constant_border_value);
+ return reference::warp_perspective<T>(src, _valid_mask, matrix.data(), policy, border_mode, constant_border_value);
}
TensorType _target{};