diff options
author | Aron Virginas-Tar <Aron.Virginas-Tar@arm.com> | 2019-02-11 12:21:27 +0000 |
---|---|---|
committer | Aron Virginas-Tar <Aron.Virginas-Tar@arm.com> | 2019-02-11 13:33:20 +0000 |
commit | 0085978ac40ecd008195d635cd009a1d4f49fb74 (patch) | |
tree | 560c296e74b94826d6338b7d0d92224ae526a426 /src/armnn/layers | |
parent | 3dad5acc5d8eda6fc472b9a255c1d893d4e1f942 (diff) | |
download | armnn-0085978ac40ecd008195d635cd009a1d4f49fb74.tar.gz |
IVGCVSW-2676 Make biases optional in ILayerVisitor for Convolution2D, DepthwiseConvolution2D and FullyConnected
Change-Id: I3048504ff699fdb266488e7c07b7262e5843d4b0
Signed-off-by: Aron Virginas-Tar <Aron.Virginas-Tar@arm.com>
Diffstat (limited to 'src/armnn/layers')
-rw-r--r-- | src/armnn/layers/Convolution2dLayer.cpp | 10 | ||||
-rw-r--r-- | src/armnn/layers/DepthwiseConvolution2dLayer.cpp | 12 | ||||
-rw-r--r-- | src/armnn/layers/FullyConnectedLayer.cpp | 12 |
3 files changed, 17 insertions, 17 deletions
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<ConstTensor> 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<ConstTensor>(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<ConstTensor> 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<ConstTensor>(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<ConstTensor> optionalBiasTensor = EmptyOptional(); + if (GetParameters().m_BiasEnabled) { ConstTensor biasTensor(m_Bias->GetTensorInfo(), m_Bias->GetConstTensor<void>()); - visitor.VisitFullyConnectedLayer(this, GetParameters(), weightsTensor, biasTensor, GetName()); - } - else - { - visitor.VisitFullyConnectedLayer(this, GetParameters(), weightsTensor, GetName()); + optionalBiasTensor = Optional<ConstTensor>(biasTensor); } + + visitor.VisitFullyConnectedLayer(this, GetParameters(), weightsTensor, optionalBiasTensor, GetName()); } } // namespace armnn |