diff options
author | Francis Murtagh <francis.murtagh@arm.com> | 2022-02-09 15:13:38 +0000 |
---|---|---|
committer | Francis Murtagh <francis.murtagh@arm.com> | 2022-02-16 10:26:39 +0000 |
commit | bb6c6490b43036400e3c2ff90d3beafe074ab0b1 (patch) | |
tree | 49c05a44c00b0f009fa3913c45dc20496762ec5e /samples | |
parent | 154258132955f0bd74ef26a0cc20b7daca4d7b09 (diff) | |
download | armnn-bb6c6490b43036400e3c2ff90d3beafe074ab0b1.tar.gz |
IVGCVSW-6399 Remove deprecated code 22.02 (FullyConnected)
* Remove deprecated INetwork::AddFullyconnectedLayer() taking weights
as argument as they are now taken as separate input layers.
* Updated test that was using the deprecated function.
* Remove calls in pyarmnn
Signed-off-by: Francis Murtagh <francis.murtagh@arm.com>
Change-Id: Ibc52ac7fa57afd9033eb226bbc24a09e88a7d361
Diffstat (limited to 'samples')
-rw-r--r-- | samples/CustomMemoryAllocatorSample.cpp | 47 |
1 files changed, 24 insertions, 23 deletions
diff --git a/samples/CustomMemoryAllocatorSample.cpp b/samples/CustomMemoryAllocatorSample.cpp index a1b05d4be0..da249e0f4d 100644 --- a/samples/CustomMemoryAllocatorSample.cpp +++ b/samples/CustomMemoryAllocatorSample.cpp @@ -71,26 +71,27 @@ int main() // Turn on logging to standard output // This is useful in this sample so that users can learn more about what is going on - armnn::ConfigureLogging(true, false, LogSeverity::Info); + ConfigureLogging(true, false, LogSeverity::Info); // Construct ArmNN network - armnn::NetworkId networkIdentifier; - INetworkPtr myNetwork = INetwork::Create(); - armnn::FullyConnectedDescriptor fullyConnectedDesc; + NetworkId networkIdentifier; + INetworkPtr network = INetwork::Create(); + FullyConnectedDescriptor fullyConnectedDesc; float weightsData[] = {1.0f}; // Identity TensorInfo weightsInfo(TensorShape({1, 1}), DataType::Float32, 0.0f, 0, true); weightsInfo.SetConstant(true); - armnn::ConstTensor weights(weightsInfo, weightsData); - ARMNN_NO_DEPRECATE_WARN_BEGIN - IConnectableLayer *fullyConnected = myNetwork->AddFullyConnectedLayer(fullyConnectedDesc, - weights, - EmptyOptional(), - "fully connected"); - ARMNN_NO_DEPRECATE_WARN_END - IConnectableLayer *InputLayer = myNetwork->AddInputLayer(0); - IConnectableLayer *OutputLayer = myNetwork->AddOutputLayer(0); - InputLayer->GetOutputSlot(0).Connect(fullyConnected->GetInputSlot(0)); - fullyConnected->GetOutputSlot(0).Connect(OutputLayer->GetInputSlot(0)); + ConstTensor weights(weightsInfo, weightsData); + + IConnectableLayer* inputLayer = network->AddInputLayer(0); + IConnectableLayer* weightsLayer = network->AddConstantLayer(weights, "Weights"); + IConnectableLayer* fullyConnectedLayer = + network->AddFullyConnectedLayer(fullyConnectedDesc, "fully connected"); + IConnectableLayer* outputLayer = network->AddOutputLayer(0); + + inputLayer->GetOutputSlot(0).Connect(fullyConnectedLayer->GetInputSlot(0)); + weightsLayer->GetOutputSlot(0).Connect(fullyConnectedLayer->GetInputSlot(1)); + fullyConnectedLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0)); + weightsLayer->GetOutputSlot(0).SetTensorInfo(weightsInfo); // Create ArmNN runtime: // @@ -111,19 +112,19 @@ int main() //Set the tensors in the network. TensorInfo inputTensorInfo(TensorShape({1, 1}), DataType::Float32); - InputLayer->GetOutputSlot(0).SetTensorInfo(inputTensorInfo); + inputLayer->GetOutputSlot(0).SetTensorInfo(inputTensorInfo); unsigned int numElements = inputTensorInfo.GetNumElements(); size_t totalBytes = numElements * sizeof(float); TensorInfo outputTensorInfo(TensorShape({1, 1}), DataType::Float32); - fullyConnected->GetOutputSlot(0).SetTensorInfo(outputTensorInfo); + fullyConnectedLayer->GetOutputSlot(0).SetTensorInfo(outputTensorInfo); // Optimise ArmNN network OptimizerOptions optOptions; optOptions.m_ImportEnabled = true; - armnn::IOptimizedNetworkPtr optNet = - Optimize(*myNetwork, {"GpuAcc"}, runtime->GetDeviceSpec(), optOptions); + IOptimizedNetworkPtr optNet = + Optimize(*network, {"GpuAcc"}, runtime->GetDeviceSpec(), optOptions); if (!optNet) { // This shouldn't happen for this simple sample, with GpuAcc backend. @@ -154,13 +155,13 @@ int main() inputTensorInfo = runtime->GetInputTensorInfo(networkIdentifier, 0); inputTensorInfo.SetConstant(true); - armnn::InputTensors inputTensors + InputTensors inputTensors { - {0, armnn::ConstTensor(inputTensorInfo, alignedInputPtr)}, + {0, ConstTensor(inputTensorInfo, alignedInputPtr)}, }; - armnn::OutputTensors outputTensors + OutputTensors outputTensors { - {0, armnn::Tensor(runtime->GetOutputTensorInfo(networkIdentifier, 0), alignedOutputPtr)} + {0, Tensor(runtime->GetOutputTensorInfo(networkIdentifier, 0), alignedOutputPtr)} }; // Execute network |