diff options
author | Gian Marco <gianmarco.iodice@arm.com> | 2018-02-05 15:07:36 +0000 |
---|---|---|
committer | Anthony Barbier <anthony.barbier@arm.com> | 2018-11-02 16:47:18 +0000 |
commit | 1aede367b9ecab66dfaf6fb07f95720064afdea4 (patch) | |
tree | 4ff21a0bd82bef963cd7b7a8013c0dceedb78fd5 | |
parent | 1167487ea8e54a76d0a3625e0aa84e2ad9ffd317 (diff) | |
download | ComputeLibrary-1aede367b9ecab66dfaf6fb07f95720064afdea4.tar.gz |
COMPMID-765 - Extended GEMM benchmark
Added new benchmarks GEMM in order to evaluate the performance when the
input matrix B has to be reshaped only once
Change-Id: I1c4790213704ce57ea7b28f6f362c56edccd1eb9
Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/118910
Tested-by: Jenkins <bsgcomp@arm.com>
Reviewed-by: Michele DiGiorgio <michele.digiorgio@arm.com>
Reviewed-by: Anthony Barbier <anthony.barbier@arm.com>
-rw-r--r-- | arm_compute/runtime/GLES_COMPUTE/functions/GCGEMM.h | 18 | ||||
-rw-r--r-- | src/runtime/GLES_COMPUTE/functions/GCGEMM.cpp | 8 | ||||
-rw-r--r-- | tests/benchmark/CL/GEMM.cpp | 21 | ||||
-rw-r--r-- | tests/benchmark/GLES_COMPUTE/GEMM.cpp | 18 | ||||
-rw-r--r-- | tests/benchmark/NEON/GEMM.cpp | 14 | ||||
-rw-r--r-- | tests/benchmark/fixtures/GEMMFixture.h | 4 |
6 files changed, 57 insertions, 26 deletions
diff --git a/arm_compute/runtime/GLES_COMPUTE/functions/GCGEMM.h b/arm_compute/runtime/GLES_COMPUTE/functions/GCGEMM.h index f2484cd801..8ddfae1169 100644 --- a/arm_compute/runtime/GLES_COMPUTE/functions/GCGEMM.h +++ b/arm_compute/runtime/GLES_COMPUTE/functions/GCGEMM.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -58,14 +58,16 @@ public: * * @note Whilst the first input tensor can be a vector, the second input tensor must be at least a matrix * - * @param[in] a First input tensor (Matrix or Vector A). Data types supported: F32 - * @param[in] b Second input tensor (Matrix B). Data type supported: same as @p a. - * @param[in] c Third input tensor (Matrix C). It can be a nullptr if just the multiplication between @p a and @p b is needed. Data type supported: same as @p a. - * @param[out] output Output tensor. Data type supported: same as @p a - * @param[in] alpha Weight of the matrix product - * @param[in] beta Weight of matrix C + * @param[in] a First input tensor (Matrix or Vector A). Data types supported: F32 + * @param[in] b Second input tensor (Matrix B). Data type supported: same as @p a. + * @param[in] c Third input tensor (Matrix C). It can be a nullptr if just the multiplication between @p a and @p b is needed. Data type supported: same as @p a. + * @param[out] output Output tensor. Data type supported: same as @p a + * @param[in] alpha Weight of the matrix product + * @param[in] beta Weight of matrix C + * @param[in] gemm_info (Optional) Specifies if the matrix A and/or matrix B have been reshaped and + * if the reshape of matrix B should happen only for the first run */ - void configure(const IGCTensor *a, const IGCTensor *b, const IGCTensor *c, IGCTensor *output, float alpha, float beta); + void configure(const IGCTensor *a, const IGCTensor *b, const IGCTensor *c, IGCTensor *output, float alpha, float beta, const GEMMInfo &gemm_info = GEMMInfo()); // Inherited methods overridden: void run() override; diff --git a/src/runtime/GLES_COMPUTE/functions/GCGEMM.cpp b/src/runtime/GLES_COMPUTE/functions/GCGEMM.cpp index 7aa2d421eb..5122c20504 100644 --- a/src/runtime/GLES_COMPUTE/functions/GCGEMM.cpp +++ b/src/runtime/GLES_COMPUTE/functions/GCGEMM.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -45,10 +45,14 @@ GCGEMM::GCGEMM() { } -void GCGEMM::configure(const IGCTensor *a, const IGCTensor *b, const IGCTensor *c, IGCTensor *output, float alpha, float beta) +void GCGEMM::configure(const IGCTensor *a, const IGCTensor *b, const IGCTensor *c, IGCTensor *output, float alpha, float beta, const GEMMInfo &gemm_info) { ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(a, 1, DataType::F32); ARM_COMPUTE_ERROR_ON_MISMATCHING_DATA_TYPES(a, b, output); + ARM_COMPUTE_ERROR_ON_MSG(gemm_info.is_a_reshaped(), "Matrix A already reshaped is not supported"); + ARM_COMPUTE_ERROR_ON_MSG(gemm_info.is_b_reshaped(), "Matrix B already reshaped is not supported"); + ARM_COMPUTE_ERROR_ON_MSG(gemm_info.reshape_b_only_on_first_run(), "Reshape matrix B only on first run is not supported"); + ARM_COMPUTE_UNUSED(gemm_info); if(c != nullptr) { diff --git a/tests/benchmark/CL/GEMM.cpp b/tests/benchmark/CL/GEMM.cpp index 615b492ee0..60362b43e1 100644 --- a/tests/benchmark/CL/GEMM.cpp +++ b/tests/benchmark/CL/GEMM.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018 ARM Limited. + * Copyright (c) 2017-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -41,17 +41,26 @@ namespace test { namespace { -const auto data_types = framework::dataset::make("DataType", { DataType::F16, DataType::F32 }); +const auto data_types = framework::dataset::make("DataType", { DataType::F16, DataType::F32 }); +const auto reshape_b_only_once = framework::dataset::make("ReshapeBOnlyOnce", { false, true }); } // namespace using CLGEMMFixture = GEMMFixture<CLTensor, CLGEMM, CLAccessor>; TEST_SUITE(CL) -REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV1GEMM, CLGEMMFixture, framework::DatasetMode::ALL, framework::dataset::combine(datasets::GoogLeNetInceptionV1GEMMDataset(), data_types)); -REGISTER_FIXTURE_DATA_TEST_CASE(MatrixMultiplyGEMM, CLGEMMFixture, framework::DatasetMode::ALL, framework::dataset::combine(datasets::MatrixMultiplyGEMMDataset(), data_types)); -REGISTER_FIXTURE_DATA_TEST_CASE(GoogleNetGEMM, CLGEMMFixture, framework::DatasetMode::NIGHTLY, framework::dataset::combine(datasets::GoogleNetGEMMDataset(), data_types)); -REGISTER_FIXTURE_DATA_TEST_CASE(AlexNetGEMM, CLGEMMFixture, framework::DatasetMode::NIGHTLY, framework::dataset::combine(datasets::AlexNetGEMMDataset(), data_types)); +REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV1GEMM, CLGEMMFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV1GEMMDataset(), + data_types), + reshape_b_only_once)); +REGISTER_FIXTURE_DATA_TEST_CASE(MatrixMultiplyGEMM, CLGEMMFixture, framework::DatasetMode::ALL, framework::dataset::combine(framework::dataset::combine(datasets::MatrixMultiplyGEMMDataset(), + data_types), + reshape_b_only_once)); +REGISTER_FIXTURE_DATA_TEST_CASE(GoogleNetGEMM, CLGEMMFixture, framework::DatasetMode::NIGHTLY, framework::dataset::combine(framework::dataset::combine(datasets::GoogleNetGEMMDataset(), data_types), + reshape_b_only_once)); +REGISTER_FIXTURE_DATA_TEST_CASE(AlexNetGEMM, CLGEMMFixture, framework::DatasetMode::NIGHTLY, framework::dataset::combine(framework::dataset::combine(datasets::AlexNetGEMMDataset(), + data_types), + reshape_b_only_once)); TEST_SUITE_END() } // namespace test diff --git a/tests/benchmark/GLES_COMPUTE/GEMM.cpp b/tests/benchmark/GLES_COMPUTE/GEMM.cpp index 69d8e54919..97c92c679b 100644 --- a/tests/benchmark/GLES_COMPUTE/GEMM.cpp +++ b/tests/benchmark/GLES_COMPUTE/GEMM.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -40,16 +40,24 @@ namespace test { namespace { -const auto data_types = framework::dataset::make("DataType", { DataType::F32 }); +const auto data_types = framework::dataset::make("DataType", { DataType::F32 }); +const auto reshape_b_only_once = framework::dataset::make("ReshapeBOnlyOnce", { false }); } // namespace using GCGEMMFixture = GEMMFixture<GCTensor, GCGEMM, GCAccessor>; TEST_SUITE(GC) -REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV1GEMM, GCGEMMFixture, framework::DatasetMode::ALL, framework::dataset::combine(datasets::GoogLeNetInceptionV1GEMMDataset(), data_types)); -REGISTER_FIXTURE_DATA_TEST_CASE(MatrixMultiplyGEMM, GCGEMMFixture, framework::DatasetMode::ALL, framework::dataset::combine(datasets::MatrixMultiplyGEMMDataset(), data_types)); -REGISTER_FIXTURE_DATA_TEST_CASE(GoogleNetGEMM, GCGEMMFixture, framework::DatasetMode::NIGHTLY, framework::dataset::combine(datasets::GoogleNetGEMMDataset(), data_types)); +REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV1GEMM, GCGEMMFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV1GEMMDataset(), + data_types), + reshape_b_only_once)); +REGISTER_FIXTURE_DATA_TEST_CASE(MatrixMultiplyGEMM, GCGEMMFixture, framework::DatasetMode::ALL, framework::dataset::combine(framework::dataset::combine(datasets::MatrixMultiplyGEMMDataset(), + data_types), + reshape_b_only_once)); +REGISTER_FIXTURE_DATA_TEST_CASE(GoogleNetGEMM, GCGEMMFixture, framework::DatasetMode::NIGHTLY, framework::dataset::combine(framework::dataset::combine(datasets::GoogleNetGEMMDataset(), + data_types), + reshape_b_only_once)); TEST_SUITE_END() } // namespace test diff --git a/tests/benchmark/NEON/GEMM.cpp b/tests/benchmark/NEON/GEMM.cpp index 1d6ea8df7f..473d6429fb 100644 --- a/tests/benchmark/NEON/GEMM.cpp +++ b/tests/benchmark/NEON/GEMM.cpp @@ -48,15 +48,23 @@ const auto data_types = framework::dataset::make("DataType", #endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */ DataType::F32 }); +const auto reshape_b_only_once = framework::dataset::make("ReshapeBOnlyOnce", { false, true }); } // namespace using NEGEMMFixture = GEMMFixture<Tensor, NEGEMM, Accessor>; TEST_SUITE(NEON) -REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV1GEMM, NEGEMMFixture, framework::DatasetMode::ALL, framework::dataset::combine(datasets::GoogLeNetInceptionV1GEMMDataset(), data_types)); -REGISTER_FIXTURE_DATA_TEST_CASE(MatrixMultiplyGEMM, NEGEMMFixture, framework::DatasetMode::ALL, framework::dataset::combine(datasets::MatrixMultiplyGEMMDataset(), data_types)); -REGISTER_FIXTURE_DATA_TEST_CASE(GoogleNetGEMM, NEGEMMFixture, framework::DatasetMode::NIGHTLY, framework::dataset::combine(datasets::GoogleNetGEMMDataset(), data_types)); +REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV1GEMM, NEGEMMFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV1GEMMDataset(), + data_types), + reshape_b_only_once)); +REGISTER_FIXTURE_DATA_TEST_CASE(MatrixMultiplyGEMM, NEGEMMFixture, framework::DatasetMode::ALL, framework::dataset::combine(framework::dataset::combine(datasets::MatrixMultiplyGEMMDataset(), + data_types), + reshape_b_only_once)); +REGISTER_FIXTURE_DATA_TEST_CASE(GoogleNetGEMM, NEGEMMFixture, framework::DatasetMode::NIGHTLY, framework::dataset::combine(framework::dataset::combine(datasets::GoogleNetGEMMDataset(), + data_types), + reshape_b_only_once)); TEST_SUITE_END() } // namespace test diff --git a/tests/benchmark/fixtures/GEMMFixture.h b/tests/benchmark/fixtures/GEMMFixture.h index e958d4fdde..3a308d9ada 100644 --- a/tests/benchmark/fixtures/GEMMFixture.h +++ b/tests/benchmark/fixtures/GEMMFixture.h @@ -40,7 +40,7 @@ class GEMMFixture : public framework::Fixture { public: template <typename...> - void setup(TensorShape shape_a, TensorShape shape_b, TensorShape shape_c, TensorShape shape_dst, float alpha, float beta, DataType data_type) + void setup(TensorShape shape_a, TensorShape shape_b, TensorShape shape_c, TensorShape shape_dst, float alpha, float beta, DataType data_type, bool reshape_b_only_on_first_run) { constexpr int fixed_point_position = 4; @@ -51,7 +51,7 @@ public: dst = create_tensor<TensorType>(shape_dst, data_type, 1, fixed_point_position); // Create and configure function - gemm.configure(&a, &b, &c, &dst, alpha, beta); + gemm.configure(&a, &b, &c, &dst, alpha, beta, GEMMInfo(false, false, reshape_b_only_on_first_run)); // Allocate tensors a.allocator()->allocate(); |