From c577f2c6a3b4ddb6ba87a882723c53a248afbeba Mon Sep 17 00:00:00 2001 From: telsoa01 Date: Fri, 31 Aug 2018 09:22:23 +0100 Subject: Release 18.08 --- src/armnn/layers/DepthwiseConvolution2dLayer.cpp | 46 +++++++++++++++++------- 1 file changed, 33 insertions(+), 13 deletions(-) (limited to 'src/armnn/layers/DepthwiseConvolution2dLayer.cpp') diff --git a/src/armnn/layers/DepthwiseConvolution2dLayer.cpp b/src/armnn/layers/DepthwiseConvolution2dLayer.cpp index 0442de6c60..471bf015a9 100644 --- a/src/armnn/layers/DepthwiseConvolution2dLayer.cpp +++ b/src/armnn/layers/DepthwiseConvolution2dLayer.cpp @@ -22,11 +22,15 @@ DepthwiseConvolution2dLayer::DepthwiseConvolution2dLayer(const DepthwiseConvolut std::unique_ptr DepthwiseConvolution2dLayer::CreateWorkload(const Graph& graph, const IWorkloadFactory& factory) const { + // on this level constant data should not be released.. + BOOST_ASSERT_MSG(m_Weight != nullptr, "DepthwiseConvolution2dLayer: Weights data should not be null."); + DepthwiseConvolution2dQueueDescriptor descriptor; descriptor.m_Weight = m_Weight.get(); if (m_Param.m_BiasEnabled) { + BOOST_ASSERT_MSG(m_Bias != nullptr, "DepthwiseConvolution2dLayer: Bias data should not be null."); descriptor.m_Bias = m_Bias.get(); } return factory.CreateDepthwiseConvolution2d(descriptor, PrepInfoAndDesc(descriptor, graph)); @@ -45,16 +49,12 @@ DepthwiseConvolution2dLayer* DepthwiseConvolution2dLayer::Clone(Graph& graph) co return std::move(layer); } -void DepthwiseConvolution2dLayer::ValidateTensorShapesFromInputs() +std::vector +DepthwiseConvolution2dLayer::InferOutputShapes(const std::vector& inputShapes) const { - ConditionalThrow(GetInputSlot(0).GetConnection() != nullptr, - "DepthwiseConvolution2dLayer: InputSlot must be connected to an OutputSlot"); - ConditionalThrow(GetInputSlot(0).GetConnection()->IsTensorInfoSet(), - "DepthwiseConvolution2dLayer: TensorInfo must be set on connected OutputSlot."); - - IOutputSlot* input = GetInputSlot(0).GetConnection(); - const TensorShape& inputShape = input->GetTensorInfo().GetShape(); - const TensorShape filterShape = m_Weight->GetTensorInfo().GetShape(); + BOOST_ASSERT(inputShapes.size() == 2); + const TensorShape& inputShape = inputShapes[0]; + const TensorShape filterShape = inputShapes[1]; BOOST_ASSERT_MSG(inputShape.GetNumDimensions() == 4, "Convolutions will always have 4D input."); @@ -74,12 +74,32 @@ void DepthwiseConvolution2dLayer::ValidateTensorShapesFromInputs() unsigned int outChannels = filterShape[1]*depthMultiplier; unsigned int outBatchSize = inBatchSize; - TensorShape outShape({outBatchSize, outChannels, outHeight, outWidth}); + return std::vector({ TensorShape({outBatchSize, outChannels, outHeight, outWidth})}); +} + +void DepthwiseConvolution2dLayer::ValidateTensorShapesFromInputs() +{ + VerifyLayerConnections(1, CHECK_LOCATION()); + + // on this level constant data should not be released.. + BOOST_ASSERT_MSG(m_Weight != nullptr, "DepthwiseConvolution2dLayer: Weights data should not be null."); + + auto inferredShapes = InferOutputShapes({ + GetInputSlot(0).GetConnection()->GetTensorInfo().GetShape(), + m_Weight->GetTensorInfo().GetShape() + }); + + BOOST_ASSERT(inferredShapes.size() == 1); + ConditionalThrowIfNotEqual( - "DepthwiseConvolution2dLayer: " - "TensorShape set on OutputSlot[0] does not match the inferred shape.", + "DepthwiseConvolution2dLayer: TensorShape set on OutputSlot[0] does not match the inferred shape.", GetOutputSlot(0).GetTensorInfo().GetShape(), - outShape); + inferredShapes[0]); +} + +Layer::ConstantTensors DepthwiseConvolution2dLayer::GetConstantTensorsByRef() +{ + return {m_Weight, m_Bias}; } } // namespace armnn -- cgit v1.2.1