ArmNN
 24.02
ClLstmFloatWorkload.hpp
Go to the documentation of this file.
1 //
2 // Copyright © 2017 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #pragma once
7 
8 #include <armnn/Descriptors.hpp>
9 #include <armnn/LstmParams.hpp>
12 
13 #include <arm_compute/runtime/CL/functions/CLLSTMLayer.h>
14 
15 namespace armnn
16 {
17 
18 class ClLstmFloatWorkload : public FloatWorkload<LstmQueueDescriptor>
19 {
20 public:
21  ClLstmFloatWorkload(const LstmQueueDescriptor& descriptor,
22  const WorkloadInfo& info,
23  const arm_compute::CLCompileContext& clCompileContext);
24  void Execute() const override;
25  // Replace input tensor handle with the given TensorHandle
26  void ReplaceInputTensorHandle(ITensorHandle* tensorHandle, unsigned int slot) override;
27 
28  // Replace output tensor handle with the given TensorHandle
29  void ReplaceOutputTensorHandle(ITensorHandle* tensorHandle, unsigned int slot) override;
30 private:
31  mutable arm_compute::CLLSTMLayer m_LstmLayer;
32  virtual void Reconfigure();
33 
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;
51  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;
55 
56  std::unique_ptr<arm_compute::CLTensor> m_ScratchBuffer;
57 
58  void FreeUnusedTensors();
59 };
60 
61 arm_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,
65  const LstmInputParamsInfo& paramsInfo);
66 } //namespace armnn
Descriptors.hpp
WorkloadData.hpp
armnn::ClLstmFloatWorkload
Definition: ClLstmFloatWorkload.hpp:18
armnn::TensorInfo
Definition: Tensor.hpp:152
armnn::ClLstmFloatWorkload::ReplaceOutputTensorHandle
void ReplaceOutputTensorHandle(ITensorHandle *tensorHandle, unsigned int slot) override
Definition: ClLstmFloatWorkload.cpp:413
armnn::ITensorHandle
Definition: ITensorHandle.hpp:16
armnn::TypedWorkload
Definition: Workload.hpp:101
LstmParams.hpp
armnn::WorkloadInfo
Contains information about TensorInfos of a layer.
Definition: WorkloadInfo.hpp:16
Workload.hpp
armnn::ClLstmFloatWorkload::Execute
void Execute() const override
Definition: ClLstmFloatWorkload.cpp:238
armnn::ClLstmFloatWorkloadValidate
arm_compute::Status ClLstmFloatWorkloadValidate(const TensorInfo &input, const TensorInfo &outputStateIn, const TensorInfo &cellStateIn, const TensorInfo &scratchBuffer, const TensorInfo &outputStateOut, const TensorInfo &cellStateOut, const TensorInfo &output, const LstmDescriptor &descriptor, const LstmInputParamsInfo &paramsInfo)
Definition: ClLstmFloatWorkload.cpp:244
armnn::BoostLogSeverityMapping::info
@ info
armnn::LstmDescriptor
An LstmDescriptor for the LstmLayer.
Definition: Descriptors.hpp:1102
armnn::LstmQueueDescriptor
Definition: WorkloadData.hpp:400
armnn::Status
Status
Definition: Types.hpp:42
armnn
Copyright (c) 2021 ARM Limited and Contributors.
Definition: 01_00_quick_start.dox:6
armnn::LstmInputParamsInfo
Definition: LstmParams.hpp:63
armnn::ClLstmFloatWorkload::ReplaceInputTensorHandle
void ReplaceInputTensorHandle(ITensorHandle *tensorHandle, unsigned int slot) override
Definition: ClLstmFloatWorkload.cpp:396
armnn::ClLstmFloatWorkload::ClLstmFloatWorkload
ClLstmFloatWorkload(const LstmQueueDescriptor &descriptor, const WorkloadInfo &info, const arm_compute::CLCompileContext &clCompileContext)
Definition: ClLstmFloatWorkload.cpp:23