From 47a899017e67556ffffef78571c9be61dd7bc3f0 Mon Sep 17 00:00:00 2001 From: Michele Di Giorgio Date: Mon, 9 Mar 2020 19:32:33 +0000 Subject: COMPMID-3237: Implement NEQLSTMLayer COMPMID-3082: Extend NEQLSTMLayer with enhancements Change-Id: I88175b7bf69494a4eae510b74176fe8a0d6cd770 Signed-off-by: Michele Di Giorgio Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/2969 Tested-by: Arm Jenkins Reviewed-by: Sang-Hoon Park Reviewed-by: Sheri Zhang Comments-Addressed: Arm Jenkins --- arm_compute/core/utils/misc/InfoHelpers.h | 35 ++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) (limited to 'arm_compute/core/utils') diff --git a/arm_compute/core/utils/misc/InfoHelpers.h b/arm_compute/core/utils/misc/InfoHelpers.h index b572de2433..8cf701c124 100644 --- a/arm_compute/core/utils/misc/InfoHelpers.h +++ b/arm_compute/core/utils/misc/InfoHelpers.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 ARM Limited. + * Copyright (c) 2019-2020 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -26,6 +26,7 @@ #include "arm_compute/core/Error.h" #include "arm_compute/core/Types.h" +#include "arm_compute/runtime/common/LSTMParams.h" namespace arm_compute { @@ -58,6 +59,38 @@ inline bool is_relu6(ActivationLayerInfo activation_info) && activation_info.a() == 6.f; return activation_info.enabled() && (is_lu_bounded_relu || is_bounded_relu); } + +/** Build LSTMParams object by extracting the metadata from each + * tensor. + * + * @param[in] lstm_params The LSTMParams object containing the tensors. + * @param[out] lstm_params_info The LSTMParams to be constructed. + * + */ +template +inline void build_lstm_params_tensor_info(const LSTMParams &lstm_params, + LSTMParams *lstm_params_info) +{ + if(lstm_params.has_peephole_opt()) + { + ARM_COMPUTE_ERROR_ON_NULLPTR(lstm_params.cell_to_forget_weights(), lstm_params.cell_to_output_weights()); + lstm_params_info->set_peephole_params(lstm_params.cell_to_forget_weights()->info(), lstm_params.cell_to_output_weights()->info()); + } + if(lstm_params.has_projection()) + { + ARM_COMPUTE_ERROR_ON_NULLPTR(lstm_params.projection_weights()); + lstm_params_info->set_projection_params(lstm_params.projection_weights()->info(), + lstm_params.projection_bias() != nullptr ? lstm_params.projection_bias()->info() : nullptr); + } + if(!lstm_params.has_cifg_opt()) + { + ARM_COMPUTE_ERROR_ON_NULLPTR(lstm_params.input_to_input_weights(), lstm_params.recurrent_to_input_weights(), lstm_params.input_gate_bias()); + + const ITensorInfo *cell_to_input_weights_info = (lstm_params.has_peephole_opt()) ? lstm_params.cell_to_input_weights()->info() : nullptr; + lstm_params_info->set_cifg_params(lstm_params.input_to_input_weights()->info(), lstm_params.recurrent_to_input_weights()->info(), + cell_to_input_weights_info, lstm_params.input_gate_bias()->info()); + } +} } // namespace info_helpers } // namespace utils } // namespace arm_compute -- cgit v1.2.1