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/DepthwiseConvolution2dLayer.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/armnn/layers/DepthwiseConvolution2dLayer.cpp') diff --git a/src/armnn/layers/DepthwiseConvolution2dLayer.cpp b/src/armnn/layers/DepthwiseConvolution2dLayer.cpp index 0b2114a196..3511ab58d0 100644 --- a/src/armnn/layers/DepthwiseConvolution2dLayer.cpp +++ b/src/armnn/layers/DepthwiseConvolution2dLayer.cpp @@ -153,12 +153,14 @@ Layer::ConstantTensors DepthwiseConvolution2dLayer::GetConstantTensorsByRef() void DepthwiseConvolution2dLayer::Accept(ILayerVisitor& visitor) const { - ConstTensor weightsTensor(m_Weight->GetTensorInfo(), m_Weight->Map(true)); + 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); } @@ -167,11 +169,13 @@ void DepthwiseConvolution2dLayer::Accept(ILayerVisitor& visitor) const void DepthwiseConvolution2dLayer::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(true))); } strategy.ExecuteStrategy(this, GetParameters(), constTensors, GetName()); -- cgit v1.2.1