From 4af561666b0ce5c12164447a5f7eb9722abb85f8 Mon Sep 17 00:00:00 2001 From: Francis Murtagh Date: Tue, 20 Apr 2021 16:37:55 +0100 Subject: IVGCVSW-5816 Constant memory access * Add new class ManagedConstTensorHandle to Unmap when out of scope * Integrate into existing layers that have constants * Add unit tests Signed-off-by: Francis Murtagh Change-Id: I0a05e14e438804b37e9862e76b5ca329483f6b45 --- src/armnn/layers/TransposeConvolution2dLayer.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/armnn/layers/TransposeConvolution2dLayer.cpp') diff --git a/src/armnn/layers/TransposeConvolution2dLayer.cpp b/src/armnn/layers/TransposeConvolution2dLayer.cpp index 8f6908ea5d..c0a7dfa1cd 100644 --- a/src/armnn/layers/TransposeConvolution2dLayer.cpp +++ b/src/armnn/layers/TransposeConvolution2dLayer.cpp @@ -123,12 +123,14 @@ Layer::ConstantTensors TransposeConvolution2dLayer::GetConstantTensorsByRef() void TransposeConvolution2dLayer::Accept(ILayerVisitor& visitor) const { - ConstTensor weightsTensor(m_Weight->GetTensorInfo(), m_Weight->Map(true)) ; - Optional optionalBiasTensor = EmptyOptional(); + ManagedConstTensorHandle managedWeight(m_Weight); + ConstTensor weightsTensor(managedWeight.GetTensorInfo(), managedWeight.Map()); + Optional optionalBiasTensor = EmptyOptional(); + ManagedConstTensorHandle managedBias(m_Bias); if (GetParameters().m_BiasEnabled) { - ConstTensor biasTensor(m_Bias->GetTensorInfo(), m_Bias->Map(true)); + ConstTensor biasTensor(managedBias.GetTensorInfo(), managedBias.Map()); optionalBiasTensor = Optional(biasTensor); } @@ -137,11 +139,13 @@ void TransposeConvolution2dLayer::Accept(ILayerVisitor& visitor) const void TransposeConvolution2dLayer::ExecuteStrategy(IStrategy& strategy) const { - std::vector constTensors { {m_Weight->GetTensorInfo(), m_Weight->Map(true)} }; + ManagedConstTensorHandle managedWeight(m_Weight); + std::vector constTensors { { managedWeight.GetTensorInfo(), managedWeight.Map() } }; + ManagedConstTensorHandle managedBias(m_Bias); if (GetParameters().m_BiasEnabled) { - constTensors.emplace_back(ConstTensor(m_Bias->GetTensorInfo(), m_Bias->Map(true))); + constTensors.emplace_back(ConstTensor(managedBias.GetTensorInfo(), managedBias.Map())); } strategy.ExecuteStrategy(this, GetParameters(), constTensors, GetName()); -- cgit v1.2.1