From fc598e15ff30bc375c95c9536d4a56662d867926 Mon Sep 17 00:00:00 2001 From: Matteo Martincigh Date: Tue, 14 May 2019 10:36:13 +0100 Subject: Use the new deprecation API * Used the new ARMNN_DEPRECATED_MSG macro instead of @deprecated * Refactored the code to no longer use the deprecated methods where applicable !android-nn-driver:1126 Change-Id: Ib0578d3d6fc5a763f5fb922f67ba91fafc7796f6 Signed-off-by: Matteo Martincigh --- src/armnnCaffeParser/CaffeParser.cpp | 56 ++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 28 deletions(-) (limited to 'src/armnnCaffeParser') diff --git a/src/armnnCaffeParser/CaffeParser.cpp b/src/armnnCaffeParser/CaffeParser.cpp index 90579e67fd..a27abc7cb9 100644 --- a/src/armnnCaffeParser/CaffeParser.cpp +++ b/src/armnnCaffeParser/CaffeParser.cpp @@ -543,19 +543,17 @@ void CaffeParserBase::AddConvLayerWithSplits(const caffe::LayerParameter& layerP weightData.data() + numWeightsPerGroup * g); IConnectableLayer* convLayer = nullptr; + Optional optionalBiases; if (desc.m_BiasEnabled) { // Pulls out the biases for this group from that loaded from the model file earlier. ConstTensor biases(biasInfo, biasData.data() + numBiasesPerGroup * g); - - convLayer = - m_Network->AddConvolution2dLayer(desc, weights, biases, convLayerNames[g].c_str()); - } - else - { - convLayer = - m_Network->AddConvolution2dLayer(desc, weights, convLayerNames[g].c_str()); + optionalBiases = Optional(biases); } + convLayer = m_Network->AddConvolution2dLayer(desc, + weights, + optionalBiases, + convLayerNames[g].c_str()); convLayers[g] = convLayer; // If we have more than one group then the input to the nth convolution the splitter layer's nth output, @@ -665,11 +663,11 @@ void CaffeParserBase::AddConvLayerWithDepthwiseConv(const caffe::LayerParameter& armnn::IConnectableLayer* returnLayer = nullptr; ConstTensor weights(TensorInfo(4, weightDimSizes, DataType::Float32), weightData.data()); - + Optional optionalBiases; + vector biasData; if (desc.m_BiasEnabled) { TensorInfo biasInfo; - vector biasData; biasData.resize(boost::numeric_cast(outputShape.dim(1)), 1.f); GetDataFromBlob(layerParam, biasData, 1); @@ -678,12 +676,12 @@ void CaffeParserBase::AddConvLayerWithDepthwiseConv(const caffe::LayerParameter& biasInfo = TensorInfo(1, biasDimSizes, DataType::Float32); ConstTensor biases(biasInfo, biasData.data()); - returnLayer = m_Network->AddDepthwiseConvolution2dLayer(desc, weights, biases, layerParam.name().c_str()); - } - else - { - returnLayer = m_Network->AddDepthwiseConvolution2dLayer(desc, weights, layerParam.name().c_str()); + optionalBiases = Optional(biases); } + returnLayer = m_Network->AddDepthwiseConvolution2dLayer(desc, + weights, + optionalBiases, + layerParam.name().c_str()); if (!returnLayer) { @@ -843,11 +841,11 @@ void CaffeParserBase::ParseConvLayer(const LayerParameter& layerParam) // Pull out the weights for this group from that loaded from the model file earlier ConstTensor weights(TensorInfo(4, weightDimSizes, DataType::Float32), weightData.data()); - + Optional optionalBiases; + vector biasData; if (convolution2dDescriptor.m_BiasEnabled) { TensorInfo biasInfo; - vector biasData; biasData.resize(boost::numeric_cast(outputShape.dim(1)), 1.f); GetDataFromBlob(layerParam, biasData, 1); @@ -857,14 +855,12 @@ void CaffeParserBase::ParseConvLayer(const LayerParameter& layerParam) // Pull out the biases for this group from that loaded from the model file earlier ConstTensor biases(biasInfo, biasData.data()); - - returnLayer = - m_Network->AddConvolution2dLayer(convolution2dDescriptor, weights, biases, layerParam.name().c_str()); - } - else - { - returnLayer = m_Network->AddConvolution2dLayer(convolution2dDescriptor, weights, layerParam.name().c_str()); + optionalBiases = Optional(biases); } + returnLayer = m_Network->AddConvolution2dLayer(convolution2dDescriptor, + weights, + optionalBiases, + layerParam.name().c_str()); armnn::IOutputSlot& inputConnection = GetArmnnOutputSlotForCaffeTop(layerParam.bottom(0)); inputConnection.Connect(returnLayer->GetInputSlot(0)); @@ -1192,13 +1188,17 @@ void CaffeParserBase::ParseInnerProductLayer(const LayerParameter& layerParam) ConstTensor biases(TensorInfo(1, sbTD, DataType::Float32), biasDataPtr); - fullyConnectedLayer = m_Network->AddFullyConnectedLayer(tensorFullyConnectedDescriptor, weights, biases, - layerParam.name().c_str()); + fullyConnectedLayer = m_Network->AddFullyConnectedLayer(tensorFullyConnectedDescriptor, + weights, + Optional(biases), + layerParam.name().c_str()); } else { - fullyConnectedLayer = m_Network->AddFullyConnectedLayer(tensorFullyConnectedDescriptor, weights, - layerParam.name().c_str()); + fullyConnectedLayer = m_Network->AddFullyConnectedLayer(tensorFullyConnectedDescriptor, + weights, + EmptyOptional(), + layerParam.name().c_str()); } TensorInfo outputInfo({ inputInfo.GetShape()[0], outputSize }, DataType::Float32); -- cgit v1.2.1