diff options
author | Michele Di Giorgio <michele.digiorgio@arm.com> | 2020-06-10 16:34:50 +0100 |
---|---|---|
committer | Michele Di Giorgio <michele.digiorgio@arm.com> | 2020-06-12 09:26:10 +0000 |
commit | 11c562c94fa6a0399aff798bfd970ed8c1942730 (patch) | |
tree | 6eb2ca628659b1b579a2f99a6dd598d5e6ee5ea2 /src/runtime | |
parent | d004a7a707feab36e51f51cfc9eb2cb70729d5ad (diff) | |
download | ComputeLibrary-11c562c94fa6a0399aff798bfd970ed8c1942730.tar.gz |
COMPMID-3527: QLSTM should allow nullptr for optional projection bias
Change-Id: I5568ca1e9383f3960886f211d8320fc4525a8804
Signed-off-by: Michele Di Giorgio <michele.digiorgio@arm.com>
Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/3326
Reviewed-by: James Conroy <james.conroy@arm.com>
Reviewed-by: Georgios Pinitas <georgios.pinitas@arm.com>
Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Tested-by: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'src/runtime')
-rw-r--r-- | src/runtime/CL/functions/CLQLSTMLayer.cpp | 16 | ||||
-rw-r--r-- | src/runtime/NEON/functions/NEQLSTMLayer.cpp | 15 |
2 files changed, 25 insertions, 6 deletions
diff --git a/src/runtime/CL/functions/CLQLSTMLayer.cpp b/src/runtime/CL/functions/CLQLSTMLayer.cpp index 524c7b3aae..f063410972 100644 --- a/src/runtime/CL/functions/CLQLSTMLayer.cpp +++ b/src/runtime/CL/functions/CLQLSTMLayer.cpp @@ -211,6 +211,10 @@ void CLQLSTMLayer::configure(const CLCompileContext &compile_context, const ICLT if(_has_projection) { _projection_reduction.configure(compile_context, _projection_weights, &_projection_eff_bias, GEMMLowpReductionKernelInfo(output_size, false, lstm_params.hidden_state_zero(), true)); + if(_projection_bias != nullptr) + { + _projection_bias_add.configure(compile_context, ArithmeticOperation::ADD, _projection_bias, &_projection_eff_bias, &_projection_eff_bias, ConvertPolicy::SATURATE); + } } // Pre-transpose weights to be used in GEMM. @@ -640,6 +644,12 @@ Status CLQLSTMLayer::validate(const ITensorInfo *input, ARM_COMPUTE_RETURN_ON_ERROR(CLGEMMLowpMatrixAReductionKernel::validate(lstm_params.projection_weights(), &projection_eff_bias_info, GEMMLowpReductionKernelInfo(output_size, false, lstm_params.hidden_state_zero(), true))); + if(lstm_params.projection_bias() != nullptr) + { + ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(lstm_params.projection_bias(), 1, DataType::S32); + ARM_COMPUTE_RETURN_ON_ERROR(CLSaturatedArithmeticOperationKernel::validate(ArithmeticOperation::ADD, lstm_params.projection_bias(), &projection_eff_bias_info, + &projection_eff_bias_info, ConvertPolicy::SATURATE)); + } } const TensorInfo input_weights_transposed(TensorShape(num_units, input_size), 1, input_to_forget_weights->data_type(), input_to_forget_weights->quantization_info()); @@ -832,7 +842,6 @@ Status CLQLSTMLayer::validate(const ITensorInfo *input, if(lstm_params.has_projection()) { ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(recurrent_to_forget_weights, lstm_params.projection_weights()); - ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(forget_gate_bias, lstm_params.projection_bias()); ARM_COMPUTE_RETURN_ERROR_ON(qoutput_state_in.scale == 0); const UniformQuantizationInfo qprojection = lstm_params.projection_weights()->quantization_info().uniform(); @@ -1095,10 +1104,11 @@ void CLQLSTMLayer::prepare() if(_has_projection) { + _projection_eff_bias.allocator()->allocate(); + CLScheduler::get().enqueue(_projection_reduction); if(_projection_bias != nullptr) { - _projection_eff_bias.allocator()->allocate(); - CLScheduler::get().enqueue(_projection_reduction); + CLScheduler::get().enqueue(_projection_bias_add); _projection_bias->mark_as_unused(); } diff --git a/src/runtime/NEON/functions/NEQLSTMLayer.cpp b/src/runtime/NEON/functions/NEQLSTMLayer.cpp index 083e3fddb4..a22c669ca7 100644 --- a/src/runtime/NEON/functions/NEQLSTMLayer.cpp +++ b/src/runtime/NEON/functions/NEQLSTMLayer.cpp @@ -189,6 +189,10 @@ void NEQLSTMLayer::configure(const ITensor *input, if(_has_projection) { _projection_reduction.configure(_projection_weights, &_projection_eff_bias, GEMMLowpReductionKernelInfo(output_size, false, lstm_params.hidden_state_zero(), true)); + if(_projection_bias != nullptr) + { + _projection_bias_add.configure(_projection_bias, &_projection_eff_bias, &_projection_eff_bias, ConvertPolicy::SATURATE); + } } // Pre-transpose weights to be used in GEMM. @@ -612,6 +616,11 @@ Status NEQLSTMLayer::validate(const ITensorInfo *input, ARM_COMPUTE_RETURN_ON_ERROR(NEGEMMLowpMatrixAReductionKernel::validate(lstm_params.projection_weights(), &projection_eff_bias_info, GEMMLowpReductionKernelInfo(output_size, false, lstm_params.hidden_state_zero(), true))); + if(lstm_params.projection_bias() != nullptr) + { + ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(lstm_params.projection_bias(), 1, DataType::S32); + ARM_COMPUTE_RETURN_ON_ERROR(NEArithmeticAdditionKernel::validate(lstm_params.projection_bias(), &projection_eff_bias_info, &projection_eff_bias_info, ConvertPolicy::SATURATE)); + } } const TensorInfo input_weights_transposed(TensorShape(num_units, input_size), 1, input_to_forget_weights->data_type(), input_to_forget_weights->quantization_info()); @@ -804,7 +813,6 @@ Status NEQLSTMLayer::validate(const ITensorInfo *input, if(lstm_params.has_projection()) { ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(recurrent_to_forget_weights, lstm_params.projection_weights()); - ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(forget_gate_bias, lstm_params.projection_bias()); ARM_COMPUTE_RETURN_ERROR_ON(qoutput_state_in.scale == 0); const UniformQuantizationInfo qprojection = lstm_params.projection_weights()->quantization_info().uniform(); @@ -1065,10 +1073,11 @@ void NEQLSTMLayer::prepare() if(_has_projection) { + _projection_eff_bias.allocator()->allocate(); + NEScheduler::get().schedule(&_projection_reduction, Window::DimY); if(_projection_bias != nullptr) { - _projection_eff_bias.allocator()->allocate(); - NEScheduler::get().schedule(&_projection_reduction, Window::DimY); + NEScheduler::get().schedule(&_projection_bias_add, Window::DimY); _projection_bias->mark_as_unused(); } |