diff options
-rw-r--r-- | samples/SimpleSample.cpp | 37 |
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 |