blob: 54c5c600dcbfcbd1d262391a02efbb1f72db0439 [file] [log] [blame]
arovir019e53a352018-08-31 15:26:35 +01001//
Teresa Charlin588cbdf2022-01-19 15:55:37 +00002// Copyright © 2017 Arm Ltd and Contributors. All rights reserved.
David Beckecb56cd2018-09-05 12:52:57 +01003// SPDX-License-Identifier: MIT
arovir019e53a352018-08-31 15:26:35 +01004//
5
6#pragma once
7
Matthew Bentham39ef3e52020-01-20 10:09:09 +00008#include <armnn/Descriptors.hpp>
9#include <armnn/LstmParams.hpp>
Colm Donelan0c479742021-12-10 12:43:54 +000010#include <armnn/backends/Workload.hpp>
11#include <armnn/backends/WorkloadData.hpp>
arovir019e53a352018-08-31 15:26:35 +010012
Matthew Bentham9b3e7382020-02-05 21:39:55 +000013#include <arm_compute/runtime/CL/functions/CLLSTMLayer.h>
Matthew Bentham14e46692018-09-20 15:35:30 +010014
arovir019e53a352018-08-31 15:26:35 +010015namespace armnn
16{
17
18class ClLstmFloatWorkload : public FloatWorkload<LstmQueueDescriptor>
19{
20public:
Sadik Armagane9444752020-12-02 11:28:58 +000021 ClLstmFloatWorkload(const LstmQueueDescriptor& descriptor,
22 const WorkloadInfo& info,
23 const arm_compute::CLCompileContext& clCompileContext);
arovir019e53a352018-08-31 15:26:35 +010024 void Execute() const override;
David Monahanec819992022-02-10 14:47:13 +000025 // Replace input tensor handle with the given TensorHandle
26 void ReplaceInputTensorHandle(ITensorHandle* tensorHandle, unsigned int slot) override;
arovir019e53a352018-08-31 15:26:35 +010027
David Monahanec819992022-02-10 14:47:13 +000028 // Replace output tensor handle with the given TensorHandle
29 void ReplaceOutputTensorHandle(ITensorHandle* tensorHandle, unsigned int slot) override;
arovir019e53a352018-08-31 15:26:35 +010030private:
31 mutable arm_compute::CLLSTMLayer m_LstmLayer;
David Monahanec819992022-02-10 14:47:13 +000032 virtual void Reconfigure();
arovir019e53a352018-08-31 15:26:35 +010033
34 std::unique_ptr<arm_compute::CLTensor> m_InputToInputWeightsTensor;
35 std::unique_ptr<arm_compute::CLTensor> m_InputToForgetWeightsTensor;
36 std::unique_ptr<arm_compute::CLTensor> m_InputToCellWeightsTensor;
37 std::unique_ptr<arm_compute::CLTensor> m_InputToOutputWeightsTensor;
38 std::unique_ptr<arm_compute::CLTensor> m_RecurrentToInputWeightsTensor;
39 std::unique_ptr<arm_compute::CLTensor> m_RecurrentToForgetWeightsTensor;
40 std::unique_ptr<arm_compute::CLTensor> m_RecurrentToCellWeightsTensor;
41 std::unique_ptr<arm_compute::CLTensor> m_RecurrentToOutputWeightsTensor;
42 std::unique_ptr<arm_compute::CLTensor> m_CellToInputWeightsTensor;
43 std::unique_ptr<arm_compute::CLTensor> m_CellToForgetWeightsTensor;
44 std::unique_ptr<arm_compute::CLTensor> m_CellToOutputWeightsTensor;
45 std::unique_ptr<arm_compute::CLTensor> m_InputGateBiasTensor;
46 std::unique_ptr<arm_compute::CLTensor> m_ForgetGateBiasTensor;
47 std::unique_ptr<arm_compute::CLTensor> m_CellBiasTensor;
48 std::unique_ptr<arm_compute::CLTensor> m_OutputGateBiasTensor;
49 std::unique_ptr<arm_compute::CLTensor> m_ProjectionWeightsTensor;
50 std::unique_ptr<arm_compute::CLTensor> m_ProjectionBiasTensor;
Jan Eilersa2ec9092019-07-08 15:56:59 +010051 std::unique_ptr<arm_compute::CLTensor> m_InputLayerNormWeightsTensor;
52 std::unique_ptr<arm_compute::CLTensor> m_ForgetLayerNormWeightsTensor;
53 std::unique_ptr<arm_compute::CLTensor> m_CellLayerNormWeightsTensor;
54 std::unique_ptr<arm_compute::CLTensor> m_OutputLayerNormWeightsTensor;
arovir019e53a352018-08-31 15:26:35 +010055
56 std::unique_ptr<arm_compute::CLTensor> m_ScratchBuffer;
57
58 void FreeUnusedTensors();
59};
60
61arm_compute::Status ClLstmFloatWorkloadValidate(const TensorInfo& input, const TensorInfo& outputStateIn,
62 const TensorInfo& cellStateIn, const TensorInfo& scratchBuffer,
63 const TensorInfo& outputStateOut, const TensorInfo& cellStateOut,
64 const TensorInfo& output, const LstmDescriptor &descriptor,
Jan Eilersd01a83c2019-07-03 18:20:40 +010065 const LstmInputParamsInfo& paramsInfo);
arovir019e53a352018-08-31 15:26:35 +010066} //namespace armnn