diff options
author | Matteo Martincigh <matteo.martincigh@arm.com> | 2019-05-14 10:36:13 +0100 |
---|---|---|
committer | Matteo Martincigh <matteo.martincigh@arm.com> | 2019-05-14 13:33:59 +0100 |
commit | fc598e15ff30bc375c95c9536d4a56662d867926 (patch) | |
tree | 0d17a7928ae4faab6978552e666123bfc1926d93 /src/armnn/test | |
parent | 906f94631aa7ef590b9d8ff45507e818a0d1ac2c (diff) | |
download | armnn-fc598e15ff30bc375c95c9536d4a56662d867926.tar.gz |
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 <matteo.martincigh@arm.com>
Diffstat (limited to 'src/armnn/test')
-rw-r--r-- | src/armnn/test/ConstTensorLayerVisitor.cpp | 45 | ||||
-rw-r--r-- | src/armnn/test/CreateWorkload.hpp | 10 | ||||
-rw-r--r-- | src/armnn/test/NetworkTests.cpp | 6 | ||||
-rw-r--r-- | src/armnn/test/QuantizerTest.cpp | 30 |
4 files changed, 52 insertions, 39 deletions
diff --git a/src/armnn/test/ConstTensorLayerVisitor.cpp b/src/armnn/test/ConstTensorLayerVisitor.cpp index 5b77ddeb97..e17ee46c81 100644 --- a/src/armnn/test/ConstTensorLayerVisitor.cpp +++ b/src/armnn/test/ConstTensorLayerVisitor.cpp @@ -128,7 +128,7 @@ BOOST_AUTO_TEST_CASE(CheckConvolution2dLayer) Network net; - IConnectableLayer* const layer = net.AddConvolution2dLayer(descriptor, weights); + IConnectableLayer* const layer = net.AddConvolution2dLayer(descriptor, weights, EmptyOptional()); layer->Accept(visitor); } @@ -152,7 +152,7 @@ BOOST_AUTO_TEST_CASE(CheckNamedConvolution2dLayer) Network net; - IConnectableLayer* const layer = net.AddConvolution2dLayer(descriptor, weights, layerName); + IConnectableLayer* const layer = net.AddConvolution2dLayer(descriptor, weights, EmptyOptional(), layerName); layer->Accept(visitor); } @@ -175,12 +175,13 @@ BOOST_AUTO_TEST_CASE(CheckConvolution2dLayerWithBiases) std::vector<float> biasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0}; std::vector<unsigned int> biasDimensions = {1, 1, 3, 3}; ConstTensor biases(TensorInfo(4, biasDimensions.data(), DataType::Float32), biasData); + Optional<ConstTensor> optionalBiases(biases); - TestConvolution2dLayerVisitor visitor(descriptor, weights, Optional<ConstTensor>(biases)); + TestConvolution2dLayerVisitor visitor(descriptor, weights, optionalBiases); Network net; - IConnectableLayer* const layer = net.AddConvolution2dLayer(descriptor, weights, biases); + IConnectableLayer* const layer = net.AddConvolution2dLayer(descriptor, weights, optionalBiases); layer->Accept(visitor); } @@ -204,12 +205,13 @@ BOOST_AUTO_TEST_CASE(CheckNamedConvolution2dLayerWithBiases) std::vector<float> biasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0}; std::vector<unsigned int> biasDimensions = {1, 1, 3, 3}; ConstTensor biases(TensorInfo(4, biasDimensions.data(), DataType::Float32), biasData); + Optional<ConstTensor> optionalBiases(biases); - TestConvolution2dLayerVisitor visitor(descriptor, weights, Optional<ConstTensor>(biases), layerName); + TestConvolution2dLayerVisitor visitor(descriptor, weights, optionalBiases, layerName); Network net; - IConnectableLayer* const layer = net.AddConvolution2dLayer(descriptor, weights, biases, layerName); + IConnectableLayer* const layer = net.AddConvolution2dLayer(descriptor, weights, optionalBiases, layerName); layer->Accept(visitor); } @@ -232,7 +234,7 @@ BOOST_AUTO_TEST_CASE(CheckDepthwiseConvolution2dLayer) Network net; - IConnectableLayer* const layer = net.AddDepthwiseConvolution2dLayer(descriptor, weights); + IConnectableLayer* const layer = net.AddDepthwiseConvolution2dLayer(descriptor, weights, EmptyOptional()); layer->Accept(visitor); } @@ -256,7 +258,10 @@ BOOST_AUTO_TEST_CASE(CheckNamedDepthwiseConvolution2dLayer) Network net; - IConnectableLayer* const layer = net.AddDepthwiseConvolution2dLayer(descriptor, weights, layerName); + IConnectableLayer* const layer = net.AddDepthwiseConvolution2dLayer(descriptor, + weights, + EmptyOptional(), + layerName); layer->Accept(visitor); } @@ -279,12 +284,13 @@ BOOST_AUTO_TEST_CASE(CheckDepthwiseConvolution2dLayerWithBiases) std::vector<float> biasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0}; std::vector<unsigned int> biasDimensions = {1, 1, 3, 3}; ConstTensor biases(TensorInfo(4, biasDimensions.data(), DataType::Float32), biasData); + Optional<ConstTensor> optionalBiases(biases); - TestDepthwiseConvolution2dLayerVisitor visitor(descriptor, weights, Optional<ConstTensor>(biases)); + TestDepthwiseConvolution2dLayerVisitor visitor(descriptor, weights, optionalBiases); Network net; - IConnectableLayer* const layer = net.AddDepthwiseConvolution2dLayer(descriptor, weights, biases); + IConnectableLayer* const layer = net.AddDepthwiseConvolution2dLayer(descriptor, weights, optionalBiases); layer->Accept(visitor); } @@ -308,12 +314,13 @@ BOOST_AUTO_TEST_CASE(CheckNamedDepthwiseConvolution2dLayerWithBiases) std::vector<float> biasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0}; std::vector<unsigned int> biasDimensions = {1, 1, 3, 3}; ConstTensor biases(TensorInfo(4, biasDimensions.data(), DataType::Float32), biasData); + Optional<ConstTensor> optionalBiases(biases); - TestDepthwiseConvolution2dLayerVisitor visitor(descriptor, weights, Optional<ConstTensor>(biases), layerName); + TestDepthwiseConvolution2dLayerVisitor visitor(descriptor, weights, optionalBiases, layerName); Network net; - IConnectableLayer* const layer = net.AddDepthwiseConvolution2dLayer(descriptor, weights, biases, layerName); + IConnectableLayer* const layer = net.AddDepthwiseConvolution2dLayer(descriptor, weights, optionalBiases, layerName); layer->Accept(visitor); } @@ -330,7 +337,7 @@ BOOST_AUTO_TEST_CASE(CheckFullyConnectedLayer) Network net; - IConnectableLayer* const layer = net.AddFullyConnectedLayer(descriptor, weights); + IConnectableLayer* const layer = net.AddFullyConnectedLayer(descriptor, weights, EmptyOptional()); layer->Accept(visitor); } @@ -348,7 +355,7 @@ BOOST_AUTO_TEST_CASE(CheckNamedFullyConnectedLayer) Network net; - IConnectableLayer* const layer = net.AddFullyConnectedLayer(descriptor, weights, layerName); + IConnectableLayer* const layer = net.AddFullyConnectedLayer(descriptor, weights, EmptyOptional(), layerName); layer->Accept(visitor); } @@ -365,12 +372,13 @@ BOOST_AUTO_TEST_CASE(CheckFullyConnectedLayerWithBiases) std::vector<float> biasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0}; std::vector<unsigned int> biasDimensions = {1, 1, 3, 3}; ConstTensor biases(TensorInfo(4, biasDimensions.data(), DataType::Float32), biasData); + Optional<ConstTensor> optionalBiases(biases); - TestFullyConnectedLayerVistor visitor(descriptor, weights, Optional<ConstTensor>(biases)); + TestFullyConnectedLayerVistor visitor(descriptor, weights, optionalBiases); Network net; - IConnectableLayer* const layer = net.AddFullyConnectedLayer(descriptor, weights, biases); + IConnectableLayer* const layer = net.AddFullyConnectedLayer(descriptor, weights, optionalBiases); layer->Accept(visitor); } @@ -388,12 +396,13 @@ BOOST_AUTO_TEST_CASE(CheckNamedFullyConnectedLayerWithBiases) std::vector<float> biasData = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0}; std::vector<unsigned int> biasDimensions = {1, 1, 3, 3}; ConstTensor biases(TensorInfo(4, biasDimensions.data(), DataType::Float32), biasData); + Optional<ConstTensor> optionalBiases(biases); - TestFullyConnectedLayerVistor visitor(descriptor, weights, Optional<ConstTensor>(biases), layerName); + TestFullyConnectedLayerVistor visitor(descriptor, weights, optionalBiases, layerName); Network net; - IConnectableLayer* const layer = net.AddFullyConnectedLayer(descriptor, weights, biases, layerName); + IConnectableLayer* const layer = net.AddFullyConnectedLayer(descriptor, weights, optionalBiases, layerName); layer->Accept(visitor); } diff --git a/src/armnn/test/CreateWorkload.hpp b/src/armnn/test/CreateWorkload.hpp index a68a6e3f42..1193ab721e 100644 --- a/src/armnn/test/CreateWorkload.hpp +++ b/src/armnn/test/CreateWorkload.hpp @@ -1148,12 +1148,18 @@ std::pair<armnn::IOptimizedNetworkPtr, std::unique_ptr<PreCompiledWorkload>> Cre armnn::ConstTensor biases(biasTensorInfo, biasData); // Create convolution layer with biases - convLayer = net.AddConvolution2dLayer(convDesc2d, weights, biases, convLayerName.c_str()); + convLayer = net.AddConvolution2dLayer(convDesc2d, + weights, + Optional<ConstTensor>(biases), + convLayerName.c_str()); } else { // Create convolution layer without biases - convLayer = net.AddConvolution2dLayer(convDesc2d, weights, convLayerName.c_str()); + convLayer = net.AddConvolution2dLayer(convDesc2d, + weights, + EmptyOptional(), + convLayerName.c_str()); } BOOST_TEST(convLayer); diff --git a/src/armnn/test/NetworkTests.cpp b/src/armnn/test/NetworkTests.cpp index 155304be36..47fd67b8d4 100644 --- a/src/armnn/test/NetworkTests.cpp +++ b/src/armnn/test/NetworkTests.cpp @@ -78,7 +78,10 @@ BOOST_AUTO_TEST_CASE(NetworkModification) armnn::ConstTensor weights(armnn::TensorInfo(4, dims, armnn::DataType::Float32), convWeightsData); armnn::Convolution2dDescriptor convDesc2d; - armnn::IConnectableLayer* const convLayer = net.AddConvolution2dLayer(convDesc2d, weights, "conv layer"); + armnn::IConnectableLayer* const convLayer = net.AddConvolution2dLayer(convDesc2d, + weights, + armnn::EmptyOptional(), + "conv layer"); BOOST_TEST(convLayer); inputLayer->GetOutputSlot(0).Connect(convLayer->GetInputSlot(0)); @@ -86,6 +89,7 @@ BOOST_AUTO_TEST_CASE(NetworkModification) armnn::FullyConnectedDescriptor fullyConnectedDesc; armnn::IConnectableLayer* const fullyConnectedLayer = net.AddFullyConnectedLayer(fullyConnectedDesc, weights, + armnn::EmptyOptional(), "fully connected"); BOOST_TEST(fullyConnectedLayer); diff --git a/src/armnn/test/QuantizerTest.cpp b/src/armnn/test/QuantizerTest.cpp index 4f22317651..f2c739d274 100644 --- a/src/armnn/test/QuantizerTest.cpp +++ b/src/armnn/test/QuantizerTest.cpp @@ -686,16 +686,14 @@ INetworkPtr CreateNetworkWithFullyConnectedLayer(const bool biasEnabled, // Add the layers IConnectableLayer* input0 = network->AddInputLayer(0); IConnectableLayer* fullyConnected; + Optional<ConstTensor> optionalBias; + std::vector<float> biasData{10.0f, 20.0f, 30.0f}; if (desc.m_BiasEnabled) { - std::vector<float> biasData{10.0f, 20.0f, 30.0f}; ConstTensor bias(info, biasData); - fullyConnected = network->AddFullyConnectedLayer(desc, weights, bias); - } - else - { - fullyConnected = network->AddFullyConnectedLayer(desc, weights); + optionalBias = Optional<ConstTensor>(bias); } + fullyConnected = network->AddFullyConnectedLayer(desc, weights, optionalBias); IConnectableLayer* output = network->AddOutputLayer(1); // Establish connections @@ -814,16 +812,14 @@ void TestQuantizeConvolution2d(bool useBiases) // Add the layers IConnectableLayer* input0 = network->AddInputLayer(0); IConnectableLayer* conv2d; + Optional<ConstTensor> optionalBiases; + std::vector<float> biasesData{-1.0f, 1.5f, 2.0f}; if (useBiases) { - std::vector<float> biasesData{-1.0f, 1.5f, 2.0f}; ConstTensor biases(info, biasesData); - conv2d = network->AddConvolution2dLayer(descriptor, weights, biases); - } - else - { - conv2d = network->AddConvolution2dLayer(descriptor, weights); + optionalBiases = Optional<ConstTensor>(biases); } + conv2d = network->AddConvolution2dLayer(descriptor, weights, optionalBiases); IConnectableLayer* output = network->AddOutputLayer(1); // Establish connections @@ -902,16 +898,14 @@ void TestQuantizeDepthwiseConvolution2d(bool useBiases) // Add the layers IConnectableLayer* input0 = network->AddInputLayer(0); IConnectableLayer* depthwiseConv2d; + Optional<ConstTensor> optionalBiases; + std::vector<float> biasesData{-1.0f, 1.5f, 2.0f}; if (useBiases) { - std::vector<float> biasesData{-1.0f, 1.5f, 2.0f}; ConstTensor biases(info, biasesData); - depthwiseConv2d = network->AddDepthwiseConvolution2dLayer(descriptor, weights, biases); - } - else - { - depthwiseConv2d = network->AddDepthwiseConvolution2dLayer(descriptor, weights); + optionalBiases = Optional<ConstTensor>(biases); } + depthwiseConv2d = network->AddDepthwiseConvolution2dLayer(descriptor, weights, optionalBiases); IConnectableLayer* output = network->AddOutputLayer(1); // Establish connections |