aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/CL
diff options
context:
space:
mode:
authorGeorgios Pinitas <georgios.pinitas@arm.com>2019-02-06 18:08:04 +0000
committerManuel Bottini <manuel.bottini@arm.com>2019-02-07 16:07:16 +0000
commit4f85982a55ae417edde6864304aeb1d69972973e (patch)
tree094f88d2138ee20e57cfe482a89cd68833e91954 /src/runtime/CL
parentebc3a90721fe4a41b8e141466894d4d7185c01b7 (diff)
downloadComputeLibrary-4f85982a55ae417edde6864304aeb1d69972973e.tar.gz
COMPMID-1923: Input is ignored if peephole optimization is enabled in
LSTM Change-Id: I9e6c4fe279aafaf7f77af453785a8f677868a25a Signed-off-by: Georgios Pinitas <georgios.pinitas@arm.com> Reviewed-on: https://review.mlplatform.org/639 Reviewed-by: Michalis Spyrou <michalis.spyrou@arm.com> Tested-by: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'src/runtime/CL')
-rw-r--r--src/runtime/CL/functions/CLLSTMLayer.cpp30
1 files changed, 18 insertions, 12 deletions
diff --git a/src/runtime/CL/functions/CLLSTMLayer.cpp b/src/runtime/CL/functions/CLLSTMLayer.cpp
index 8a27d68d4a..f01b1b898f 100644
--- a/src/runtime/CL/functions/CLLSTMLayer.cpp
+++ b/src/runtime/CL/functions/CLLSTMLayer.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018 ARM Limited.
+ * Copyright (c) 2018-2019 ARM Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -111,8 +111,8 @@ void CLLSTMLayer::configure(const ICLTensor *input,
_forget_gate_out2.allocator()->allocate();
_memory_group.manage(&_forget_gate_out5);
_accum_forget_gate1.configure(ArithmeticOperation::ADD, &_forget_gate_out1, &_forget_gate_out3, &_forget_gate_out5, ConvertPolicy::SATURATE);
+ _forget_gate_out1.allocator()->allocate();
CLTensor *forget_gate_out = &_forget_gate_out5;
-
if(lstm_params.has_peephole_opt())
{
_forget_gate_out4.allocator()->init(TensorInfo(cell_state_shape, 1, input->info()->data_type()));
@@ -129,17 +129,18 @@ void CLLSTMLayer::configure(const ICLTensor *input,
{
_forget_gate_out3.allocator()->allocate();
}
- _activation_forget_gate.configure(forget_gate_out, &_forget_gate_out1, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LOGISTIC));
+ _activation_forget_gate.configure(forget_gate_out, nullptr, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LOGISTIC));
// Configure block that calculates the input gate
// input_gate = Activation(input * input_to_input_weights + output_state * recurrent_to_input_weights + PixelWiseMul(cell_state, cell_to_input_weights) + input_gate_bias), without CIFG
// input_gate = 1 - forget_gate, with CIFG
_input_gate_out1.allocator()->init(TensorInfo(cell_state_shape, 1, input->info()->data_type()));
+ CLTensor *input_gate_out = &_input_gate_out1;
if(lstm_params.has_cifg_opt())
{
_memory_group.manage(&_input_gate_out1);
_ones.allocator()->init(TensorInfo(cell_state_shape, 1, input->info()->data_type()));
- _subtract_input_gate.configure(ArithmeticOperation::SUB, &_ones, &_forget_gate_out1, &_input_gate_out1, ConvertPolicy::SATURATE);
+ _subtract_input_gate.configure(ArithmeticOperation::SUB, &_ones, forget_gate_out, &_input_gate_out1, ConvertPolicy::SATURATE);
_ones.allocator()->allocate();
_run_cifg_opt = true;
}
@@ -161,16 +162,22 @@ void CLLSTMLayer::configure(const ICLTensor *input,
_input_gate_out2.allocator()->allocate();
_memory_group.manage(&_input_gate_out4);
_accum_input_gate1.configure(ArithmeticOperation::ADD, &_input_gate_out1, &_input_gate_out3, &_input_gate_out4, ConvertPolicy::SATURATE);
+ _input_gate_out3.allocator()->allocate();
+ input_gate_out = &_input_gate_out4;
if(_run_peephole_opt)
{
_memory_group.manage(&_input_gate_out5);
_pixelwise_mul_input_gate.configure(cell_state_in, lstm_params.cell_to_input_weights(), &_input_gate_out5, 1, ConvertPolicy::SATURATE, RoundingPolicy::TO_NEAREST_EVEN);
_accum_input_gate2.configure(&_input_gate_out4, &_input_gate_out5, &_input_gate_out1, ConvertPolicy::SATURATE);
+ _input_gate_out4.allocator()->allocate();
_input_gate_out5.allocator()->allocate();
+ input_gate_out = &_input_gate_out1;
}
- _input_gate_out3.allocator()->allocate();
- _input_gate_out4.allocator()->allocate();
- _activation_input_gate.configure(&_input_gate_out1, nullptr, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LOGISTIC));
+ else
+ {
+ _input_gate_out1.allocator()->allocate();
+ }
+ _activation_input_gate.configure(input_gate_out, nullptr, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LOGISTIC));
}
// Configure block that calculates the cell state
@@ -193,10 +200,9 @@ void CLLSTMLayer::configure(const ICLTensor *input,
_accum_cell_state1.configure(ArithmeticOperation::ADD, &_cell_state_out1, &_cell_state_out3, &_cell_state_out4, ConvertPolicy::SATURATE);
_activation_cell_state.configure(&_cell_state_out4, nullptr, activation_info);
_memory_group.manage(&_cell_state_out5);
- _pixelwise_mul_cell_state1.configure(&_cell_state_out4, &_input_gate_out1, &_cell_state_out5, 1, ConvertPolicy::SATURATE, RoundingPolicy::TO_NEAREST_EVEN);
+ _pixelwise_mul_cell_state1.configure(&_cell_state_out4, input_gate_out, &_cell_state_out5, 1, ConvertPolicy::SATURATE, RoundingPolicy::TO_NEAREST_EVEN);
_cell_state_out4.allocator()->allocate();
- _pixelwise_mul_cell_state2.configure(&_forget_gate_out1, cell_state_in, &_cell_state_out3, 1, ConvertPolicy::SATURATE, RoundingPolicy::TO_NEAREST_EVEN);
- _forget_gate_out1.allocator()->allocate();
+ _pixelwise_mul_cell_state2.configure(forget_gate_out, cell_state_in, &_cell_state_out3, 1, ConvertPolicy::SATURATE, RoundingPolicy::TO_NEAREST_EVEN);
_accum_cell_state2.configure(ArithmeticOperation::ADD, &_cell_state_out5, &_cell_state_out3, &_cell_state_out1, ConvertPolicy::SATURATE);
_cell_state_out3.allocator()->allocate();
_cell_state_out5.allocator()->allocate();
@@ -284,13 +290,13 @@ void CLLSTMLayer::configure(const ICLTensor *input,
std::vector<ICLTensor *> scratch_inputs;
if(!lstm_params.has_cifg_opt())
{
- scratch_inputs.emplace_back(&_input_gate_out1);
+ scratch_inputs.emplace_back(input_gate_out);
}
scratch_inputs.emplace_back(&_cell_state_out1);
scratch_inputs.emplace_back(forget_gate_out);
scratch_inputs.emplace_back(output_gate_out);
_concat_scratch_buffer.configure(scratch_inputs, scratch_buffer);
- _input_gate_out1.allocator()->allocate();
+ input_gate_out->allocator()->allocate();
_cell_state_out1.allocator()->allocate();
forget_gate_out->allocator()->allocate();
output_gate_out->allocator()->allocate();