diff options
author | Jakub Sujak <jakub.sujak@arm.com> | 2023-03-29 11:16:18 +0100 |
---|---|---|
committer | Jakub Sujak <jakub.sujak@arm.com> | 2023-04-04 14:09:21 +0000 |
commit | 617ed50000532877296fff93973590a8ab67f96d (patch) | |
tree | d571654a2c31dfb6d5ec1529160b9f3d3348938c /src/runtime/CL | |
parent | f26ea2f8cc957a1e6faf0361dea805fb2e236061 (diff) | |
download | ComputeLibrary-617ed50000532877296fff93973590a8ab67f96d.tar.gz |
Support dynamic weights for Fully Connected layers on GPU
The fully connected function and operator running on GPU have been adapted to support dynamic weights.
Dynamic weights require the reshape and data layout conversion of weight tensors at runtime in the prepare stage of the operator. The implementation for GPU is identical to the CPU implementation.
This patch also deprecates the `are_weights_reshaped` option in Fully Connected.
Resolves: COMPMID-5870
Change-Id: I28f967695879d82cc91a928d95308a4e0e52a597
Signed-off-by: Jakub Sujak <jakub.sujak@arm.com>
Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/9403
Tested-by: Arm Jenkins <bsgcomp@arm.com>
Reviewed-by: Viet-Hoa Do <viet-hoa.do@arm.com>
Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Benchmark: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'src/runtime/CL')
-rw-r--r-- | src/runtime/CL/functions/CLFullyConnectedLayer.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/runtime/CL/functions/CLFullyConnectedLayer.cpp b/src/runtime/CL/functions/CLFullyConnectedLayer.cpp index 02b2042a6c..1c162db79a 100644 --- a/src/runtime/CL/functions/CLFullyConnectedLayer.cpp +++ b/src/runtime/CL/functions/CLFullyConnectedLayer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2021 Arm Limited. + * Copyright (c) 2017-2021, 2023 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -46,6 +46,7 @@ struct CLFullyConnectedLayer::Impl experimental::MemoryRequirements aux_mem_req{}; bool is_prepared{ false }; + bool dynamic_weights{ false }; }; CLFullyConnectedLayer::CLFullyConnectedLayer(std::shared_ptr<IMemoryManager> memory_manager, IWeightsManager *weights_manager) @@ -96,6 +97,12 @@ void CLFullyConnectedLayer::configure(const CLCompileContext &compile_context, c _impl->run_pack.add_tensor(ACL_SRC_0, input); _impl->run_pack.add_tensor(ACL_DST, output); } + + _impl->dynamic_weights = + !weights->info()->are_values_constant() && + fc_info.transpose_weights && + !fc_info.are_weights_reshaped && + !fc_info.retain_internal_weights; } Status CLFullyConnectedLayer::validate(const ITensorInfo *input, const ITensorInfo *weights, const ITensorInfo *biases, const ITensorInfo *output, @@ -106,7 +113,10 @@ Status CLFullyConnectedLayer::validate(const ITensorInfo *input, const ITensorIn void CLFullyConnectedLayer::run() { - prepare(); + if(!_impl->dynamic_weights) + { + prepare(); + } MemoryGroupResourceScope scope_mg(_impl->memory_group); _impl->op->run(_impl->run_pack); |