diff options
author | Francis Murtagh <francis.murtagh@arm.com> | 2021-04-20 16:37:55 +0100 |
---|---|---|
committer | Francis Murtagh <francis.murtagh@arm.com> | 2021-04-20 16:38:04 +0100 |
commit | 4af561666b0ce5c12164447a5f7eb9722abb85f8 (patch) | |
tree | 8fc485d875aa91d6920c9104505541fb94b832b6 /src/armnn/layers/FullyConnectedLayer.cpp | |
parent | ec8b333001808f532d17a7ca2efd563f4181ff40 (diff) | |
download | armnn-4af561666b0ce5c12164447a5f7eb9722abb85f8.tar.gz |
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 <francis.murtagh@arm.com>
Change-Id: I0a05e14e438804b37e9862e76b5ca329483f6b45
Diffstat (limited to 'src/armnn/layers/FullyConnectedLayer.cpp')
-rw-r--r-- | src/armnn/layers/FullyConnectedLayer.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/armnn/layers/FullyConnectedLayer.cpp b/src/armnn/layers/FullyConnectedLayer.cpp index 44c8920136..79d56c0bd7 100644 --- a/src/armnn/layers/FullyConnectedLayer.cpp +++ b/src/armnn/layers/FullyConnectedLayer.cpp @@ -103,17 +103,21 @@ void FullyConnectedLayer::Accept(ILayerVisitor& visitor) const { Optional<ConstTensor> optionalWeightsTensor = EmptyOptional(); Optional<ConstTensor> optionalBiasTensor = EmptyOptional(); - if(GetParameters().m_ConstantWeights) + + ManagedConstTensorHandle managedWeight(m_Weight); + ManagedConstTensorHandle managedBias(m_Bias); + if (GetParameters().m_ConstantWeights) { - ConstTensor weightsTensor(m_Weight->GetTensorInfo(), m_Weight->GetConstTensor<void>()); + ConstTensor weightsTensor(managedWeight.GetTensorInfo(), managedWeight.Map()); optionalWeightsTensor = Optional<ConstTensor>(weightsTensor); if (GetParameters().m_BiasEnabled) { - ConstTensor biasTensor(m_Bias->GetTensorInfo(), m_Bias->GetConstTensor<void>()); + ConstTensor biasTensor(managedBias.GetTensorInfo(), managedBias.Map()); optionalBiasTensor = Optional<ConstTensor>(biasTensor); } } + visitor.VisitFullyConnectedLayer(this, GetParameters(), optionalWeightsTensor.value(), @@ -124,12 +128,15 @@ void FullyConnectedLayer::Accept(ILayerVisitor& visitor) const void FullyConnectedLayer::ExecuteStrategy(IStrategy& strategy) const { std::vector <armnn::ConstTensor> constTensors; + ManagedConstTensorHandle managedWeight(m_Weight); + ManagedConstTensorHandle managedBias(m_Bias); + if(GetParameters().m_ConstantWeights) { - constTensors.emplace_back(ConstTensor(m_Weight->GetTensorInfo(), m_Weight->Map(true))); + constTensors.emplace_back(ConstTensor(managedWeight.GetTensorInfo(), managedWeight.Map())); 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()); |