From 24486d6554b30df4f9d2bcdf87f408baa742b42f Mon Sep 17 00:00:00 2001 From: Sanghoon Lee Date: Mon, 4 Sep 2017 15:51:21 +0100 Subject: COMPMID-496: Port DepthConvert to new validation Change-Id: I4b5faeadcaea2878687e0c3844f5fe47fd0a3c8d Reviewed-on: http://mpd-gerrit.cambridge.arm.com/87320 Tested-by: Kaizen Reviewed-by: Moritz Pflanzer --- tests/validation_old/TensorOperations.h | 76 --------------------------------- 1 file changed, 76 deletions(-) (limited to 'tests/validation_old/TensorOperations.h') diff --git a/tests/validation_old/TensorOperations.h b/tests/validation_old/TensorOperations.h index dd53c046df..73e7661a1c 100644 --- a/tests/validation_old/TensorOperations.h +++ b/tests/validation_old/TensorOperations.h @@ -577,82 +577,6 @@ void accumulate_weighted(const Tensor &in, Tensor &out, float alpha) } } -// Depth conversion -template < typename T1, typename T2, typename std::enable_if < std::is_integral::value &&is_floating_point::value, int >::type = 0 > -void depth_convert(const Tensor &in, Tensor &out, ConvertPolicy policy, uint32_t shift) -{ - using namespace fixed_point_arithmetic; - - const int fixed_point_position = in.fixed_point_position(); - for(int i = 0; i < in.num_elements(); ++i) - { - out[i] = static_cast(fixed_point(in[i], fixed_point_position, true)); - } -} - -template < typename T1, typename T2, typename std::enable_if < is_floating_point::value &&std::is_integral::value, int >::type = 0 > -void depth_convert(const Tensor &in, Tensor &out, ConvertPolicy policy, uint32_t shift) -{ - using namespace fixed_point_arithmetic; - - const int fixed_point_position = out.fixed_point_position(); - for(int i = 0; i < in.num_elements(); ++i) - { - out[i] = fixed_point(in[i], fixed_point_position).raw(); - } -} - -template < typename T1, typename T2, typename std::enable_if < std::is_integral::value &&std::is_integral::value &&!std::is_same::value, int >::type = 0 > -void depth_convert(const Tensor &in, Tensor &out, ConvertPolicy policy, uint32_t shift) -{ - // Up-casting - if(std::numeric_limits::digits <= std::numeric_limits::digits) - { - for(int i = 0; i < in.num_elements(); ++i) - { - out[i] = static_cast(in[i]) << shift; - } - } - // Down-casting - else - { - for(int i = 0; i < in.num_elements(); ++i) - { - T1 val = in[i] >> shift; - out[i] = ((policy == ConvertPolicy::SATURATE) ? saturate_cast(val) : static_cast(val)); - } - } -} - -template < typename T1, typename T2, typename std::enable_if < std::is_integral::value &&std::is_integral::value &&std::is_same::value, int >::type = 0 > -void depth_convert(const Tensor &in, Tensor &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(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(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::value &&is_floating_point::value, int >::type = 0 > -void depth_convert(const Tensor &in, Tensor &out, ConvertPolicy policy, uint32_t shift) -{ - for(int i = 0; i < in.num_elements(); ++i) - { - out[i] = static_cast(in[i]); - } -} - // Gaussian3x3 filter template ::value>::type> void gaussian3x3(const Tensor &in, Tensor &out, BorderMode border_mode, T constant_border_value) -- cgit v1.2.1