12 #include <boost/test/unit_test.hpp> 19 bool allConnected =
true;
23 allConnected &= inputConnected;
39 BOOST_TEST(inputId != addId);
40 BOOST_TEST(addId != outputId);
41 BOOST_TEST(inputId != outputId);
74 BOOST_TEST(inputLayer);
76 unsigned int dims[] = { 10,1,1,1 };
77 std::vector<float> convWeightsData(10);
85 BOOST_TEST(convLayer);
94 BOOST_TEST(fullyConnectedLayer);
100 BOOST_TEST(poolingLayer);
106 BOOST_TEST(activationLayer);
112 BOOST_TEST(normalizationLayer);
118 BOOST_TEST(softmaxLayer);
125 std::vector<float> data(tensorInfo.GetNumBytes() /
sizeof(float));
134 BOOST_TEST(batchNormalizationLayer);
139 BOOST_TEST(additionLayer);
145 BOOST_TEST(multiplicationLayer);
151 BOOST_TEST(outputLayer);
171 auto checkOneOutputToOneInputConnection = []
174 int expectedSrcNumInputs = 1,
175 int expectedDstNumOutputs = 1)
179 BOOST_TEST(tgtLayer->GetNumInputSlots() == 1);
180 BOOST_TEST(tgtLayer->GetNumOutputSlots() == expectedDstNumOutputs);
186 auto checkOneOutputToTwoInputsConnections = []
189 int expectedSrcNumInputs,
190 int expectedDstNumOutputs = 1)
194 BOOST_TEST(tgtLayer->GetNumInputSlots() == 2);
195 BOOST_TEST(tgtLayer->GetNumOutputSlots() == expectedDstNumOutputs);
205 BOOST_TEST(AreAllLayerInputSlotsConnected(*convLayer));
206 BOOST_TEST(AreAllLayerInputSlotsConnected(*fullyConnectedLayer));
207 BOOST_TEST(AreAllLayerInputSlotsConnected(*poolingLayer));
208 BOOST_TEST(AreAllLayerInputSlotsConnected(*activationLayer));
209 BOOST_TEST(AreAllLayerInputSlotsConnected(*normalizationLayer));
210 BOOST_TEST(AreAllLayerInputSlotsConnected(*softmaxLayer));
211 BOOST_TEST(AreAllLayerInputSlotsConnected(*batchNormalizationLayer));
212 BOOST_TEST(AreAllLayerInputSlotsConnected(*additionLayer));
213 BOOST_TEST(AreAllLayerInputSlotsConnected(*multiplicationLayer));
214 BOOST_TEST(AreAllLayerInputSlotsConnected(*outputLayer));
217 checkOneOutputToOneInputConnection(inputLayer, convLayer, 0);
218 checkOneOutputToOneInputConnection(convLayer, fullyConnectedLayer);
219 checkOneOutputToOneInputConnection(fullyConnectedLayer, poolingLayer);
220 checkOneOutputToOneInputConnection(poolingLayer, activationLayer);
221 checkOneOutputToOneInputConnection(activationLayer, normalizationLayer);
222 checkOneOutputToOneInputConnection(normalizationLayer, softmaxLayer);
223 checkOneOutputToOneInputConnection(softmaxLayer, batchNormalizationLayer);
224 checkOneOutputToTwoInputsConnections(batchNormalizationLayer, additionLayer, 1);
225 checkOneOutputToTwoInputsConnections(additionLayer, multiplicationLayer, 2);
226 checkOneOutputToOneInputConnection(multiplicationLayer, outputLayer, 2, 0);
235 BOOST_TEST(inputLayer);
241 BOOST_TEST(splitterLayer);
248 BOOST_TEST(softmaxLayer1);
254 BOOST_TEST(softmaxLayer2);
262 BOOST_TEST(concatLayer);
269 BOOST_TEST(outputLayer);
298 BOOST_TEST(splitterLayer);
305 BOOST_TEST(softmax1Layer);
311 BOOST_TEST(softmax2Layer);
342 BOOST_TEST(splitterLayer);
349 BOOST_TEST(softmax1Layer);
355 BOOST_TEST(softmax2Layer);
384 std::string expectedName = std::string(
"quantize");
385 BOOST_TEST(std::string(layer->
GetName()) == expectedName);
386 BOOST_TEST(std::string(name) == expectedName);
398 bool m_Visited =
false;
404 auto input = graph->AddInputLayer(0,
"input");
405 auto quantize = graph->AddQuantizeLayer(
"quantize");
406 auto output = graph->AddOutputLayer(1,
"output");
408 input->GetOutputSlot(0).Connect(quantize->GetInputSlot(0));
409 quantize->GetOutputSlot(0).Connect(output->GetInputSlot(0));
412 input->GetOutputSlot(0).SetTensorInfo(infoIn);
415 quantize->GetOutputSlot(0).SetTensorInfo(infoOut);
418 graph->Accept(testQuantize);
420 BOOST_TEST(testQuantize.m_Visited ==
true);
434 std::string expectedName = std::string(
"merge");
435 BOOST_TEST(std::string(layer->
GetName()) == expectedName);
436 BOOST_TEST(std::string(name) == expectedName);
451 bool m_Visited =
false;
471 network->Accept(testMerge);
473 BOOST_TEST(testMerge.m_Visited ==
true);
497 floor->GetOutputSlot(0).Connect(standIn->GetInputSlot(0));
499 standIn->GetOutputSlot(0).Connect(output->GetInputSlot(0));
504 BOOST_TEST(input->GetOutputSlot(0).GetConnection(0) == &floor->GetInputSlot(0));
505 BOOST_TEST(floor->GetOutputSlot(0).GetConnection(0) == &standIn->GetInputSlot(0));
506 BOOST_TEST(standIn->GetOutputSlot(0).GetConnection(0) == &output->GetInputSlot(0));
531 standIn->GetOutputSlot(0).Connect(output0->GetInputSlot(0));
532 standIn->GetOutputSlot(1).Connect(output1->GetInputSlot(0));
537 BOOST_TEST(input->GetOutputSlot(0).GetConnection(0) == &standIn->GetInputSlot(0));
538 BOOST_TEST(standIn->GetOutputSlot(0).GetConnection(0) == &output0->GetInputSlot(0));
539 BOOST_TEST(standIn->GetOutputSlot(1).GetConnection(0) == &output1->GetInputSlot(0));
virtual LayerGuid GetGuid() const =0
size_t GetNumLayers() const
virtual const IInputSlot & GetInputSlot(unsigned int index) const =0
IConnectableLayer * AddSplitterLayer(const ViewsDescriptor &splitterDescriptor, const char *name=nullptr) override
A NormalizationDescriptor for the NormalizationLayer.
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
virtual const TensorInfo & GetTensorInfo() const =0
uint32_t m_NumOutputs
Number of output tensors.
IConnectableLayer * AddInputLayer(LayerBindingId id, const char *name=nullptr) override
BOOST_AUTO_TEST_CASE(CheckConvolution2dLayer)
An ActivationDescriptor for the ActivationLayer.
A BatchNormalizationDescriptor for the BatchNormalizationLayer.
virtual const IInputSlot * GetConnection(unsigned int index) const =0
IConnectableLayer * AddAdditionLayer(const char *name=nullptr) override
A ViewsDescriptor for the SplitterLayer. Descriptor to configure the splitting process. Number of Views must be equal to the number of outputs, and their order must match - e.g. first view corresponds to the first output, second view to the second output, etc.
IConnectableLayer * AddPooling2dLayer(const Pooling2dDescriptor &pooling2dDescriptor, const char *name=nullptr) override
IConnectableLayer * AddStandInLayer(const StandInDescriptor &descriptor, const char *name=nullptr) override
virtual const char * GetName() const =0
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
bool GraphHasNamedLayer(const armnn::Graph &graph, const std::string &name)
IConnectableLayer * AddActivationLayer(const ActivationDescriptor &activationDescriptor, const char *name=nullptr) override
virtual IConnectableLayer * AddInputLayer(LayerBindingId id, const char *name=nullptr)=0
IConnectableLayer * AddMultiplicationLayer(const char *name=nullptr) override
Private implementation of INetwork.
virtual IConnectableLayer * AddAdditionLayer(const char *name=nullptr)=0
virtual unsigned int GetNumOutputSlots() const =0
static INetworkPtr Create()
void VisitQuantizeLayer(const IConnectableLayer *, const char *) override
A FullyConnectedDescriptor for the FullyConnectedLayer.
IConnectableLayer * AddSoftmaxLayer(const SoftmaxDescriptor &softmaxDescriptor, const char *name=nullptr) override
IConnectableLayer * AddConvolution2dLayer(const Convolution2dDescriptor &convolution2dDescriptor, const ConstTensor &weights, const Optional< ConstTensor > &biases, const char *name=nullptr) override
virtual unsigned int GetNumConnections() const =0
void VisitMergeLayer(const IConnectableLayer *, const char *) override
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
const Graph & GetGraph() const
BOOST_AUTO_TEST_SUITE_END()
uint32_t m_NumInputs
Number of input tensors.
A SoftmaxDescriptor for the SoftmaxLayer.
BOOST_AUTO_TEST_CASE(LayerGuids)
Status PrintGraph() override
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
DataType GetDataType() const
BOOST_AUTO_TEST_SUITE(TensorflowLiteParser)
A Pooling2dDescriptor for the Pooling2dLayer.
virtual unsigned int GetNumInputSlots() const =0
A StandInDescriptor for the StandIn layer.
IConnectableLayer * AddFullyConnectedLayer(const FullyConnectedDescriptor &fullyConnectedDescriptor, const ConstTensor &weights, const Optional< ConstTensor > &biases, const char *name=nullptr) override
virtual IConnectableLayer * AddActivationLayer(const ActivationDescriptor &activationDescriptor, const char *name=nullptr)=0
virtual IConnectableLayer * AddOutputLayer(LayerBindingId id, const char *name=nullptr)=0
A Convolution2dDescriptor for the Convolution2dLayer.
IConnectableLayer * AddNormalizationLayer(const NormalizationDescriptor &normalizationDescriptor, const char *name=nullptr) override
IConnectableLayer * AddOutputLayer(LayerBindingId id, const char *name=nullptr) override
virtual int Connect(IInputSlot &destination)=0
IConnectableLayer * AddFloorLayer(const char *name=nullptr) override
IConnectableLayer * AddBatchNormalizationLayer(const BatchNormalizationDescriptor &desc, const ConstTensor &mean, const ConstTensor &variance, const ConstTensor &beta, const ConstTensor &gamma, const char *name=nullptr) override
virtual const IOutputSlot & GetOutputSlot(unsigned int index) const =0
An OriginsDescriptor for the ConcatLayer. Descriptor to configure the concatenation process...
IConnectableLayer * AddConcatLayer(const ConcatDescriptor &concatDescriptor, const char *name=nullptr) override