diff options
author | Finn Williams <Finn.Williams@arm.com> | 2021-03-22 17:51:06 +0000 |
---|---|---|
committer | finn.williams <finn.williams@arm.com> | 2021-04-07 16:42:38 +0000 |
commit | 4422ceca976a88aac49b21808a43e465bc87a35e (patch) | |
tree | d4f7f3d86394f74b679c907ad3f7fc7f4537933f /src/armnn/layers/QLstmLayer.hpp | |
parent | b70ec417989490a2a72c66ecd6c737df1c094f4c (diff) | |
download | armnn-4422ceca976a88aac49b21808a43e465bc87a35e.tar.gz |
Fix graph copy memory spike
* Change layer storage of ConstTensors to std::shared_ptr<ConstCpuTensorHandle>
* Change clone to share ConstTensor rather than copy
* Remove uses of non-const GetTensor() call
* Reduce scope of non-optimized network in ExeNet, so memory can be released after use
Signed-off-by: Finn Williams <Finn.Williams@arm.com>
Change-Id: Ibb2c7309d12411d21405bd6024c76bcdf5404545
Diffstat (limited to 'src/armnn/layers/QLstmLayer.hpp')
-rw-r--r-- | src/armnn/layers/QLstmLayer.hpp | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/src/armnn/layers/QLstmLayer.hpp b/src/armnn/layers/QLstmLayer.hpp index 70cc4f2b15..09a020dc1d 100644 --- a/src/armnn/layers/QLstmLayer.hpp +++ b/src/armnn/layers/QLstmLayer.hpp @@ -14,65 +14,65 @@ class ScopedCpuTensorHandle; struct QLstmBasicParameters { /// A unique pointer to represent 2D weights tensor with dimensions [num_units, inputSize] (QSymmS8). - std::unique_ptr<ScopedCpuTensorHandle> m_InputToForgetWeights; + std::shared_ptr<ConstCpuTensorHandle> m_InputToForgetWeights; /// A unique pointer to represent 2D weights tensor with dimensions [num_units, inputSize] (QSymmS8). - std::unique_ptr<ScopedCpuTensorHandle> m_InputToCellWeights; + std::shared_ptr<ConstCpuTensorHandle> m_InputToCellWeights; /// A unique pointer to represent 2D weights tensor with dimensions [num_units, inputSize] (QSymmS8). - std::unique_ptr<ScopedCpuTensorHandle> m_InputToOutputWeights; + std::shared_ptr<ConstCpuTensorHandle> m_InputToOutputWeights; /// A unique pointer to represent 2D weights tensor with dimensions [num_units, outputSize] (QSymmS8). - std::unique_ptr<ScopedCpuTensorHandle> m_RecurrentToForgetWeights; + std::shared_ptr<ConstCpuTensorHandle> m_RecurrentToForgetWeights; /// A unique pointer to represent 2D weights tensor with dimensions [num_units, outputSize] (QSymmS8). - std::unique_ptr<ScopedCpuTensorHandle> m_RecurrentToCellWeights; + std::shared_ptr<ConstCpuTensorHandle> m_RecurrentToCellWeights; /// A unique pointer to represent 2D weights tensor with dimensions [num_units, outputSize] (QSymmS8). - std::unique_ptr<ScopedCpuTensorHandle> m_RecurrentToOutputWeights; + std::shared_ptr<ConstCpuTensorHandle> m_RecurrentToOutputWeights; /// A unique pointer to represent 1D bias tensor with dimensions [num_units] (int32). - std::unique_ptr<ScopedCpuTensorHandle> m_ForgetGateBias; + std::shared_ptr<ConstCpuTensorHandle> m_ForgetGateBias; /// A unique pointer to represent 1D bias tensor with dimensions [num_units] (int32). - std::unique_ptr<ScopedCpuTensorHandle> m_CellBias; + std::shared_ptr<ConstCpuTensorHandle> m_CellBias; /// A unique pointer to represent 1D bias tensor with dimensions [num_units] (int32). - std::unique_ptr<ScopedCpuTensorHandle> m_OutputGateBias; + std::shared_ptr<ConstCpuTensorHandle> m_OutputGateBias; }; struct QLstmOptProjectionParameters { /// A unique pointer to represent 2D weights tensor with dimensions [output_size, num_units] (QSymmS8). - std::unique_ptr<ScopedCpuTensorHandle> m_ProjectionWeights; + std::shared_ptr<ConstCpuTensorHandle> m_ProjectionWeights; /// A unique pointer to represent 1D weights tensor with dimensions [output_size] (int32). - std::unique_ptr<ScopedCpuTensorHandle> m_ProjectionBias; + std::shared_ptr<ConstCpuTensorHandle> m_ProjectionBias; }; struct QLstmOptPeepholeParameters { /// A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16). - std::unique_ptr<ScopedCpuTensorHandle> m_CellToInputWeights; + std::shared_ptr<ConstCpuTensorHandle> m_CellToInputWeights; /// A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16). - std::unique_ptr<ScopedCpuTensorHandle> m_CellToForgetWeights; + std::shared_ptr<ConstCpuTensorHandle> m_CellToForgetWeights; /// A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16). - std::unique_ptr<ScopedCpuTensorHandle> m_CellToOutputWeights; + std::shared_ptr<ConstCpuTensorHandle> m_CellToOutputWeights; }; struct QLstmOptCifgParameters { /// A unique pointer to represent 2D weights tensor with dimensions [input_size, num_units] (QSymmS8). - std::unique_ptr<ScopedCpuTensorHandle> m_InputToInputWeights; + std::shared_ptr<ConstCpuTensorHandle> m_InputToInputWeights; /// A unique pointer to represent 2D weights tensor with dimensions [input_size, num_units] (QSymmS8). - std::unique_ptr<ScopedCpuTensorHandle> m_RecurrentToInputWeights; + std::shared_ptr<ConstCpuTensorHandle> m_RecurrentToInputWeights; /// A unique pointer to represent 1D weights tensor with dimensions [num_units] (int32). - std::unique_ptr<ScopedCpuTensorHandle> m_InputGateBias; + std::shared_ptr<ConstCpuTensorHandle> m_InputGateBias; }; struct QLstmOptLayerNormParameters { /// A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16). - std::unique_ptr<ScopedCpuTensorHandle> m_InputLayerNormWeights; + std::shared_ptr<ConstCpuTensorHandle> m_InputLayerNormWeights; /// A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16). - std::unique_ptr<ScopedCpuTensorHandle> m_ForgetLayerNormWeights; + std::shared_ptr<ConstCpuTensorHandle> m_ForgetLayerNormWeights; /// A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16). - std::unique_ptr<ScopedCpuTensorHandle> m_CellLayerNormWeights; + std::shared_ptr<ConstCpuTensorHandle> m_CellLayerNormWeights; /// A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16). - std::unique_ptr<ScopedCpuTensorHandle> m_OutputLayerNormWeights; + std::shared_ptr<ConstCpuTensorHandle> m_OutputLayerNormWeights; }; /// This layer represents a QLstm operation. |