aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGunes Bayir <gunes.bayir@arm.com>2023-07-06 15:51:12 +0100
committerGunes Bayir <gunes.bayir@arm.com>2023-07-07 11:19:01 +0000
commit5153fe4b989768907ed588ecdb859d6a81b72992 (patch)
tree879bc23c32cc2f5190d8c3e051ea1c7a17e06048
parentacea4071a7f457bab696dc3c895ba47d60345541 (diff)
downloadComputeLibrary-5153fe4b989768907ed588ecdb859d6a81b72992.tar.gz
Fix unsupported configuration in CLFullyConnected validation
When the weights to CLFullyConnected layer are not constant and the weights need reshaping, we prefer MatMul kernels instead of Gemm-based ones. The bias addition is currently unsupported in MatMull, but the validate() function does not account for this properly. This patch fixes the validation of this function. Resolves: COMPMID-6338 Change-Id: I5c240191ae8e369753691c43ab4a30d4ae1776b0 Signed-off-by: Gunes Bayir <gunes.bayir@arm.com> Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/9882 Benchmark: Arm Jenkins <bsgcomp@arm.com> Tested-by: Arm Jenkins <bsgcomp@arm.com> Reviewed-by: Viet-Hoa Do <viet-hoa.do@arm.com> Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
-rw-r--r--src/gpu/cl/operators/ClFullyConnected.cpp6
-rw-r--r--src/gpu/cl/operators/ClFullyConnected.h4
2 files changed, 3 insertions, 7 deletions
diff --git a/src/gpu/cl/operators/ClFullyConnected.cpp b/src/gpu/cl/operators/ClFullyConnected.cpp
index c62e4b531f..b7ba8b89fa 100644
--- a/src/gpu/cl/operators/ClFullyConnected.cpp
+++ b/src/gpu/cl/operators/ClFullyConnected.cpp
@@ -115,7 +115,7 @@ Status validate_mm(const ITensorInfo &src, const ITensorInfo &weights, const ITe
{
// If weights are dynamic, data is not batched, and bias is nullptr validate using matmul.
const bool weights_reshaped = fc_info.transpose_weights ? fc_info.are_weights_reshaped : true;
- const bool use_matmul = !weights.are_values_constant() && !weights_reshaped && !(dst.dimension(1) > 1) && (bias != nullptr);
+ const bool use_matmul = !weights.are_values_constant() && !weights_reshaped && !(dst.dimension(1) > 1) && (bias == nullptr);
if(use_matmul)
{
@@ -317,7 +317,7 @@ void ClFullyConnected::configure(const CLCompileContext &compile_context, ITenso
// Note: No matmul with biases for the moment.
const bool is_batched_fc_layer = dst->dimension(1) > 1;
_dynamic_weights = !weights->are_values_constant() && !_are_weights_reshaped;
- _use_matmul = _dynamic_weights && !is_batched_fc_layer && !(biases);
+ _use_matmul = _dynamic_weights && !is_batched_fc_layer && (biases == nullptr);
// With the Fully Connected layer we can have 4 different cases:
// 1) Convolution layer -> Fully Connected layer without batches
@@ -442,7 +442,7 @@ Status ClFullyConnected::validate(const ITensorInfo *src, const ITensorInfo *wei
// Note: Pre-Shaped RHS is a deprecated use case and is therefore not supported with matmul.
const bool dynamic_weights = !weights->are_values_constant() && !weights_reshaped;
const bool is_batched_fc_layer = dst->dimension(1) > 1;
- const bool use_matmul = dynamic_weights && !is_batched_fc_layer && (biases != nullptr);
+ const bool use_matmul = dynamic_weights && !is_batched_fc_layer && (biases == nullptr);
const ITensorInfo &flatten_src = TensorInfo(src->clone()->set_is_resizable(true).reset_padding().set_tensor_shape(compute_flatten_shape(src)).set_data_layout(DataLayout::NCHW));
const ITensorInfo &reshaped_weights = TensorInfo(weights->clone()->set_is_resizable(true).reset_padding().set_tensor_shape(compute_transposed_shape(*weights)));
diff --git a/src/gpu/cl/operators/ClFullyConnected.h b/src/gpu/cl/operators/ClFullyConnected.h
index 5dc68c1bbe..9a5ba40510 100644
--- a/src/gpu/cl/operators/ClFullyConnected.h
+++ b/src/gpu/cl/operators/ClFullyConnected.h
@@ -132,11 +132,7 @@ private:
TensorInfo _flattened_src{};
TensorInfo _converted_weights{};
TensorInfo _reshaped_weights{};
-
- // Saved tensor shapes for reshaping when using matmul
- TensorShape _lhs_shape_original{};
TensorInfo _lhs_to_use{};
-
TensorInfo _weights_to_use{};
int _weights_to_use_idx{ ACL_SRC_1 };