From 0085978ac40ecd008195d635cd009a1d4f49fb74 Mon Sep 17 00:00:00 2001 From: Aron Virginas-Tar Date: Mon, 11 Feb 2019 12:21:27 +0000 Subject: IVGCVSW-2676 Make biases optional in ILayerVisitor for Convolution2D, DepthwiseConvolution2D and FullyConnected Change-Id: I3048504ff699fdb266488e7c07b7262e5843d4b0 Signed-off-by: Aron Virginas-Tar --- src/armnn/layers/Convolution2dLayer.cpp | 10 +++++----- src/armnn/layers/DepthwiseConvolution2dLayer.cpp | 12 ++++++------ src/armnn/layers/FullyConnectedLayer.cpp | 12 ++++++------ 3 files changed, 17 insertions(+), 17 deletions(-) (limited to 'src/armnn/layers') diff --git a/src/armnn/layers/Convolution2dLayer.cpp b/src/armnn/layers/Convolution2dLayer.cpp index 2c0997a9d0..243bcc3dfd 100644 --- a/src/armnn/layers/Convolution2dLayer.cpp +++ b/src/armnn/layers/Convolution2dLayer.cpp @@ -113,15 +113,15 @@ Layer::ConstantTensors Convolution2dLayer::GetConstantTensorsByRef() void Convolution2dLayer::Accept(ILayerVisitor& visitor) const { ConstTensor weightsTensor(m_Weight->GetTensorInfo(), m_Weight->Map(true)) ; + Optional optionalBiasTensor = EmptyOptional(); + if (GetParameters().m_BiasEnabled) { ConstTensor biasTensor(m_Bias->GetTensorInfo(), m_Bias->Map(true)); - visitor.VisitConvolution2dLayer(this, GetParameters(), weightsTensor, biasTensor, GetName()); - } - else - { - visitor.VisitConvolution2dLayer(this, GetParameters(), weightsTensor, GetName()); + optionalBiasTensor = Optional(biasTensor); } + + visitor.VisitConvolution2dLayer(this, GetParameters(), weightsTensor, optionalBiasTensor, GetName()); } } // namespace armnn diff --git a/src/armnn/layers/DepthwiseConvolution2dLayer.cpp b/src/armnn/layers/DepthwiseConvolution2dLayer.cpp index a17673fc1e..a1ffe91792 100644 --- a/src/armnn/layers/DepthwiseConvolution2dLayer.cpp +++ b/src/armnn/layers/DepthwiseConvolution2dLayer.cpp @@ -122,16 +122,16 @@ Layer::ConstantTensors DepthwiseConvolution2dLayer::GetConstantTensorsByRef() void DepthwiseConvolution2dLayer::Accept(ILayerVisitor& visitor) const { - ConstTensor weightsTensor(m_Weight->GetTensorInfo(), m_Weight->Map(true)) ; + ConstTensor weightsTensor(m_Weight->GetTensorInfo(), m_Weight->Map(true)); + Optional optionalBiasTensor = EmptyOptional(); + if (GetParameters().m_BiasEnabled) { ConstTensor biasTensor(m_Bias->GetTensorInfo(), m_Bias->Map(true)); - visitor.VisitDepthwiseConvolution2dLayer(this, GetParameters(), weightsTensor, biasTensor, GetName()); - } - else - { - visitor.VisitDepthwiseConvolution2dLayer(this, GetParameters(), weightsTensor, GetName()); + optionalBiasTensor = Optional(biasTensor); } + + visitor.VisitDepthwiseConvolution2dLayer(this, GetParameters(), weightsTensor, optionalBiasTensor, GetName()); } } // namespace armnn diff --git a/src/armnn/layers/FullyConnectedLayer.cpp b/src/armnn/layers/FullyConnectedLayer.cpp index 219113bca6..98b81fa6a8 100644 --- a/src/armnn/layers/FullyConnectedLayer.cpp +++ b/src/armnn/layers/FullyConnectedLayer.cpp @@ -88,16 +88,16 @@ Layer::ConstantTensors FullyConnectedLayer::GetConstantTensorsByRef() void FullyConnectedLayer::Accept(ILayerVisitor& visitor) const { - ConstTensor weightsTensor(m_Weight->GetTensorInfo(), m_Weight->Map(true)) ; + ConstTensor weightsTensor(m_Weight->GetTensorInfo(), m_Weight->Map(true)); + Optional optionalBiasTensor = EmptyOptional(); + if (GetParameters().m_BiasEnabled) { ConstTensor biasTensor(m_Bias->GetTensorInfo(), m_Bias->GetConstTensor()); - visitor.VisitFullyConnectedLayer(this, GetParameters(), weightsTensor, biasTensor, GetName()); - } - else - { - visitor.VisitFullyConnectedLayer(this, GetParameters(), weightsTensor, GetName()); + optionalBiasTensor = Optional(biasTensor); } + + visitor.VisitFullyConnectedLayer(this, GetParameters(), weightsTensor, optionalBiasTensor, GetName()); } } // namespace armnn -- cgit v1.2.1