diff options
author | Mohammed Suhail Munshi <MohammedSuhail.Munshi@arm.com> | 2022-04-27 13:49:51 +0100 |
---|---|---|
committer | Suhail M <MohammedSuhail.Munshi@arm.com> | 2022-05-06 10:56:44 +0000 |
commit | bc5c407b52c2ea3762b7efa526a971d8180d25c7 (patch) | |
tree | dd66afe0a7955c57c2b027fb93a06761642988c3 /tests/validation/fixtures/GEMMFixture.h | |
parent | c5849580868b7ad101572f1b90c87f3daa06385d (diff) | |
download | ComputeLibrary-bc5c407b52c2ea3762b7efa526a971d8180d25c7.tar.gz |
Extend GEMM to support batch matmul operation
- Added values to supports transpose operations prior to gemm.
Resolves: COMPMID-5072
Change-Id: Ia8bc39b3ded8a507c2314a4926f1f7809da03649
Signed-off-by: Mohammed Suhail Munshi <MohammedSuhail.Munshi@arm.com>
Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/7485
Reviewed-by: Gian Marco Iodice <gianmarco.iodice@arm.com>
Tested-by: Arm Jenkins <bsgcomp@arm.com>
Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'tests/validation/fixtures/GEMMFixture.h')
-rw-r--r-- | tests/validation/fixtures/GEMMFixture.h | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/tests/validation/fixtures/GEMMFixture.h b/tests/validation/fixtures/GEMMFixture.h index 8b748032fe..be3a3cd735 100644 --- a/tests/validation/fixtures/GEMMFixture.h +++ b/tests/validation/fixtures/GEMMFixture.h @@ -48,7 +48,7 @@ namespace test { namespace validation { -template <typename TensorType, typename AccessorType, typename FunctionType, typename T, bool disable_c = false, bool reinterpret_input_as_3d = false, bool reinterpret_output_as_3d = false> +template <typename TensorType, typename AccessorType, typename FunctionType, typename T, bool disable_c = false, bool reinterpret_input_as_3d = false, bool reinterpret_output_as_3d = false, bool pretranspose_a = false, bool pretranspose_b = false> class GEMMValidationFixture : public framework::Fixture { public: @@ -170,9 +170,30 @@ protected: } } + // Define transposed shapes + TensorShape a_transposed_shape(a.shape().y(), a.shape().x()); + TensorShape b_transposed_shape(b.shape().y(), b.shape().x()); + + // Define transposed tensors + SimpleTensor<T> a_transposed{ a_transposed_shape, data_type }; + SimpleTensor<T> b_transposed{ b_transposed_shape, data_type }; + + // pretranspose a if necessary + if(pretranspose_a) + { + transpose_matrix<T>(a, a_transposed); + } + + // pretranspose b if necessary + if(pretranspose_b) + { + transpose_matrix<T>(b, b_transposed); + } + // Setting beta to 0 will effectively disable C for the // computation of the reference: alpha * A * B + 0 * C - return reference::gemm<T>(a, b, c, alpha, disable_c ? 0.f : beta); + // Use transposed tensors if boolean enabled else use original tensors + return reference::gemm<T>((pretranspose_a) ? a_transposed : a, (pretranspose_b) ? b_transposed : b, c, alpha, disable_c ? 0.f : beta); } TensorType _target{}; |