ArmNN
 22.08
RuntimeTestImpl.hpp
Go to the documentation of this file.
1 //
2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 #pragma once
6 
7 
8 #include <Runtime.hpp>
9 
10 namespace
11 {
12 
13 inline void CreateAndDropDummyNetwork(const std::vector<armnn::BackendId>& backends, armnn::RuntimeImpl& runtime)
14 {
15  armnn::NetworkId networkIdentifier;
16  {
19 
21 
22  armnn::IConnectableLayer* input = network->AddInputLayer(0, "input");
23  armnn::IConnectableLayer* layer = network->AddActivationLayer(armnn::ActivationDescriptor(), "test");
24  armnn::IConnectableLayer* output = network->AddOutputLayer(0, "output");
25 
26  input->GetOutputSlot(0).Connect(layer->GetInputSlot(0));
27  layer->GetOutputSlot(0).Connect(output->GetInputSlot(0));
28 
29  // Sets the tensors in the network.
30  input->GetOutputSlot(0).SetTensorInfo(inputTensorInfo);
31  layer->GetOutputSlot(0).SetTensorInfo(outputTensorInfo);
32 
33  // optimize the network
34  armnn::IOptimizedNetworkPtr optNet = Optimize(*network, backends, runtime.GetDeviceSpec());
35 
36  runtime.LoadNetwork(networkIdentifier, std::move(optNet));
37  }
38 
39  runtime.UnloadNetwork(networkIdentifier);
40 }
41 
42 } // anonymous namespace
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition: INetwork.hpp:68
Status UnloadNetwork(NetworkId networkId)
Unloads a network from the Runtime.
Definition: Runtime.cpp:229
Status LoadNetwork(NetworkId &networkIdOut, IOptimizedNetworkPtr network)
Loads a complete network into the Runtime.
Definition: Runtime.cpp:163
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
IOptimizedNetworkPtr Optimize(const INetwork &network, const std::vector< BackendId > &backendPreferences, const IDeviceSpec &deviceSpec, const OptimizerOptions &options=OptimizerOptions(), Optional< std::vector< std::string > &> messages=EmptyOptional())
Create an optimized version of the network.
Definition: Network.cpp:1864
const IDeviceSpec & GetDeviceSpec() const
Definition: Runtime.hpp:90
int NetworkId
Definition: IRuntime.hpp:27
std::unique_ptr< IOptimizedNetwork, void(*)(IOptimizedNetwork *network)> IOptimizedNetworkPtr
Definition: INetwork.hpp:239
An ActivationDescriptor for the ActivationLayer.
Definition: Descriptors.hpp:36
virtual const IInputSlot & GetInputSlot(unsigned int index) const =0
Get a const input slot handle by slot index.
virtual const IOutputSlot & GetOutputSlot(unsigned int index) const =0
Get the const output slot handle by slot index.
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:238
virtual int Connect(IInputSlot &destination)=0
static INetworkPtr Create(NetworkOptions networkOptions={})
Definition: Network.cpp:475