diff options
Diffstat (limited to 'tests/validation_old/TensorOperations.h')
-rw-r--r-- | tests/validation_old/TensorOperations.h | 76 |
1 files changed, 0 insertions, 76 deletions
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<T> &in, Tensor<T> &out, float alpha) } } -// Depth conversion -template < typename T1, typename T2, typename std::enable_if < std::is_integral<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) -{ - 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<float>(fixed_point<T1>(in[i], fixed_point_position, true)); - } -} - -template < typename T1, typename T2, typename std::enable_if < 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; - - const int fixed_point_position = out.fixed_point_position(); - for(int i = 0; i < in.num_elements(); ++i) - { - out[i] = fixed_point<T2>(in[i], fixed_point_position).raw(); - } -} - -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 - if(std::numeric_limits<T1>::digits <= std::numeric_limits<T2>::digits) - { - for(int i = 0; i < in.num_elements(); ++i) - { - out[i] = static_cast<T2>(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<T2>(val) : static_cast<T2>(val)); - } - } -} - -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) -{ - for(int i = 0; i < in.num_elements(); ++i) - { - out[i] = static_cast<T2>(in[i]); - } -} - // Gaussian3x3 filter template <typename T, typename = typename std::enable_if<std::is_integral<T>::value>::type> void gaussian3x3(const Tensor<T> &in, Tensor<T> &out, BorderMode border_mode, T constant_border_value) |