Skip to content

Commit

Permalink
IVGCVSW-7006 Remove deprecated code due to be removed in 22.08
Browse files Browse the repository at this point in the history
* AddConv and AddDWConv with weights and bias
* ResizeBilinearDescriptor
* b,blacklist option in accuracy tool

!android-nn-driver:8172

Signed-off-by: Teresa Charlin <teresa.charlinreyes@arm.com>
Change-Id: Ibbc04fd18be7f938b11590bf67cd7af103cb4d99
  • Loading branch information
TeresaARM committed Sep 6, 2022
1 parent 48f9d5d commit d1628bf
Show file tree
Hide file tree
Showing 13 changed files with 35 additions and 226 deletions.
37 changes: 0 additions & 37 deletions include/armnn/Descriptors.hpp
Expand Up @@ -921,43 +921,6 @@ struct GatherDescriptor : BaseDescriptor
int32_t m_Axis;
};

/// A ResizeBilinearDescriptor for the ResizeBilinearLayer.
struct ARMNN_DEPRECATED_MSG_REMOVAL_DATE(
"ResizeBilinearDescriptor is not supported anymore. Use ResizeDescriptor instead.",
"22.08")
ResizeBilinearDescriptor : BaseDescriptor
{
ResizeBilinearDescriptor()
: m_TargetWidth(0)
, m_TargetHeight(0)
, m_DataLayout(DataLayout::NCHW)
, m_AlignCorners(false)
, m_HalfPixelCenters(false)
{}

ARMNN_NO_DEPRECATE_WARN_BEGIN
bool operator ==(const ResizeBilinearDescriptor& rhs) const
{
return m_TargetWidth == rhs.m_TargetWidth &&
m_TargetHeight == rhs.m_TargetHeight &&
m_DataLayout == rhs.m_DataLayout &&
m_AlignCorners == rhs.m_AlignCorners &&
m_HalfPixelCenters == rhs.m_HalfPixelCenters;
}
ARMNN_NO_DEPRECATE_WARN_END

/// Target width value.
uint32_t m_TargetWidth;
/// Target height value.
uint32_t m_TargetHeight;
/// The data layout to be used (NCHW, NHWC).
DataLayout m_DataLayout;
/// Aligned corners
bool m_AlignCorners;
/// Half Pixel Centers
bool m_HalfPixelCenters;
};

/// A ResizeDescriptor for the ResizeLayer.
struct ResizeDescriptor : BaseDescriptor
{
Expand Down
1 change: 0 additions & 1 deletion include/armnn/DescriptorsFwd.hpp
Expand Up @@ -39,7 +39,6 @@ struct Pooling3dDescriptor;
struct PreCompiledDescriptor;
struct QLstmDescriptor;
struct ReshapeDescriptor;
struct ResizeBilinearDescriptor;
struct ResizeDescriptor;
struct ReduceDescriptor;
struct SliceDescriptor;
Expand Down
36 changes: 0 additions & 36 deletions include/armnn/INetwork.hpp
Expand Up @@ -295,29 +295,6 @@ class INetwork
IConnectableLayer* AddConvolution2dLayer(const Convolution2dDescriptor& convolution2dDescriptor,
const char* name = nullptr);

/// Adds a 2D convolution layer to the network.
/// @param convolution2dDescriptor - Description of the 2D convolution layer.
/// @param weights - Tensor for the weights data.
/// @param biases - Optional tensor for the bias data. If specified, must match the output tensor shape.
/// @param name - Optional name for the layer.
/// @return - Interface for configuring the layer.
ARMNN_DEPRECATED_MSG_REMOVAL_DATE("This AddConvolution2dLayer overload is deprecated", "22.08")
IConnectableLayer* AddConvolution2dLayer(const Convolution2dDescriptor& convolution2dDescriptor,
const ConstTensor& weights,
const Optional<ConstTensor>& biases,
const char* name = nullptr);

ARMNN_DEPRECATED_MSG_REMOVAL_DATE("This AddConvolution2dLayer overload is deprecated", "22.08")
IConnectableLayer* AddConvolution2dLayer(const Convolution2dDescriptor& convolution2dDescriptor,
const ConstTensor& weights,
const char* name = nullptr);

ARMNN_DEPRECATED_MSG_REMOVAL_DATE("This AddConvolution2dLayer overload is deprecated", "22.08")
IConnectableLayer* AddConvolution2dLayer(const Convolution2dDescriptor& convolution2dDescriptor,
const ConstTensor& weights,
const ConstTensor& biases,
const char* name = nullptr);

/// Adds a 3D convolution layer to the network.
/// @param convolution3dDescriptor - Description of the 3D convolution layer.
/// @param name - Optional name for the layer.
Expand All @@ -339,19 +316,6 @@ class INetwork
IConnectableLayer* AddDepthwiseConvolution2dLayer(const DepthwiseConvolution2dDescriptor& convolution2dDescriptor,
const char* name = nullptr);

/// Adds a 2D depthwise convolution layer to the network.
/// @param convolution2dDescriptor - Description of the 2D depthwise convolution layer.
/// @param weights - Tensor for the weights. Expected format: [channelMultiplier, inputChannels, height, width].
/// @param biases Optional tensor for the bias data. If specified, must match the output tensor shape.
/// @param name - Optional name for the layer.
/// @return - Interface for configuring the layer.
ARMNN_DEPRECATED_MSG("This AddDepthwiseConvolution2dLayer overload is deprecated")
IConnectableLayer* AddDepthwiseConvolution2dLayer(
const DepthwiseConvolution2dDescriptor& convolution2dDescriptor,
const ConstTensor& weights,
const Optional<ConstTensor>& biases,
const char* name = nullptr);

/// Adds a Dequantize layer to the network.
/// @return - Interface for configuring the layer.
IConnectableLayer* AddDequantizeLayer(const char* name = nullptr);
Expand Down
10 changes: 0 additions & 10 deletions include/armnn/backends/WorkloadData.hpp
Expand Up @@ -353,16 +353,6 @@ struct RankQueueDescriptor : QueueDescriptor
void Validate(const WorkloadInfo& workloadInfo) const;
};

ARMNN_NO_DEPRECATE_WARN_BEGIN
struct
ARMNN_DEPRECATED_MSG_REMOVAL_DATE("ResizeBilinearQueueDescriptor is deprecated use ResizeQueueDescriptor instead",
"22.08")
ResizeBilinearQueueDescriptor : QueueDescriptorWithParameters<ResizeBilinearDescriptor>
{
void Validate(const WorkloadInfo& workloadInfo) const;
};
ARMNN_NO_DEPRECATE_WARN_END

struct ResizeQueueDescriptor : QueueDescriptorWithParameters<ResizeDescriptor>
{
void Validate(const WorkloadInfo& workloadInfo) const;
Expand Down
26 changes: 2 additions & 24 deletions python/pyarmnn/src/pyarmnn/swig/modules/armnn_network.i
Expand Up @@ -1179,25 +1179,15 @@ public:
Args:
convolution2dDescriptor (Convolution2dDescriptor): Description of the 2D convolution layer.
weights (ConstTensor): Tensor for the weights data.
biases (ConstTensor): Optional tensor for the bias data. If specified, must match the output tensor shape.
name (str): Optional name for the layer.
Returns:
IConnectableLayer: Interface for configuring the layer.
") AddConvolution2dLayer;
armnn::IConnectableLayer* AddConvolution2dLayer(const armnn::Convolution2dDescriptor& convolution2dDescriptor,
const armnn::ConstTensor& weights,
armnn::ConstTensor* biases = nullptr,
const char* name = nullptr) {

if (biases) {
return $self->AddConvolution2dLayer(convolution2dDescriptor, weights,
armnn::Optional<armnn::ConstTensor>(*biases), name);
} else {
return $self->AddConvolution2dLayer(convolution2dDescriptor, weights,
armnn::Optional<armnn::ConstTensor>(), name);
}
return $self->AddConvolution2dLayer(convolution2dDescriptor, name);
}

%feature("docstring",
Expand All @@ -1206,8 +1196,6 @@ public:
Args:
convolution2dDescriptor (DepthwiseConvolution2dDescriptor): Description of the 2D depthwise convolution layer.
weights (ConstTensor): Tensor for the weights. Expected format: [channelMultiplier, inputChannels, height, width].
biases (ConstTensor): Optional tensor for the bias data. If specified, must match the output tensor shape.
name (str): Optional name for the layer.
Returns:
Expand All @@ -1216,19 +1204,9 @@ public:

armnn::IConnectableLayer* AddDepthwiseConvolution2dLayer(
const armnn::DepthwiseConvolution2dDescriptor& convolution2dDescriptor,
const armnn::ConstTensor& weights,
const armnn::ConstTensor* biases = nullptr,
const char* name = nullptr) {

ARMNN_NO_DEPRECATE_WARN_BEGIN
if (biases) {
return $self->AddDepthwiseConvolution2dLayer(convolution2dDescriptor, weights,
armnn::Optional<armnn::ConstTensor>(*biases), name);
} else {
return $self->AddDepthwiseConvolution2dLayer(convolution2dDescriptor, weights,
armnn::Optional<armnn::ConstTensor>(), name);
}
ARMNN_NO_DEPRECATE_WARN_END
return $self->AddDepthwiseConvolution2dLayer(convolution2dDescriptor, name);
}

}
Expand Down
14 changes: 1 addition & 13 deletions python/pyarmnn/test/test_network.py
Expand Up @@ -253,26 +253,14 @@ def test_network_method_exists(method):

def test_Convolution2d_layer_optional_none():
net = ann.INetwork()
layer = net.AddConvolution2dLayer(convolution2dDescriptor=ann.Convolution2dDescriptor(),
weights=ann.ConstTensor())

assert layer


def test_Convolution2d_layer_optional_provided():
net = ann.INetwork()
layer = net.AddConvolution2dLayer(convolution2dDescriptor=ann.Convolution2dDescriptor(),
weights=ann.ConstTensor(),
biases=ann.ConstTensor())
layer = net.AddConvolution2dLayer(convolution2dDescriptor=ann.Convolution2dDescriptor())

assert layer


def test_Convolution2d_layer_all_args():
net = ann.INetwork()
layer = net.AddConvolution2dLayer(convolution2dDescriptor=ann.Convolution2dDescriptor(),
weights=ann.ConstTensor(),
biases=ann.ConstTensor(),
name='NAME1')

assert layer
Expand Down
14 changes: 10 additions & 4 deletions shim/sl/canonical/Converter.cpp
Expand Up @@ -2233,16 +2233,22 @@ bool Converter::ConvertGroupedConv2d(const Operation& operation, const Model& mo
{
return false;
}
ARMNN_NO_DEPRECATE_WARN_BEGIN
IConnectableLayer* convLayer =
data.m_Network->AddConvolution2dLayer(desc, groupWeights, Optional<ConstTensor>(groupBiases));
ARMNN_NO_DEPRECATE_WARN_END

IConnectableLayer* weightsLayer = data.m_Network->AddConstantLayer(groupWeights);
IConnectableLayer* biasLayer = data.m_Network->AddConstantLayer(groupBiases);
IConnectableLayer* convLayer = data.m_Network->AddConvolution2dLayer(desc);

if (!convLayer)
{
return Fail("%s: AddConvolution2dLayer failed", __func__);
}

splitterLayer->GetOutputSlot(group).Connect(convLayer->GetInputSlot(0));
weightsLayer->GetOutputSlot(0).Connect(convLayer->GetInputSlot(1));
biasLayer->GetOutputSlot(0).Connect(convLayer->GetInputSlot(2));

weightsLayer->GetOutputSlot(0).SetTensorInfo(groupWeightsInfo);
biasLayer->GetOutputSlot(0).SetTensorInfo(groupBiasesInfo);
convLayer->GetOutputSlot(0).SetTensorInfo(groupOutputInfo);

if(isDynamic)
Expand Down
25 changes: 0 additions & 25 deletions src/armnn/Network.cpp
Expand Up @@ -88,19 +88,6 @@ IConnectableLayer* INetwork::AddConvolution2dLayer(const Convolution2dDescriptor
return pNetworkImpl->AddConvolution2dLayer(convolution2dDescriptor, name);
}

ARMNN_NO_DEPRECATE_WARN_BEGIN
IConnectableLayer* INetwork::AddConvolution2dLayer(const Convolution2dDescriptor& convolution2dDescriptor,
const ConstTensor& weights,
const Optional<ConstTensor>& biases,
const char* name)
{
return pNetworkImpl->AddConvolution2dLayer(convolution2dDescriptor,
weights,
armnn::Optional<ConstTensor>(biases),
name);
}
ARMNN_NO_DEPRECATE_WARN_END

IConnectableLayer* INetwork::AddConvolution3dLayer(const Convolution3dDescriptor& convolution3dDescriptor,
const char* name)
{
Expand All @@ -123,18 +110,6 @@ IConnectableLayer* INetwork::AddDepthwiseConvolution2dLayer(
}


ARMNN_NO_DEPRECATE_WARN_BEGIN
IConnectableLayer* INetwork::AddDepthwiseConvolution2dLayer(
const DepthwiseConvolution2dDescriptor& convolution2dDescriptor,
const ConstTensor& weights,
const Optional<ConstTensor>& biases,
const char* name)
{
return pNetworkImpl->AddDepthwiseConvolution2dLayer(convolution2dDescriptor, weights, biases, name);
}
ARMNN_NO_DEPRECATE_WARN_END


IConnectableLayer* INetwork::AddDequantizeLayer(const char* name)
{
return pNetworkImpl->AddDequantizeLayer(name);
Expand Down
1 change: 0 additions & 1 deletion src/armnn/layers/Convolution2dLayer.hpp
Expand Up @@ -44,7 +44,6 @@ class Convolution2dLayer : public LayerWithParameters<Convolution2dDescriptor>
/// @return A vector to the inferred output shape.
std::vector<TensorShape> InferOutputShapes(const std::vector<TensorShape>& inputShapes) const override;


void ExecuteStrategy(IStrategy& strategy) const override;

void SerializeLayerParameters(ParameterStringifyFunction& fn) const override;
Expand Down
14 changes: 7 additions & 7 deletions src/armnn/test/GraphTests.cpp
Expand Up @@ -632,13 +632,13 @@ TEST_CASE("IConnectableLayerConstantTensorsByRef")
TensorInfo weightsInfo = constInfo;
ConstTensor weights(weightsInfo, weightData);
DepthwiseConvolution2dDescriptor desc;
ARMNN_NO_DEPRECATE_WARN_BEGIN
// GetConstantTensorsByRef() returns {m_Weights, m_Bias} so we need to use the old AddDepthwiseConvolution2dLayer()
const auto depthwiseLayer = net->AddDepthwiseConvolution2dLayer(desc, weights, EmptyOptional(), "Depthwise");
ARMNN_NO_DEPRECATE_WARN_END
const void* resultData = depthwiseLayer->GetConstantTensorsByRef()[0].get()->GetConstTensor<void>();
auto resultValue = reinterpret_cast<const uint8_t*>(resultData);
CHECK(resultValue[0] == 3);

const auto weightsLayer = net->AddConstantLayer(weights);

const void* resultDataWeights = weightsLayer->GetConstantTensorsByRef()[0].get()->GetConstTensor<void>();
auto resultValueWeights = reinterpret_cast<const uint8_t*>(resultDataWeights);
CHECK(resultValueWeights[0] == 3);

}

}
30 changes: 15 additions & 15 deletions src/armnnSerializer/test/SerializerTests.cpp
Expand Up @@ -436,19 +436,19 @@ TEST_CASE("SerializeConvolution2d")

armnn::INetworkPtr network = armnn::INetwork::Create();
armnn::IConnectableLayer* const inputLayer = network->AddInputLayer(0);
ARMNN_NO_DEPRECATE_WARN_BEGIN
armnn::IConnectableLayer* const convLayer =
network->AddConvolution2dLayer(descriptor,
weights,
armnn::Optional<armnn::ConstTensor>(biases),
layerName.c_str());
ARMNN_NO_DEPRECATE_WARN_END
armnn::IConnectableLayer* const weightsLayer = network->AddConstantLayer(weights, "weights");
armnn::IConnectableLayer* const biasLayer = network->AddConstantLayer(biases, "bias");
armnn::IConnectableLayer* const convLayer = network->AddConvolution2dLayer(descriptor, layerName.c_str());
armnn::IConnectableLayer* const outputLayer = network->AddOutputLayer(0);

inputLayer->GetOutputSlot(0).Connect(convLayer->GetInputSlot(0));
weightsLayer->GetOutputSlot(0).Connect(convLayer->GetInputSlot(1));
biasLayer->GetOutputSlot(0).Connect(convLayer->GetInputSlot(2));
convLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));

inputLayer->GetOutputSlot(0).SetTensorInfo(inputInfo);
weightsLayer->GetOutputSlot(0).SetTensorInfo(weightsInfo);
biasLayer->GetOutputSlot(0).SetTensorInfo(biasesInfo);
convLayer->GetOutputSlot(0).SetTensorInfo(outputInfo);

armnn::INetworkPtr deserializedNetwork = DeserializeNetwork(SerializeNetwork(*network));
Expand All @@ -458,7 +458,7 @@ TEST_CASE("SerializeConvolution2d")
deserializedNetwork->ExecuteStrategy(verifier);
}

TEST_CASE("SerializeConvolution2dWithPerAxisParamsTestDeprecatedMethod")
TEST_CASE("SerializeConvolution2dWithPerAxisParams")
{
using namespace armnn;

Expand Down Expand Up @@ -491,19 +491,19 @@ TEST_CASE("SerializeConvolution2dWithPerAxisParamsTestDeprecatedMethod")

armnn::INetworkPtr network = armnn::INetwork::Create();
armnn::IConnectableLayer* const inputLayer = network->AddInputLayer(0);
ARMNN_NO_DEPRECATE_WARN_BEGIN
armnn::IConnectableLayer* const convLayer =
network->AddConvolution2dLayer(descriptor,
weights,
armnn::Optional<armnn::ConstTensor>(biases),
layerName.c_str());
ARMNN_NO_DEPRECATE_WARN_END
armnn::IConnectableLayer* const weightsLayer = network->AddConstantLayer(weights, "weights");
armnn::IConnectableLayer* const biasLayer = network->AddConstantLayer(weights, "bias");
armnn::IConnectableLayer* const convLayer = network->AddConvolution2dLayer(descriptor, layerName.c_str());
armnn::IConnectableLayer* const outputLayer = network->AddOutputLayer(0);

inputLayer->GetOutputSlot(0).Connect(convLayer->GetInputSlot(0));
weightsLayer->GetOutputSlot(0).Connect(convLayer->GetInputSlot(1));
biasLayer->GetOutputSlot(0).Connect(convLayer->GetInputSlot(2));
convLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));

inputLayer->GetOutputSlot(0).SetTensorInfo(inputInfo);
weightsLayer->GetOutputSlot(0).SetTensorInfo(kernelInfo);
biasLayer->GetOutputSlot(0).SetTensorInfo(biasInfo);
convLayer->GetOutputSlot(0).SetTensorInfo(outputInfo);

armnn::INetworkPtr deserializedNetwork = DeserializeNetwork(SerializeNetwork(*network));
Expand Down

0 comments on commit d1628bf

Please sign in to comment.