diff options
author | Moritz Pflanzer <moritz.pflanzer@arm.com> | 2017-08-02 14:51:36 +0100 |
---|---|---|
committer | Anthony Barbier <anthony.barbier@arm.com> | 2018-09-17 14:16:42 +0100 |
commit | 4dfc235367e602a366952a8495679e339d7a7263 (patch) | |
tree | e01c63ed0d63e81f33b00c414af68610d393c276 /tests/validation/TensorOperations.h | |
parent | 218cc52ce6f0ebf052346650d1b2004e7201f348 (diff) | |
download | ComputeLibrary-4dfc235367e602a366952a8495679e339d7a7263.tar.gz |
COMPMID-415: Move GEMM to new validation
Change-Id: Ie32f981c86fa1b01905d2776b0d0a0a47b228f0b
Reviewed-on: http://mpd-gerrit.cambridge.arm.com/82538
Tested-by: Kaizen <jeremy.johnson+kaizengerrit@arm.com>
Reviewed-by: Anthony Barbier <anthony.barbier@arm.com>
Diffstat (limited to 'tests/validation/TensorOperations.h')
-rw-r--r-- | tests/validation/TensorOperations.h | 73 |
1 files changed, 0 insertions, 73 deletions
diff --git a/tests/validation/TensorOperations.h b/tests/validation/TensorOperations.h index f4d2110387..6e6d1f5115 100644 --- a/tests/validation/TensorOperations.h +++ b/tests/validation/TensorOperations.h @@ -592,79 +592,6 @@ void gaussian5x5(const Tensor<T> &in, Tensor<T> &out, BorderMode border_mode, T } } -// Matrix multiplication for floating point type -template <typename T, typename std::enable_if<is_floating_point<T>::value, int>::type * = nullptr> -void gemm(const Tensor<T> &in1, const Tensor<T> &in2, const Tensor<T> &in3, Tensor<T> &out, float alpha, float beta) -{ - const int M = out.shape().y(); - const int N = out.shape().x(); - const int K = in1.shape().x(); - - for(int r = 0; r < M; ++r) - { - for(int c = 0; c < N; ++c) - { - T acc(0); - - for(int k = 0; k < K; ++k) - { - const T a0 = in1[r * K + k]; - const T b0 = in2[k * N + c]; - - acc += a0 * b0; - } - - // Finalize the result: A * B * alpha + C * beta - const T c0 = in3[c + r * N]; - out[c + r * N] = alpha * acc + beta * c0; - } - } -} - -// Matrix multiplication for fixed point type -template <typename T, typename std::enable_if<std::is_integral<T>::value, int>::type * = nullptr> -void gemm(const Tensor<T> &in1, const Tensor<T> &in2, const Tensor<T> &in3, Tensor<T> &out, float alpha, float beta) -{ - using namespace fixed_point_arithmetic; - - using promoted_type = typename fixed_point_arithmetic::traits::promote<T>::type; - - const int M = out.shape().y(); - const int N = out.shape().x(); - const int K = in1.shape().x(); - const int8_t fixed_point_position = static_cast<int8_t>(in1.fixed_point_position()); - - const fixed_point<T> alpha_q(alpha, fixed_point_position); - const fixed_point<T> beta_q(beta, fixed_point_position); - - for(int r = 0; r < M; ++r) - { - for(int c = 0; c < N; ++c) - { - fixed_point<promoted_type> acc_q(0, fixed_point_position); - - for(int k = 0; k < K; ++k) - { - const fixed_point<promoted_type> a0_q(in1[r * K + k], fixed_point_position, true); - const fixed_point<promoted_type> b0_q(in2[k * N + c], fixed_point_position, true); - const fixed_point<promoted_type> axb_q = a0_q * b0_q; - - acc_q = axb_q + acc_q; - } - - // Finalize the result: A * B * alpha + C * beta - const fixed_point<T> c0_q(in3[c + r * N], fixed_point_position, true); - - fixed_point<T> res_q(acc_q); - res_q = alpha_q * res_q; - res_q = (c0_q * beta_q) + res_q; - - // Store the result - out[c + r * N] = res_q.raw(); - } - } -} - // Non linear filter template <typename T> void non_linear_filter(const Tensor<T> &in, Tensor<T> &out, NonLinearFilterFunction function, unsigned int mask_size, |