32 TEST_CASE(
"LayerGuids")
39 CHECK(inputId != addId);
40 CHECK(addId != outputId);
41 CHECK(inputId != outputId);
44 TEST_CASE(
"NetworkBasic")
50 TEST_CASE(
"LayerNamesAreOptionalForINetwork")
53 inet->AddInputLayer(0);
54 inet->AddAdditionLayer();
56 inet->AddOutputLayer(0);
59 TEST_CASE(
"LayerNamesAreOptionalForNetwork")
68 TEST_CASE(
"NetworkModification")
75 unsigned int dims[] = { 10,1,1,1 };
76 std::vector<float> convWeightsData(10);
94 CHECK(constantWeightsLayer);
95 CHECK(fullyConnectedLayer);
108 CHECK(activationLayer);
114 CHECK(normalizationLayer);
127 std::vector<float> data(tensorInfo.GetNumBytes() /
sizeof(float));
136 CHECK(batchNormalizationLayer);
141 CHECK(additionLayer);
147 CHECK(multiplicationLayer);
174 auto checkOneOutputToOneInputConnection = []
177 int expectedSrcNumInputs = 1,
178 int expectedDstNumOutputs = 1)
182 CHECK(tgtLayer->GetNumInputSlots() == 1);
183 CHECK(tgtLayer->GetNumOutputSlots() == expectedDstNumOutputs);
189 auto checkOneOutputToTwoInputsConnections = []
192 int expectedSrcNumInputs,
193 int expectedDstNumOutputs = 1)
197 CHECK(tgtLayer->GetNumInputSlots() == 2);
198 CHECK(tgtLayer->GetNumOutputSlots() == expectedDstNumOutputs);
207 auto checkOneOutputToTwoInputConnectionForTwoDifferentLayers = []
211 int expectedSrcNumInputs1 = 1,
212 int expectedSrcNumInputs2 = 1,
213 int expectedDstNumOutputs = 1)
217 CHECK(srcLayer2->GetNumInputSlots() == expectedSrcNumInputs2);
218 CHECK(srcLayer2->GetNumOutputSlots() == 1);
219 CHECK(tgtLayer->GetNumInputSlots() == 2);
220 CHECK(tgtLayer->GetNumOutputSlots() == expectedDstNumOutputs);
223 CHECK(srcLayer2->GetOutputSlot(0).GetNumConnections() == 1);
225 CHECK(srcLayer2->GetOutputSlot(0).GetConnection(0) == &tgtLayer->GetInputSlot(1));
227 CHECK(&srcLayer2->GetOutputSlot(0) == tgtLayer->GetInputSlot(1).GetConnection());
230 CHECK(AreAllLayerInputSlotsConnected(*convLayer));
231 CHECK(AreAllLayerInputSlotsConnected(*fullyConnectedLayer));
232 CHECK(AreAllLayerInputSlotsConnected(*poolingLayer));
233 CHECK(AreAllLayerInputSlotsConnected(*activationLayer));
234 CHECK(AreAllLayerInputSlotsConnected(*normalizationLayer));
235 CHECK(AreAllLayerInputSlotsConnected(*softmaxLayer));
236 CHECK(AreAllLayerInputSlotsConnected(*batchNormalizationLayer));
237 CHECK(AreAllLayerInputSlotsConnected(*additionLayer));
238 CHECK(AreAllLayerInputSlotsConnected(*multiplicationLayer));
239 CHECK(AreAllLayerInputSlotsConnected(*outputLayer));
242 checkOneOutputToOneInputConnection(inputLayer, convLayer, 0);
243 checkOneOutputToTwoInputConnectionForTwoDifferentLayers(convLayer, constantWeightsLayer, fullyConnectedLayer, 1, 0);
244 checkOneOutputToOneInputConnection(fullyConnectedLayer, poolingLayer, 2, 1);
245 checkOneOutputToOneInputConnection(poolingLayer, activationLayer);
246 checkOneOutputToOneInputConnection(activationLayer, normalizationLayer);
247 checkOneOutputToOneInputConnection(normalizationLayer, softmaxLayer);
248 checkOneOutputToOneInputConnection(softmaxLayer, batchNormalizationLayer);
249 checkOneOutputToTwoInputsConnections(batchNormalizationLayer, additionLayer, 1);
250 checkOneOutputToTwoInputsConnections(additionLayer, multiplicationLayer, 2);
251 checkOneOutputToOneInputConnection(multiplicationLayer, outputLayer, 2, 0);
254 TEST_CASE(
"NetworkModification_SplitterConcat")
266 CHECK(splitterLayer);
273 CHECK(softmaxLayer1);
279 CHECK(softmaxLayer2);
311 TEST_CASE(
"NetworkModification_SplitterAddition")
323 CHECK(splitterLayer);
330 CHECK(softmax1Layer);
336 CHECK(softmax2Layer);
356 TEST_CASE(
"NetworkModification_SplitterMultiplication")
367 CHECK(splitterLayer);
374 CHECK(softmax1Layer);
380 CHECK(softmax2Layer);
399 TEST_CASE(
"Network_AddQuantize")
405 const std::vector<armnn::ConstTensor>& constants,
420 std::string expectedName = std::string(
"quantize");
421 CHECK(std::string(layer->
GetName()) == expectedName);
422 CHECK(std::string(name) == expectedName);
441 bool m_Visited =
false;
447 auto input = graph->AddInputLayer(0,
"input");
448 auto quantize = graph->AddQuantizeLayer(
"quantize");
449 auto output = graph->AddOutputLayer(1,
"output");
451 input->GetOutputSlot(0).Connect(quantize->GetInputSlot(0));
452 quantize->GetOutputSlot(0).Connect(output->GetInputSlot(0));
455 input->GetOutputSlot(0).SetTensorInfo(infoIn);
458 quantize->GetOutputSlot(0).SetTensorInfo(infoOut);
461 graph->ExecuteStrategy(testQuantize);
463 CHECK(testQuantize.m_Visited ==
true);
467 TEST_CASE(
"Network_AddMerge")
473 const std::vector<armnn::ConstTensor>& constants,
488 std::string expectedName = std::string(
"merge");
489 CHECK(std::string(layer->
GetName()) == expectedName);
490 CHECK(std::string(name) == expectedName);
512 bool m_Visited =
false;
532 network->ExecuteStrategy(testMerge);
534 CHECK(testMerge.m_Visited ==
true);
537 TEST_CASE(
"StandInLayerNetworkTest")
558 floor->GetOutputSlot(0).Connect(standIn->GetInputSlot(0));
560 standIn->GetOutputSlot(0).Connect(output->
GetInputSlot(0));
565 CHECK(input->GetOutputSlot(0).GetConnection(0) == &floor->GetInputSlot(0));
566 CHECK(floor->GetOutputSlot(0).GetConnection(0) == &standIn->GetInputSlot(0));
567 CHECK(standIn->GetOutputSlot(0).GetConnection(0) == &output->
GetInputSlot(0));
570 TEST_CASE(
"StandInLayerSingleInputMultipleOutputsNetworkTest")
592 standIn->GetOutputSlot(0).Connect(output0->GetInputSlot(0));
593 standIn->GetOutputSlot(1).Connect(output1->GetInputSlot(0));
598 CHECK(input->GetOutputSlot(0).GetConnection(0) == &standIn->GetInputSlot(0));
599 CHECK(standIn->GetOutputSlot(0).GetConnection(0) == &output0->GetInputSlot(0));
600 CHECK(standIn->GetOutputSlot(1).GetConnection(0) == &output1->GetInputSlot(0));
virtual unsigned int GetNumOutputSlots() const =0
Returns the number of connectable output slots.
A ViewsDescriptor for the SplitterLayer.
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
virtual unsigned int GetNumInputSlots() const =0
Returns the number of connectable input slots.
IConnectableLayer * AddAdditionLayer(const char *name=nullptr)
IConnectableLayer * AddPooling2dLayer(const Pooling2dDescriptor &pooling2dDescriptor, const char *name=nullptr)
A Convolution2dDescriptor for the Convolution2dLayer.
virtual void ExecuteStrategy(const armnn::IConnectableLayer *layer, const armnn::BaseDescriptor &descriptor, const std::vector< armnn::ConstTensor > &constants, const char *name, const armnn::LayerBindingId id=0)=0
IConnectableLayer * AddConstantLayer(const ConstTensor &input, const char *name=nullptr)
IConnectableLayer * AddNormalizationLayer(const NormalizationDescriptor &normalizationDescriptor, const char *name=nullptr)
bool GraphHasNamedLayer(const armnn::Graph &graph, const std::string &name)
IConnectableLayer * AddActivationLayer(const ActivationDescriptor &activationDescriptor, const char *name=nullptr)
void IgnoreUnused(Ts &&...)
virtual const IInputSlot * GetConnection(unsigned int index) const =0
Private implementation of INetwork.
int LayerBindingId
Type of identifiers for bindable layers (inputs, outputs).
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
uint32_t m_NumOutputs
Number of output tensors.
Base class for all descriptors.
IConnectableLayer * AddFloorLayer(const char *name=nullptr)
IConnectableLayer * AddMultiplicationLayer(const char *name=nullptr)
IConnectableLayer * AddInputLayer(LayerBindingId id, const char *name=nullptr)
DataType GetDataType() const
An OriginsDescriptor for the ConcatLayer.
A FullyConnectedDescriptor for the FullyConnectedLayer.
virtual LayerGuid GetGuid() const =0
Returns the unique id of the layer.
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
IConnectableLayer * AddOutputLayer(LayerBindingId id, const char *name=nullptr)
IConnectableLayer * AddConcatLayer(const ConcatDescriptor &concatDescriptor, const char *name=nullptr)
A StandInDescriptor for the StandIn layer.
An ActivationDescriptor for the ActivationLayer.
IConnectableLayer * AddStandInLayer(const StandInDescriptor &descriptor, const char *name=nullptr)
virtual LayerType GetType() const =0
Returns the armnn::LayerType of this layer.
EmptyOptional is used to initialize the Optional class in case we want to have default value for an O...
IConnectableLayer * AddFullyConnectedLayer(const FullyConnectedDescriptor &fullyConnectedDescriptor, const char *name=nullptr)
IConnectableLayer * AddSoftmaxLayer(const SoftmaxDescriptor &softmaxDescriptor, const char *name=nullptr)
uint32_t m_NumInputs
Number of input tensors.
const Graph & GetGraph() const
profiling::ProfilingGuid LayerGuid
Define LayerGuid type.
virtual const IInputSlot & GetInputSlot(unsigned int index) const =0
Get a const input slot handle by slot index.
virtual const TensorInfo & GetTensorInfo() const =0
virtual const IOutputSlot & GetOutputSlot(unsigned int index) const =0
Get the const output slot handle by slot index.
virtual unsigned int GetNumConnections() const =0
virtual const char * GetName() const =0
Returns the name of the layer.
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
IConnectableLayer * AddBatchNormalizationLayer(const BatchNormalizationDescriptor &desc, const ConstTensor &mean, const ConstTensor &variance, const ConstTensor &beta, const ConstTensor &gamma, const char *name=nullptr)
virtual int Connect(IInputSlot &destination)=0
A Pooling2dDescriptor for the Pooling2dLayer.
A NormalizationDescriptor for the NormalizationLayer.
size_t GetNumLayers() const
IConnectableLayer * AddConvolution2dLayer(const Convolution2dDescriptor &convolution2dDescriptor, const ConstTensor &weights, const Optional< ConstTensor > &biases, const char *name=nullptr)
IConnectableLayer * AddSplitterLayer(const ViewsDescriptor &splitterDescriptor, const char *name=nullptr)
static INetworkPtr Create(NetworkOptions networkOptions={})
A SoftmaxDescriptor for the SoftmaxLayer.
A BatchNormalizationDescriptor for the BatchNormalizationLayer.