ArmNN
 20.02
FlowControl.cpp File Reference
#include <armnn/Descriptors.hpp>
#include <armnn/IRuntime.hpp>
#include <armnn/INetwork.hpp>
#include <boost/test/unit_test.hpp>
#include <set>

Go to the source code of this file.

Functions

 BOOST_AUTO_TEST_CASE (ErrorOnLoadNetwork)
 

Function Documentation

◆ BOOST_AUTO_TEST_CASE()

BOOST_AUTO_TEST_CASE ( ErrorOnLoadNetwork  )

Definition at line 16 of file FlowControl.cpp.

References armnn::Boolean, BOOST_AUTO_TEST_SUITE_END(), BOOST_CHECK(), IOutputSlot::Connect(), armnn::CpuRef, INetwork::Create(), IRuntime::Create(), IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), armnn::Optimize(), options, and IOutputSlot::SetTensorInfo().

17 {
18  using namespace armnn;
19 
20  // Create runtime in which test will run
22  IRuntimePtr runtime(IRuntime::Create(options));
23 
24  // build up the structure of the network
25  // It's equivalent to something like
26  // if (0) {} else {}
28 
29  std::vector<uint8_t> falseData = {0};
30  ConstTensor falseTensor(armnn::TensorInfo({1}, armnn::DataType::Boolean), falseData);
31  IConnectableLayer* constLayer = net->AddConstantLayer(falseTensor, "const");
33 
34  IConnectableLayer* input = net->AddInputLayer(0);
35 
36  IConnectableLayer* switchLayer = net->AddSwitchLayer("switch");
37  IConnectableLayer* mergeLayer = net->AddMergeLayer("merge");
38 
39  IConnectableLayer* output = net->AddOutputLayer(0);
40 
41  input->GetOutputSlot(0).Connect(switchLayer->GetInputSlot(0));
42  constLayer->GetOutputSlot(0).Connect(switchLayer->GetInputSlot(1));
43  switchLayer->GetOutputSlot(0).Connect(mergeLayer->GetInputSlot(0));
44  switchLayer->GetOutputSlot(1).Connect(mergeLayer->GetInputSlot(1));
45  mergeLayer->GetOutputSlot(0).Connect(output->GetInputSlot(0));
46 
47  // optimize the network
48  std::vector<BackendId> backends = {Compute::CpuRef};
49  IOptimizedNetworkPtr optNet = Optimize(*net, backends, runtime->GetDeviceSpec());
50  BOOST_CHECK(!optNet); // Should have failed to optimise, as flow control is not yet implemented
51 }
static IRuntimePtr Create(const CreationOptions &options)
Definition: Runtime.cpp:32
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition: INetwork.hpp:61
CPU Execution: Reference C++ kernels.
std::unique_ptr< IRuntime, void(*)(IRuntime *runtime)> IRuntimePtr
Definition: IRuntime.hpp:24
Copyright (c) 2020 ARM Limited.
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)
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:890
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
Definition: Tensor.hpp:199
std::unique_ptr< IOptimizedNetwork, void(*)(IOptimizedNetwork *network)> IOptimizedNetworkPtr
Definition: INetwork.hpp:566
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:101
virtual int Connect(IInputSlot &destination)=0
armnn::Runtime::CreationOptions::ExternalProfilingOptions options
static INetworkPtr Create()
Definition: Network.cpp:49