aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancis Murtagh <francis.murtagh@arm.com>2021-08-06 15:50:46 +0100
committerFrancis Murtagh <francis.murtagh@arm.com>2021-08-06 19:29:29 +0000
commitcd92c9c3835f4e5d1677b3f3aaae9e49a62bd537 (patch)
tree612372b23c15c7489ae5ae16fc285f4885d966eb
parent61132ac4d98f80eaf93c28f3044be02dc039014b (diff)
downloadarmnn-cd92c9c3835f4e5d1677b3f3aaae9e49a62bd537.tar.gz
Fix SimpleSample to use new FullyConnected API
* Remove deprecated code from public examples Signed-off-by: Francis Murtagh <francis.murtagh@arm.com> Change-Id: Ia6c4f8d7f8c477b776d96e66085996487e8fdc75
-rw-r--r--samples/SimpleSample.cpp37
1 files changed, 19 insertions, 18 deletions
diff --git a/samples/SimpleSample.cpp b/samples/SimpleSample.cpp
index 6e8b461a92..6bdc2983bb 100644
--- a/samples/SimpleSample.cpp
+++ b/samples/SimpleSample.cpp
@@ -21,28 +21,28 @@ 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::Warning);
+ ConfigureLogging(true, false, LogSeverity::Warning);
// Construct ArmNN network
- armnn::NetworkId networkIdentifier;
+ NetworkId networkIdentifier;
INetworkPtr myNetwork = INetwork::Create();
- armnn::FullyConnectedDescriptor fullyConnectedDesc;
float weightsData[] = {1.0f}; // Identity
TensorInfo weightsInfo(TensorShape({1, 1}), DataType::Float32);
- armnn::ConstTensor weights(weightsInfo, weightsData);
- ARMNN_NO_DEPRECATE_WARN_BEGIN
- IConnectableLayer *fullyConnected = myNetwork->AddFullyConnectedLayer(fullyConnectedDesc,
- weights,
- EmptyOptional(),
- "fully connected");
- ARMNN_NO_DEPRECATE_WARN_END
+ ConstTensor weights(weightsInfo, weightsData);
- IConnectableLayer *InputLayer = myNetwork->AddInputLayer(0);
- IConnectableLayer *OutputLayer = myNetwork->AddOutputLayer(0);
+ // Constant layer that now holds weights data for FullyConnected
+ IConnectableLayer* const constantWeightsLayer = myNetwork->AddConstantLayer(weights, "const weights");
- InputLayer->GetOutputSlot(0).Connect(fullyConnected->GetInputSlot(0));
- fullyConnected->GetOutputSlot(0).Connect(OutputLayer->GetInputSlot(0));
+ FullyConnectedDescriptor fullyConnectedDesc;
+ IConnectableLayer* const fullyConnectedLayer = myNetwork->AddFullyConnectedLayer(fullyConnectedDesc,
+ "fully connected");
+ IConnectableLayer* InputLayer = myNetwork->AddInputLayer(0);
+ IConnectableLayer* OutputLayer = myNetwork->AddOutputLayer(0);
+
+ InputLayer->GetOutputSlot(0).Connect(fullyConnectedLayer->GetInputSlot(0));
+ constantWeightsLayer->GetOutputSlot(0).Connect(fullyConnectedLayer->GetInputSlot(1));
+ fullyConnectedLayer->GetOutputSlot(0).Connect(OutputLayer->GetInputSlot(0));
// Create ArmNN runtime
IRuntime::CreationOptions options; // default options
@@ -53,10 +53,11 @@ int main()
InputLayer->GetOutputSlot(0).SetTensorInfo(inputTensorInfo);
TensorInfo outputTensorInfo(TensorShape({1, 1}), DataType::Float32);
- fullyConnected->GetOutputSlot(0).SetTensorInfo(outputTensorInfo);
+ fullyConnectedLayer->GetOutputSlot(0).SetTensorInfo(outputTensorInfo);
+ constantWeightsLayer->GetOutputSlot(0).SetTensorInfo(outputTensorInfo);
// Optimise ArmNN network
- armnn::IOptimizedNetworkPtr optNet = Optimize(*myNetwork, {Compute::CpuRef}, run->GetDeviceSpec());
+ IOptimizedNetworkPtr optNet = Optimize(*myNetwork, {Compute::CpuRef}, run->GetDeviceSpec());
if (!optNet)
{
// This shouldn't happen for this simple sample, with reference backend.
@@ -74,9 +75,9 @@ int main()
std::vector<float> outputData(1);
- armnn::InputTensors inputTensors{{0, armnn::ConstTensor(run->GetInputTensorInfo(networkIdentifier, 0),
+ InputTensors inputTensors{{0, armnn::ConstTensor(run->GetInputTensorInfo(networkIdentifier, 0),
inputData.data())}};
- armnn::OutputTensors outputTensors{{0, armnn::Tensor(run->GetOutputTensorInfo(networkIdentifier, 0),
+ OutputTensors outputTensors{{0, armnn::Tensor(run->GetOutputTensorInfo(networkIdentifier, 0),
outputData.data())}};
// Execute network