aboutsummaryrefslogtreecommitdiff
path: root/tests/validation/TensorOperations.h
diff options
context:
space:
mode:
authorGeorgios Pinitas <georgios.pinitas@arm.com>2017-07-12 12:30:40 +0100
committerAnthony Barbier <anthony.barbier@arm.com>2018-09-17 14:16:42 +0100
commite222941f931b1d44bb29e5827b6df748e60cefc4 (patch)
tree1a54a60750caa998527e5c6b2a494047cb3ccc23 /tests/validation/TensorOperations.h
parentbbd3d6045ba6480be350c0b1610048ee6c9c050f (diff)
downloadComputeLibrary-e222941f931b1d44bb29e5827b6df748e60cefc4.tar.gz
COMPMID-401: Implement FixedPointPosition conversion for NEON.
Adds support of changing the fixed point position of a tensor in DepthConvert. Change-Id: Ic3b50a4628fac7497a0217d92941c9d6f64d21cb Reviewed-on: http://mpd-gerrit.cambridge.arm.com/80438 Reviewed-by: Anthony Barbier <anthony.barbier@arm.com> Tested-by: Kaizen <jeremy.johnson+kaizengerrit@arm.com>
Diffstat (limited to 'tests/validation/TensorOperations.h')
-rw-r--r--tests/validation/TensorOperations.h26
1 files changed, 23 insertions, 3 deletions
diff --git a/tests/validation/TensorOperations.h b/tests/validation/TensorOperations.h
index 9e6f5cf5d1..882c9e07e1 100644
--- a/tests/validation/TensorOperations.h
+++ b/tests/validation/TensorOperations.h
@@ -519,7 +519,7 @@ void box3x3(const Tensor<T> &in, Tensor<T> &out, BorderMode border_mode, T const
}
// Depth conversion
-template < typename T1, typename T2, typename std::enable_if < std::is_integral<T1>::value &&is_floating_point<T2>::value, int >::type = 0 >
+template < typename T1, typename T2, typename std::enable_if < std::is_integral<T1>::value &&std::is_floating_point<T2>::value, int >::type = 0 >
void depth_convert(const Tensor<T1> &in, Tensor<T2> &out, ConvertPolicy policy, uint32_t shift)
{
using namespace fixed_point_arithmetic;
@@ -531,7 +531,7 @@ void depth_convert(const Tensor<T1> &in, Tensor<T2> &out, ConvertPolicy policy,
}
}
-template < typename T1, typename T2, typename std::enable_if < is_floating_point<T1>::value &&std::is_integral<T2>::value, int >::type = 0 >
+template < typename T1, typename T2, typename std::enable_if < std::is_floating_point<T1>::value &&std::is_integral<T2>::value, int >::type = 0 >
void depth_convert(const Tensor<T1> &in, Tensor<T2> &out, ConvertPolicy policy, uint32_t shift)
{
using namespace fixed_point_arithmetic;
@@ -543,7 +543,7 @@ void depth_convert(const Tensor<T1> &in, Tensor<T2> &out, ConvertPolicy policy,
}
}
-template < typename T1, typename T2, typename std::enable_if < std::is_integral<T1>::value &&std::is_integral<T2>::value, int >::type = 0 >
+template < typename T1, typename T2, typename std::enable_if < std::is_integral<T1>::value &&std::is_integral<T2>::value &&!std::is_same<T1, T2>::value, int >::type = 0 >
void depth_convert(const Tensor<T1> &in, Tensor<T2> &out, ConvertPolicy policy, uint32_t shift)
{
// Up-casting
@@ -565,6 +565,26 @@ void depth_convert(const Tensor<T1> &in, Tensor<T2> &out, ConvertPolicy policy,
}
}
+template < typename T1, typename T2, typename std::enable_if < std::is_integral<T1>::value &&std::is_integral<T2>::value &&std::is_same<T1, T2>::value, int >::type = 0 >
+void depth_convert(const Tensor<T1> &in, Tensor<T2> &out, ConvertPolicy policy, uint32_t shift)
+{
+ using namespace fixed_point_arithmetic;
+ bool is_in_place = (&in == &out);
+
+ const int fixed_point_position_in = in.fixed_point_position();
+ const int fixed_point_position_out = (is_in_place) ? static_cast<int>(shift) : out.fixed_point_position();
+
+ if(!is_in_place || (fixed_point_position_in != fixed_point_position_out))
+ {
+ for(int i = 0; i < in.num_elements(); ++i)
+ {
+ auto x = fixed_point<T2>(in[i], fixed_point_position_in, true);
+ x.rescale(fixed_point_position_out);
+ out[i] = x.raw();
+ }
+ }
+}
+
template < typename T1, typename T2, typename std::enable_if < is_floating_point<T1>::value &&is_floating_point<T2>::value, int >::type = 0 >
void depth_convert(const Tensor<T1> &in, Tensor<T2> &out, ConvertPolicy policy, uint32_t shift)
{