ArmNN
 21.02
SerializerTests.cpp File Reference
#include "../Serializer.hpp"
#include "SerializerTestUtils.hpp"
#include <armnn/Descriptors.hpp>
#include <armnn/INetwork.hpp>
#include <armnn/TypesUtils.hpp>
#include <armnn/LstmParams.hpp>
#include <armnn/QuantizedLstmParams.hpp>
#include <armnnDeserializer/IDeserializer.hpp>
#include <armnn/utility/IgnoreUnused.hpp>
#include <random>
#include <vector>
#include <boost/test/unit_test.hpp>

Go to the source code of this file.

Functions

 BOOST_AUTO_TEST_CASE (SerializeAbs)
 
 BOOST_AUTO_TEST_CASE (SerializeAddition)
 
 BOOST_AUTO_TEST_CASE (SerializeArgMinMax)
 
 BOOST_AUTO_TEST_CASE (SerializeBatchNormalization)
 
 BOOST_AUTO_TEST_CASE (SerializeBatchToSpaceNd)
 
 BOOST_AUTO_TEST_CASE (SerializeComparison)
 
 BOOST_AUTO_TEST_CASE (SerializeConstant)
 
 BOOST_AUTO_TEST_CASE (SerializeConvolution2d)
 
 BOOST_AUTO_TEST_CASE (SerializeConvolution2dWithPerAxisParams)
 
 BOOST_AUTO_TEST_CASE (SerializeDepthToSpace)
 
 BOOST_AUTO_TEST_CASE (SerializeDepthwiseConvolution2d)
 
 BOOST_AUTO_TEST_CASE (SerializeDepthwiseConvolution2dWithPerAxisParams)
 
 BOOST_AUTO_TEST_CASE (SerializeDequantize)
 
 BOOST_AUTO_TEST_CASE (SerializeDeserializeDetectionPostProcess)
 
 BOOST_AUTO_TEST_CASE (SerializeDivision)
 
 BOOST_AUTO_TEST_CASE (SerializeDeserializeEqual)
 
 BOOST_AUTO_TEST_CASE (SerializeFill)
 
 BOOST_AUTO_TEST_CASE (SerializeFloor)
 
 BOOST_AUTO_TEST_CASE (SerializeFullyConnected)
 
 BOOST_AUTO_TEST_CASE (SerializeGather)
 
 BOOST_AUTO_TEST_CASE (SerializeGreaterDeprecated)
 
 BOOST_AUTO_TEST_CASE (SerializeInstanceNormalization)
 
 BOOST_AUTO_TEST_CASE (SerializeL2Normalization)
 
 BOOST_AUTO_TEST_CASE (EnsureL2NormalizationBackwardCompatibility)
 
 BOOST_AUTO_TEST_CASE (SerializeLogicalBinary)
 
 BOOST_AUTO_TEST_CASE (SerializeLogicalUnary)
 
 BOOST_AUTO_TEST_CASE (SerializeLogSoftmax)
 
 BOOST_AUTO_TEST_CASE (SerializeMaximum)
 
 BOOST_AUTO_TEST_CASE (SerializeMean)
 
 BOOST_AUTO_TEST_CASE (SerializeMerge)
 
 BOOST_AUTO_TEST_CASE (SerializeMerger)
 
 BOOST_AUTO_TEST_CASE (EnsureMergerLayerBackwardCompatibility)
 
 BOOST_AUTO_TEST_CASE (SerializeConcat)
 
 BOOST_AUTO_TEST_CASE (SerializeMinimum)
 
 BOOST_AUTO_TEST_CASE (SerializeMultiplication)
 
 BOOST_AUTO_TEST_CASE (SerializePrelu)
 
 BOOST_AUTO_TEST_CASE (SerializeNormalization)
 
 BOOST_AUTO_TEST_CASE (SerializePad)
 
 BOOST_AUTO_TEST_CASE (EnsurePadBackwardCompatibility)
 
 BOOST_AUTO_TEST_CASE (SerializePermute)
 
 BOOST_AUTO_TEST_CASE (SerializePooling2d)
 
 BOOST_AUTO_TEST_CASE (SerializeQuantize)
 
 BOOST_AUTO_TEST_CASE (SerializeRank)
 
 BOOST_AUTO_TEST_CASE (SerializeReduceSum)
 
 BOOST_AUTO_TEST_CASE (SerializeReshape)
 
 BOOST_AUTO_TEST_CASE (SerializeResize)
 
 BOOST_AUTO_TEST_CASE (SerializeResizeBilinear)
 
 BOOST_AUTO_TEST_CASE (EnsureResizeBilinearBackwardCompatibility)
 
 BOOST_AUTO_TEST_CASE (SerializeSlice)
 
 BOOST_AUTO_TEST_CASE (SerializeSoftmax)
 
 BOOST_AUTO_TEST_CASE (SerializeSpaceToBatchNd)
 
 BOOST_AUTO_TEST_CASE (SerializeSpaceToDepth)
 
 BOOST_AUTO_TEST_CASE (SerializeSplitter)
 
 BOOST_AUTO_TEST_CASE (SerializeStack)
 
 BOOST_AUTO_TEST_CASE (SerializeStandIn)
 
 BOOST_AUTO_TEST_CASE (SerializeStridedSlice)
 
 BOOST_AUTO_TEST_CASE (SerializeSubtraction)
 
 BOOST_AUTO_TEST_CASE (SerializeSwitch)
 
 BOOST_AUTO_TEST_CASE (SerializeTranspose)
 
 BOOST_AUTO_TEST_CASE (SerializeTransposeConvolution2d)
 
 BOOST_AUTO_TEST_CASE (SerializeDeserializeNonLinearNetwork)
 

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/61]

BOOST_AUTO_TEST_CASE ( SerializeAbs  )

Definition at line 26 of file SerializerTests.cpp.

References ARMNN_NO_DEPRECATE_WARN_BEGIN, ARMNN_NO_DEPRECATE_WARN_END, IOutputSlot::Connect(), INetwork::Create(), DeserializeNetwork(), LayerVerifierBase::ExecuteStrategy(), armnn::Float32, IConnectableLayer::GetOutputSlot(), SerializeNetwork(), and IOutputSlot::SetTensorInfo().

27 {
28  const std::string layerName("abs");
29  const armnn::TensorInfo tensorInfo({1, 2, 3}, armnn::DataType::Float32);
30 
32  armnn::IConnectableLayer* const inputLayer = network->AddInputLayer(0);
33 
35  armnn::IConnectableLayer* const absLayer = network->AddAbsLayer(layerName.c_str());
37  armnn::IConnectableLayer* const outputLayer = network->AddOutputLayer(0);
38 
39  inputLayer->GetOutputSlot(0).Connect(absLayer->GetInputSlot(0));
40  absLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
41 
42  inputLayer->GetOutputSlot(0).SetTensorInfo(tensorInfo);
43  absLayer->GetOutputSlot(0).SetTensorInfo(tensorInfo);
44 
45  armnn::INetworkPtr deserializedNetwork = DeserializeNetwork(SerializeNetwork(*network));
46  BOOST_CHECK(deserializedNetwork);
47 
48  LayerVerifierBase verifier(layerName, {tensorInfo}, {tensorInfo});
49  deserializedNetwork->ExecuteStrategy(verifier);
50 }
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition: INetwork.hpp:62
armnn::INetworkPtr DeserializeNetwork(const std::string &serializerString)
#define ARMNN_NO_DEPRECATE_WARN_BEGIN
Definition: Deprecated.hpp:33
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
#define ARMNN_NO_DEPRECATE_WARN_END
Definition: Deprecated.hpp:34
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:173
virtual int Connect(IInputSlot &destination)=0
std::string SerializeNetwork(const armnn::INetwork &network)
static INetworkPtr Create(NetworkOptions networkOptions={})
Definition: Network.cpp:510
void ExecuteStrategy(const armnn::IConnectableLayer *layer, const armnn::BaseDescriptor &descriptor, const std::vector< armnn::ConstTensor > &constants, const char *name, const armnn::LayerBindingId id=0) override

◆ BOOST_AUTO_TEST_CASE() [2/61]

BOOST_AUTO_TEST_CASE ( SerializeAddition  )

Definition at line 52 of file SerializerTests.cpp.

References IOutputSlot::Connect(), INetwork::Create(), DeserializeNetwork(), LayerVerifierBase::ExecuteStrategy(), armnn::Float32, IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), SerializeNetwork(), and IOutputSlot::SetTensorInfo().

53 {
54  const std::string layerName("addition");
55  const armnn::TensorInfo tensorInfo({1, 2, 3}, armnn::DataType::Float32);
56 
58  armnn::IConnectableLayer* const inputLayer0 = network->AddInputLayer(0);
59  armnn::IConnectableLayer* const inputLayer1 = network->AddInputLayer(1);
60  armnn::IConnectableLayer* const additionLayer = network->AddAdditionLayer(layerName.c_str());
61  armnn::IConnectableLayer* const outputLayer = network->AddOutputLayer(0);
62 
63  inputLayer0->GetOutputSlot(0).Connect(additionLayer->GetInputSlot(0));
64  inputLayer1->GetOutputSlot(0).Connect(additionLayer->GetInputSlot(1));
65  additionLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
66 
67  inputLayer0->GetOutputSlot(0).SetTensorInfo(tensorInfo);
68  inputLayer1->GetOutputSlot(0).SetTensorInfo(tensorInfo);
69  additionLayer->GetOutputSlot(0).SetTensorInfo(tensorInfo);
70 
71  std::string serializedNetwork = SerializeNetwork(*network);
72  armnn::INetworkPtr deserializedNetwork = DeserializeNetwork(serializedNetwork);
73  BOOST_CHECK(deserializedNetwork);
74 
75  LayerVerifierBase verifier(layerName, {tensorInfo, tensorInfo}, {tensorInfo});
76  deserializedNetwork->ExecuteStrategy(verifier);
77 }
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition: INetwork.hpp:62
armnn::INetworkPtr DeserializeNetwork(const std::string &serializerString)
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
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:173
virtual int Connect(IInputSlot &destination)=0
std::string SerializeNetwork(const armnn::INetwork &network)
static INetworkPtr Create(NetworkOptions networkOptions={})
Definition: Network.cpp:510
void ExecuteStrategy(const armnn::IConnectableLayer *layer, const armnn::BaseDescriptor &descriptor, const std::vector< armnn::ConstTensor > &constants, const char *name, const armnn::LayerBindingId id=0) override

◆ BOOST_AUTO_TEST_CASE() [3/61]

BOOST_AUTO_TEST_CASE ( SerializeArgMinMax  )

Definition at line 79 of file SerializerTests.cpp.

References IOutputSlot::Connect(), INetwork::Create(), DeserializeNetwork(), LayerVerifierBaseWithDescriptor< Descriptor >::ExecuteStrategy(), armnn::Float32, IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), ArgMinMaxDescriptor::m_Function, armnn::Max, SerializeNetwork(), IOutputSlot::SetTensorInfo(), and armnn::Signed32.

80 {
81  const std::string layerName("argminmax");
82  const armnn::TensorInfo inputInfo({1, 2, 3}, armnn::DataType::Float32);
83  const armnn::TensorInfo outputInfo({1, 3}, armnn::DataType::Signed32);
84 
85  armnn::ArgMinMaxDescriptor descriptor;
87  descriptor.m_Axis = 1;
88 
90  armnn::IConnectableLayer* const inputLayer = network->AddInputLayer(0);
91  armnn::IConnectableLayer* const argMinMaxLayer = network->AddArgMinMaxLayer(descriptor, layerName.c_str());
92  armnn::IConnectableLayer* const outputLayer = network->AddOutputLayer(0);
93 
94  inputLayer->GetOutputSlot(0).Connect(argMinMaxLayer->GetInputSlot(0));
95  argMinMaxLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
96 
97  inputLayer->GetOutputSlot(0).SetTensorInfo(inputInfo);
98  argMinMaxLayer->GetOutputSlot(0).SetTensorInfo(outputInfo);
99 
100  armnn::INetworkPtr deserializedNetwork = DeserializeNetwork(SerializeNetwork(*network));
101  BOOST_CHECK(deserializedNetwork);
102 
104  {inputInfo},
105  {outputInfo},
106  descriptor);
107  deserializedNetwork->ExecuteStrategy(verifier);
108 }
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition: INetwork.hpp:62
armnn::INetworkPtr DeserializeNetwork(const std::string &serializerString)
ArgMinMaxFunction m_Function
Specify if the function is to find Min or Max.
Definition: Descriptors.hpp:70
void ExecuteStrategy(const armnn::IConnectableLayer *layer, const armnn::BaseDescriptor &descriptor, const std::vector< armnn::ConstTensor > &constants, const char *name, const armnn::LayerBindingId id=0) override
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
An ArgMinMaxDescriptor for ArgMinMaxLayer.
Definition: Descriptors.hpp:56
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:173
virtual int Connect(IInputSlot &destination)=0
std::string SerializeNetwork(const armnn::INetwork &network)
static INetworkPtr Create(NetworkOptions networkOptions={})
Definition: Network.cpp:510

◆ BOOST_AUTO_TEST_CASE() [4/61]

BOOST_AUTO_TEST_CASE ( SerializeBatchNormalization  )

Definition at line 110 of file SerializerTests.cpp.

References IOutputSlot::Connect(), INetwork::Create(), DeserializeNetwork(), LayerVerifierBaseWithDescriptorAndConstants< Descriptor >::ExecuteStrategy(), armnn::Float32, IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), BatchNormalizationDescriptor::m_Eps, armnn::NHWC, SerializeNetwork(), and IOutputSlot::SetTensorInfo().

111 {
112  const std::string layerName("batchNormalization");
113  const armnn::TensorInfo inputInfo ({ 1, 3, 3, 1 }, armnn::DataType::Float32);
114  const armnn::TensorInfo outputInfo({ 1, 3, 3, 1 }, armnn::DataType::Float32);
115 
116  const armnn::TensorInfo meanInfo({1}, armnn::DataType::Float32);
117  const armnn::TensorInfo varianceInfo({1}, armnn::DataType::Float32);
118  const armnn::TensorInfo betaInfo({1}, armnn::DataType::Float32);
119  const armnn::TensorInfo gammaInfo({1}, armnn::DataType::Float32);
120 
122  descriptor.m_Eps = 0.0010000000475f;
123  descriptor.m_DataLayout = armnn::DataLayout::NHWC;
124 
125  std::vector<float> meanData({5.0});
126  std::vector<float> varianceData({2.0});
127  std::vector<float> betaData({1.0});
128  std::vector<float> gammaData({0.0});
129 
130  std::vector<armnn::ConstTensor> constants;
131  constants.emplace_back(armnn::ConstTensor(meanInfo, meanData));
132  constants.emplace_back(armnn::ConstTensor(varianceInfo, varianceData));
133  constants.emplace_back(armnn::ConstTensor(betaInfo, betaData));
134  constants.emplace_back(armnn::ConstTensor(gammaInfo, gammaData));
135 
137  armnn::IConnectableLayer* const inputLayer = network->AddInputLayer(0);
138  armnn::IConnectableLayer* const batchNormalizationLayer =
139  network->AddBatchNormalizationLayer(descriptor,
140  constants[0],
141  constants[1],
142  constants[2],
143  constants[3],
144  layerName.c_str());
145  armnn::IConnectableLayer* const outputLayer = network->AddOutputLayer(0);
146 
147  inputLayer->GetOutputSlot(0).Connect(batchNormalizationLayer->GetInputSlot(0));
148  batchNormalizationLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
149 
150  inputLayer->GetOutputSlot(0).SetTensorInfo(inputInfo);
151  batchNormalizationLayer->GetOutputSlot(0).SetTensorInfo(outputInfo);
152 
153  armnn::INetworkPtr deserializedNetwork = DeserializeNetwork(SerializeNetwork(*network));
154  BOOST_CHECK(deserializedNetwork);
155 
157  layerName, {inputInfo}, {outputInfo}, descriptor, constants);
158  deserializedNetwork->ExecuteStrategy(verifier);
159 }
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition: INetwork.hpp:62
armnn::INetworkPtr DeserializeNetwork(const std::string &serializerString)
float m_Eps
Value to add to the variance. Used to avoid dividing by zero.
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
void ExecuteStrategy(const armnn::IConnectableLayer *layer, const armnn::BaseDescriptor &descriptor, const std::vector< armnn::ConstTensor > &constants, const char *name, const armnn::LayerBindingId id=0) override
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
Definition: Tensor.hpp:314
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:173
virtual int Connect(IInputSlot &destination)=0
std::string SerializeNetwork(const armnn::INetwork &network)
static INetworkPtr Create(NetworkOptions networkOptions={})
Definition: Network.cpp:510
A BatchNormalizationDescriptor for the BatchNormalizationLayer.

◆ BOOST_AUTO_TEST_CASE() [5/61]

BOOST_AUTO_TEST_CASE ( SerializeBatchToSpaceNd  )

Definition at line 161 of file SerializerTests.cpp.

References IOutputSlot::Connect(), INetwork::Create(), DeserializeNetwork(), LayerVerifierBaseWithDescriptor< Descriptor >::ExecuteStrategy(), armnn::Float32, IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), BatchToSpaceNdDescriptor::m_DataLayout, armnn::NCHW, SerializeNetwork(), and IOutputSlot::SetTensorInfo().

162 {
163  const std::string layerName("spaceToBatchNd");
164  const armnn::TensorInfo inputInfo({4, 1, 2, 2}, armnn::DataType::Float32);
165  const armnn::TensorInfo outputInfo({1, 1, 4, 4}, armnn::DataType::Float32);
166 
169  desc.m_BlockShape = {2, 2};
170  desc.m_Crops = {{0, 0}, {0, 0}};
171 
173  armnn::IConnectableLayer* const inputLayer = network->AddInputLayer(0);
174  armnn::IConnectableLayer* const batchToSpaceNdLayer = network->AddBatchToSpaceNdLayer(desc, layerName.c_str());
175  armnn::IConnectableLayer* const outputLayer = network->AddOutputLayer(0);
176 
177  inputLayer->GetOutputSlot(0).Connect(batchToSpaceNdLayer->GetInputSlot(0));
178  batchToSpaceNdLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
179 
180  inputLayer->GetOutputSlot(0).SetTensorInfo(inputInfo);
181  batchToSpaceNdLayer->GetOutputSlot(0).SetTensorInfo(outputInfo);
182 
183  armnn::INetworkPtr deserializedNetwork = DeserializeNetwork(SerializeNetwork(*network));
184  BOOST_CHECK(deserializedNetwork);
185 
187  {inputInfo},
188  {outputInfo},
189  desc);
190  deserializedNetwork->ExecuteStrategy(verifier);
191 }
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition: INetwork.hpp:62
armnn::INetworkPtr DeserializeNetwork(const std::string &serializerString)
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
void ExecuteStrategy(const armnn::IConnectableLayer *layer, const armnn::BaseDescriptor &descriptor, const std::vector< armnn::ConstTensor > &constants, const char *name, const armnn::LayerBindingId id=0) override
A BatchToSpaceNdDescriptor for the BatchToSpaceNdLayer.
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
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:173
virtual int Connect(IInputSlot &destination)=0
std::string SerializeNetwork(const armnn::INetwork &network)
static INetworkPtr Create(NetworkOptions networkOptions={})
Definition: Network.cpp:510

◆ BOOST_AUTO_TEST_CASE() [6/61]

BOOST_AUTO_TEST_CASE ( SerializeComparison  )

Definition at line 193 of file SerializerTests.cpp.

References armnn::Boolean, IOutputSlot::Connect(), INetwork::Create(), DeserializeNetwork(), LayerVerifierBaseWithDescriptor< Descriptor >::ExecuteStrategy(), armnn::Float32, IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), armnn::NotEqual, SerializeNetwork(), and IOutputSlot::SetTensorInfo().

194 {
195  const std::string layerName("comparison");
196 
197  const armnn::TensorShape shape{2, 1, 2, 4};
198 
201 
203 
205  armnn::IConnectableLayer* const inputLayer0 = network->AddInputLayer(0);
206  armnn::IConnectableLayer* const inputLayer1 = network->AddInputLayer(1);
207  armnn::IConnectableLayer* const comparisonLayer = network->AddComparisonLayer(descriptor, layerName.c_str());
208  armnn::IConnectableLayer* const outputLayer = network->AddOutputLayer(0);
209 
210  inputLayer0->GetOutputSlot(0).Connect(comparisonLayer->GetInputSlot(0));
211  inputLayer1->GetOutputSlot(0).Connect(comparisonLayer->GetInputSlot(1));
212  comparisonLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
213 
214  inputLayer0->GetOutputSlot(0).SetTensorInfo(inputInfo);
215  inputLayer1->GetOutputSlot(0).SetTensorInfo(inputInfo);
216  comparisonLayer->GetOutputSlot(0).SetTensorInfo(outputInfo);
217 
218  armnn::INetworkPtr deserializedNetwork = DeserializeNetwork(SerializeNetwork(*network));
219  BOOST_CHECK(deserializedNetwork);
220 
222  { inputInfo, inputInfo },
223  { outputInfo },
224  descriptor);
225  deserializedNetwork->ExecuteStrategy(verifier);
226 }
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition: INetwork.hpp:62
armnn::INetworkPtr DeserializeNetwork(const std::string &serializerString)
A ComparisonDescriptor for the ComparisonLayer.
Definition: Descriptors.hpp:78
void ExecuteStrategy(const armnn::IConnectableLayer *layer, const armnn::BaseDescriptor &descriptor, const std::vector< armnn::ConstTensor > &constants, const char *name, const armnn::LayerBindingId id=0) override
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
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:173
virtual int Connect(IInputSlot &destination)=0
std::string SerializeNetwork(const armnn::INetwork &network)
static INetworkPtr Create(NetworkOptions networkOptions={})
Definition: Network.cpp:510

◆ BOOST_AUTO_TEST_CASE() [7/61]

BOOST_AUTO_TEST_CASE ( SerializeConstant  )

Definition at line 228 of file SerializerTests.cpp.

References armnn::Addition, CompareConstTensor(), IOutputSlot::Connect(), INetwork::Create(), DeserializeNetwork(), LayerVerifierBase::ExecuteStrategy(), armnn::Float32, IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), IConnectableLayer::GetType(), armnn::IgnoreUnused(), armnn::Input, LayerVerifierBase::LayerVerifierBase(), armnn::Output, SerializeNetwork(), IOutputSlot::SetTensorInfo(), and LayerVerifierBase::VerifyNameAndConnections().

229 {
230  class ConstantLayerVerifier : public LayerVerifierBase
231  {
232  public:
233  ConstantLayerVerifier(const std::string& layerName,
234  const std::vector<armnn::TensorInfo>& inputInfos,
235  const std::vector<armnn::TensorInfo>& outputInfos,
236  const std::vector<armnn::ConstTensor>& constants)
237  : LayerVerifierBase(layerName, inputInfos, outputInfos)
238  , m_Constants(constants) {}
239 
240  void ExecuteStrategy(const armnn::IConnectableLayer* layer,
241  const armnn::BaseDescriptor& descriptor,
242  const std::vector<armnn::ConstTensor>& constants,
243  const char* name,
244  const armnn::LayerBindingId id = 0) override
245  {
246  armnn::IgnoreUnused(descriptor, id);
247 
248  switch (layer->GetType())
249  {
250  case armnn::LayerType::Input: break;
251  case armnn::LayerType::Output: break;
252  case armnn::LayerType::Addition: break;
253  default:
254  {
255  this->VerifyNameAndConnections(layer, name);
256 
257  for (std::size_t i = 0; i < constants.size(); i++)
258  {
259  CompareConstTensor(constants[i], m_Constants[i]);
260  }
261  }
262  }
263  }
264 
265  private:
266  const std::vector<armnn::ConstTensor> m_Constants;
267  };
268 
269  const std::string layerName("constant");
271 
272  std::vector<float> constantData = GenerateRandomData<float>(info.GetNumElements());
273  armnn::ConstTensor constTensor(info, constantData);
274 
276  armnn::IConnectableLayer* input = network->AddInputLayer(0);
277  armnn::IConnectableLayer* constant = network->AddConstantLayer(constTensor, layerName.c_str());
278  armnn::IConnectableLayer* add = network->AddAdditionLayer();
279  armnn::IConnectableLayer* output = network->AddOutputLayer(0);
280 
281  input->GetOutputSlot(0).Connect(add->GetInputSlot(0));
282  constant->GetOutputSlot(0).Connect(add->GetInputSlot(1));
283  add->GetOutputSlot(0).Connect(output->GetInputSlot(0));
284 
285  input->GetOutputSlot(0).SetTensorInfo(info);
286  constant->GetOutputSlot(0).SetTensorInfo(info);
287  add->GetOutputSlot(0).SetTensorInfo(info);
288 
289  armnn::INetworkPtr deserializedNetwork = DeserializeNetwork(SerializeNetwork(*network));
290  BOOST_CHECK(deserializedNetwork);
291 
292  ConstantLayerVerifier verifier(layerName, {}, {info}, {constTensor});
293  deserializedNetwork->ExecuteStrategy(verifier);
294 }
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition: INetwork.hpp:62
armnn::INetworkPtr DeserializeNetwork(const std::string &serializerString)
void IgnoreUnused(Ts &&...)
int LayerBindingId
Type of identifiers for bindable layers (inputs, outputs).
Definition: Types.hpp:210
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
Base class for all descriptors.
Definition: Descriptors.hpp:22
void VerifyNameAndConnections(const armnn::IConnectableLayer *layer, const char *name)
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
Definition: Tensor.hpp:314
virtual LayerType GetType() const =0
Returns the armnn::LayerType of this layer.
void CompareConstTensor(const armnn::ConstTensor &tensor1, const armnn::ConstTensor &tensor2)
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:173
virtual int Connect(IInputSlot &destination)=0
std::string SerializeNetwork(const armnn::INetwork &network)
static INetworkPtr Create(NetworkOptions networkOptions={})
Definition: Network.cpp:510
void ExecuteStrategy(const armnn::IConnectableLayer *layer, const armnn::BaseDescriptor &descriptor, const std::vector< armnn::ConstTensor > &constants, const char *name, const armnn::LayerBindingId id=0) override

◆ BOOST_AUTO_TEST_CASE() [8/61]

BOOST_AUTO_TEST_CASE ( SerializeConvolution2d  )

Definition at line 296 of file SerializerTests.cpp.

References IOutputSlot::Connect(), INetwork::Create(), DeserializeNetwork(), LayerVerifierBaseWithDescriptorAndConstants< Descriptor >::ExecuteStrategy(), armnn::Float32, IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), Convolution2dDescriptor::m_BiasEnabled, Convolution2dDescriptor::m_DataLayout, Convolution2dDescriptor::m_DilationX, Convolution2dDescriptor::m_DilationY, Convolution2dDescriptor::m_PadBottom, Convolution2dDescriptor::m_PadLeft, Convolution2dDescriptor::m_PadRight, Convolution2dDescriptor::m_PadTop, Convolution2dDescriptor::m_StrideX, Convolution2dDescriptor::m_StrideY, armnn::NHWC, SerializeNetwork(), and IOutputSlot::SetTensorInfo().

297 {
298  const std::string layerName("convolution2d");
299  const armnn::TensorInfo inputInfo ({ 1, 5, 5, 1 }, armnn::DataType::Float32);
300  const armnn::TensorInfo outputInfo({ 1, 3, 3, 1 }, armnn::DataType::Float32);
301 
302  const armnn::TensorInfo weightsInfo({ 1, 3, 3, 1 }, armnn::DataType::Float32);
303  const armnn::TensorInfo biasesInfo ({ 1 }, armnn::DataType::Float32);
304 
305  std::vector<float> weightsData = GenerateRandomData<float>(weightsInfo.GetNumElements());
306  armnn::ConstTensor weights(weightsInfo, weightsData);
307 
308  std::vector<float> biasesData = GenerateRandomData<float>(biasesInfo.GetNumElements());
309  armnn::ConstTensor biases(biasesInfo, biasesData);
310 
312  descriptor.m_PadLeft = 1;
313  descriptor.m_PadRight = 1;
314  descriptor.m_PadTop = 1;
315  descriptor.m_PadBottom = 1;
316  descriptor.m_StrideX = 2;
317  descriptor.m_StrideY = 2;
318  descriptor.m_DilationX = 2;
319  descriptor.m_DilationY = 2;
320  descriptor.m_BiasEnabled = true;
322 
324  armnn::IConnectableLayer* const inputLayer = network->AddInputLayer(0);
325  armnn::IConnectableLayer* const convLayer =
326  network->AddConvolution2dLayer(descriptor,
327  weights,
329  layerName.c_str());
330  armnn::IConnectableLayer* const outputLayer = network->AddOutputLayer(0);
331 
332  inputLayer->GetOutputSlot(0).Connect(convLayer->GetInputSlot(0));
333  convLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
334 
335  inputLayer->GetOutputSlot(0).SetTensorInfo(inputInfo);
336  convLayer->GetOutputSlot(0).SetTensorInfo(outputInfo);
337 
338  armnn::INetworkPtr deserializedNetwork = DeserializeNetwork(SerializeNetwork(*network));
339  BOOST_CHECK(deserializedNetwork);
340 
341  const std::vector<armnn::ConstTensor>& constants {weights, biases};
343  layerName, {inputInfo}, {outputInfo}, descriptor, constants);
344  deserializedNetwork->ExecuteStrategy(verifier);
345 }
uint32_t m_PadBottom
Padding bottom value in the height dimension.
bool m_BiasEnabled
Enable/disable bias.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition: INetwork.hpp:62
armnn::INetworkPtr DeserializeNetwork(const std::string &serializerString)
A Convolution2dDescriptor for the Convolution2dLayer.
uint32_t m_PadRight
Padding right value in the width dimension.
uint32_t m_DilationY
Dilation along y axis.
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
uint32_t m_PadTop
Padding top value in the height dimension.
uint32_t m_StrideX
Stride value when proceeding through input for the width dimension.
void ExecuteStrategy(const armnn::IConnectableLayer *layer, const armnn::BaseDescriptor &descriptor, const std::vector< armnn::ConstTensor > &constants, const char *name, const armnn::LayerBindingId id=0) override
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
Definition: Tensor.hpp:314
uint32_t m_StrideY
Stride value when proceeding through input for the height dimension.
uint32_t m_DilationX
Dilation along x axis.
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:173
virtual int Connect(IInputSlot &destination)=0
std::string SerializeNetwork(const armnn::INetwork &network)
static INetworkPtr Create(NetworkOptions networkOptions={})
Definition: Network.cpp:510
uint32_t m_PadLeft
Padding left value in the width dimension.

◆ BOOST_AUTO_TEST_CASE() [9/61]

BOOST_AUTO_TEST_CASE ( SerializeConvolution2dWithPerAxisParams  )

Definition at line 347 of file SerializerTests.cpp.

References IOutputSlot::Connect(), INetwork::Create(), DeserializeNetwork(), LayerVerifierBaseWithDescriptorAndConstants< Descriptor >::ExecuteStrategy(), IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), Convolution2dDescriptor::m_BiasEnabled, Convolution2dDescriptor::m_DataLayout, Convolution2dDescriptor::m_PadBottom, Convolution2dDescriptor::m_PadLeft, Convolution2dDescriptor::m_PadRight, Convolution2dDescriptor::m_PadTop, Convolution2dDescriptor::m_StrideX, Convolution2dDescriptor::m_StrideY, armnn::NHWC, SerializeNetwork(), and IOutputSlot::SetTensorInfo().

348 {
349  using namespace armnn;
350 
351  const std::string layerName("convolution2dWithPerAxis");
352  const TensorInfo inputInfo ({ 1, 3, 1, 2 }, DataType::QAsymmU8, 0.55f, 128);
353  const TensorInfo outputInfo({ 1, 3, 1, 3 }, DataType::QAsymmU8, 0.75f, 128);
354 
355  const std::vector<float> quantScales{ 0.75f, 0.65f, 0.85f };
356  constexpr unsigned int quantDimension = 0;
357 
358  const TensorInfo kernelInfo({ 3, 1, 1, 2 }, DataType::QSymmS8, quantScales, quantDimension);
359 
360  const std::vector<float> biasQuantScales{ 0.25f, 0.50f, 0.75f };
361  const TensorInfo biasInfo({ 3 }, DataType::Signed32, biasQuantScales, quantDimension);
362 
363  std::vector<int8_t> kernelData = GenerateRandomData<int8_t>(kernelInfo.GetNumElements());
364  armnn::ConstTensor weights(kernelInfo, kernelData);
365  std::vector<int32_t> biasData = GenerateRandomData<int32_t>(biasInfo.GetNumElements());
366  armnn::ConstTensor biases(biasInfo, biasData);
367 
368  Convolution2dDescriptor descriptor;
369  descriptor.m_StrideX = 1;
370  descriptor.m_StrideY = 1;
371  descriptor.m_PadLeft = 0;
372  descriptor.m_PadRight = 0;
373  descriptor.m_PadTop = 0;
374  descriptor.m_PadBottom = 0;
375  descriptor.m_BiasEnabled = true;
377 
379  armnn::IConnectableLayer* const inputLayer = network->AddInputLayer(0);
380  armnn::IConnectableLayer* const convLayer =
381  network->AddConvolution2dLayer(descriptor,
382  weights,
384  layerName.c_str());
385  armnn::IConnectableLayer* const outputLayer = network->AddOutputLayer(0);
386 
387  inputLayer->GetOutputSlot(0).Connect(convLayer->GetInputSlot(0));
388  convLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
389 
390  inputLayer->GetOutputSlot(0).SetTensorInfo(inputInfo);
391  convLayer->GetOutputSlot(0).SetTensorInfo(outputInfo);
392 
393  armnn::INetworkPtr deserializedNetwork = DeserializeNetwork(SerializeNetwork(*network));
394  BOOST_CHECK(deserializedNetwork);
395 
396  const std::vector<armnn::ConstTensor>& constants {weights, biases};
398  layerName, {inputInfo}, {outputInfo}, descriptor, constants);
399  deserializedNetwork->ExecuteStrategy(verifier);
400 }
uint32_t m_PadBottom
Padding bottom value in the height dimension.
bool m_BiasEnabled
Enable/disable bias.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition: INetwork.hpp:62
armnn::INetworkPtr DeserializeNetwork(const std::string &serializerString)
A Convolution2dDescriptor for the Convolution2dLayer.
uint32_t m_PadRight
Padding right value in the width dimension.
Copyright (c) 2021 ARM Limited and Contributors.
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
uint32_t m_PadTop
Padding top value in the height dimension.
uint32_t m_StrideX
Stride value when proceeding through input for the width dimension.
void ExecuteStrategy(const armnn::IConnectableLayer *layer, const armnn::BaseDescriptor &descriptor, const std::vector< armnn::ConstTensor > &constants, const char *name, const armnn::LayerBindingId id=0) override
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
Definition: Tensor.hpp:314
uint32_t m_StrideY
Stride value when proceeding through input for the height dimension.
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:173
virtual int Connect(IInputSlot &destination)=0
std::string SerializeNetwork(const armnn::INetwork &network)
static INetworkPtr Create(NetworkOptions networkOptions={})
Definition: Network.cpp:510
uint32_t m_PadLeft
Padding left value in the width dimension.

◆ BOOST_AUTO_TEST_CASE() [10/61]

BOOST_AUTO_TEST_CASE ( SerializeDepthToSpace  )

Definition at line 402 of file SerializerTests.cpp.

References IOutputSlot::Connect(), INetwork::Create(), DeserializeNetwork(), LayerVerifierBaseWithDescriptor< Descriptor >::ExecuteStrategy(), armnn::Float32, IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), SpaceToDepthDescriptor::m_BlockSize, armnn::NHWC, SerializeNetwork(), and IOutputSlot::SetTensorInfo().

403 {
404  const std::string layerName("depthToSpace");
405 
406  const armnn::TensorInfo inputInfo ({ 1, 8, 4, 12 }, armnn::DataType::Float32);
407  const armnn::TensorInfo outputInfo({ 1, 16, 8, 3 }, armnn::DataType::Float32);
408 
410  desc.m_BlockSize = 2;
411  desc.m_DataLayout = armnn::DataLayout::NHWC;
412 
414  armnn::IConnectableLayer* const inputLayer = network->AddInputLayer(0);
415  armnn::IConnectableLayer* const depthToSpaceLayer = network->AddDepthToSpaceLayer(desc, layerName.c_str());
416  armnn::IConnectableLayer* const outputLayer = network->AddOutputLayer(0);
417 
418  inputLayer->GetOutputSlot(0).Connect(depthToSpaceLayer->GetInputSlot(0));
419  depthToSpaceLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
420 
421  inputLayer->GetOutputSlot(0).SetTensorInfo(inputInfo);
422  depthToSpaceLayer->GetOutputSlot(0).SetTensorInfo(outputInfo);
423 
424  armnn::INetworkPtr deserializedNetwork = DeserializeNetwork(SerializeNetwork(*network));
425  BOOST_CHECK(deserializedNetwork);
426 
427  LayerVerifierBaseWithDescriptor<armnn::DepthToSpaceDescriptor> verifier(layerName, {inputInfo}, {outputInfo}, desc);
428  deserializedNetwork->ExecuteStrategy(verifier);
429 }
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition: INetwork.hpp:62
armnn::INetworkPtr DeserializeNetwork(const std::string &serializerString)
void ExecuteStrategy(const armnn::IConnectableLayer *layer, const armnn::BaseDescriptor &descriptor, const std::vector< armnn::ConstTensor > &constants, const char *name, const armnn::LayerBindingId id=0) override
A SpaceToDepthDescriptor for the SpaceToDepthLayer.
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
unsigned int m_BlockSize
Scalar specifying the input block size. It must be >= 1.
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:173
virtual int Connect(IInputSlot &destination)=0
std::string SerializeNetwork(const armnn::INetwork &network)
static INetworkPtr Create(NetworkOptions networkOptions={})
Definition: Network.cpp:510

◆ BOOST_AUTO_TEST_CASE() [11/61]

BOOST_AUTO_TEST_CASE ( SerializeDepthwiseConvolution2d  )

Definition at line 431 of file SerializerTests.cpp.

References IOutputSlot::Connect(), INetwork::Create(), DeserializeNetwork(), LayerVerifierBaseWithDescriptorAndConstants< Descriptor >::ExecuteStrategy(), armnn::Float32, IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), DepthwiseConvolution2dDescriptor::m_BiasEnabled, DepthwiseConvolution2dDescriptor::m_DataLayout, DepthwiseConvolution2dDescriptor::m_DilationX, DepthwiseConvolution2dDescriptor::m_DilationY, DepthwiseConvolution2dDescriptor::m_PadBottom, DepthwiseConvolution2dDescriptor::m_PadLeft, DepthwiseConvolution2dDescriptor::m_PadRight, DepthwiseConvolution2dDescriptor::m_PadTop, DepthwiseConvolution2dDescriptor::m_StrideX, DepthwiseConvolution2dDescriptor::m_StrideY, armnn::NHWC, SerializeNetwork(), and IOutputSlot::SetTensorInfo().

432 {
433  const std::string layerName("depwiseConvolution2d");
434  const armnn::TensorInfo inputInfo ({ 1, 5, 5, 3 }, armnn::DataType::Float32);
435  const armnn::TensorInfo outputInfo({ 1, 3, 3, 3 }, armnn::DataType::Float32);
436 
437  const armnn::TensorInfo weightsInfo({ 1, 3, 3, 3 }, armnn::DataType::Float32);
438  const armnn::TensorInfo biasesInfo ({ 3 }, armnn::DataType::Float32);
439 
440  std::vector<float> weightsData = GenerateRandomData<float>(weightsInfo.GetNumElements());
441  armnn::ConstTensor weights(weightsInfo, weightsData);
442 
443  std::vector<int32_t> biasesData = GenerateRandomData<int32_t>(biasesInfo.GetNumElements());
444  armnn::ConstTensor biases(biasesInfo, biasesData);
445 
447  descriptor.m_PadLeft = 1;
448  descriptor.m_PadRight = 1;
449  descriptor.m_PadTop = 1;
450  descriptor.m_PadBottom = 1;
451  descriptor.m_StrideX = 2;
452  descriptor.m_StrideY = 2;
453  descriptor.m_DilationX = 2;
454  descriptor.m_DilationY = 2;
455  descriptor.m_BiasEnabled = true;
457 
459  armnn::IConnectableLayer* const inputLayer = network->AddInputLayer(0);
460  armnn::IConnectableLayer* const depthwiseConvLayer =
461  network->AddDepthwiseConvolution2dLayer(descriptor,
462  weights,
464  layerName.c_str());
465  armnn::IConnectableLayer* const outputLayer = network->AddOutputLayer(0);
466 
467  inputLayer->GetOutputSlot(0).Connect(depthwiseConvLayer->GetInputSlot(0));
468  depthwiseConvLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
469 
470  inputLayer->GetOutputSlot(0).SetTensorInfo(inputInfo);
471  depthwiseConvLayer->GetOutputSlot(0).SetTensorInfo(outputInfo);
472 
473  armnn::INetworkPtr deserializedNetwork = DeserializeNetwork(SerializeNetwork(*network));
474  BOOST_CHECK(deserializedNetwork);
475 
476  const std::vector<armnn::ConstTensor>& constants {weights, biases};
478  layerName, {inputInfo}, {outputInfo}, descriptor, constants);
479  deserializedNetwork->ExecuteStrategy(verifier);
480 }
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition: INetwork.hpp:62
bool m_BiasEnabled
Enable/disable bias.
uint32_t m_PadBottom
Padding bottom value in the height dimension.
armnn::INetworkPtr DeserializeNetwork(const std::string &serializerString)
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
uint32_t m_PadLeft
Padding left value in the width dimension.
uint32_t m_DilationY
Dilation factor value for height dimension.
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
uint32_t m_StrideX
Stride value when proceeding through input for the width dimension.
uint32_t m_DilationX
Dilation factor value for width dimension.
uint32_t m_PadTop
Padding top value in the height dimension.
void ExecuteStrategy(const armnn::IConnectableLayer *layer, const armnn::BaseDescriptor &descriptor, const std::vector< armnn::ConstTensor > &constants, const char *name, const armnn::LayerBindingId id=0) override
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
Definition: Tensor.hpp:314
uint32_t m_StrideY
Stride value when proceeding through input for the height dimension.
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:173
virtual int Connect(IInputSlot &destination)=0
std::string SerializeNetwork(const armnn::INetwork &network)
static INetworkPtr Create(NetworkOptions networkOptions={})
Definition: Network.cpp:510
A DepthwiseConvolution2dDescriptor for the DepthwiseConvolution2dLayer.
uint32_t m_PadRight
Padding right value in the width dimension.

◆ BOOST_AUTO_TEST_CASE() [12/61]

BOOST_AUTO_TEST_CASE ( SerializeDepthwiseConvolution2dWithPerAxisParams  )

Definition at line 482 of file SerializerTests.cpp.

References IOutputSlot::Connect(), INetwork::Create(), DeserializeNetwork(), LayerVerifierBaseWithDescriptorAndConstants< Descriptor >::ExecuteStrategy(), IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), DepthwiseConvolution2dDescriptor::m_BiasEnabled, DepthwiseConvolution2dDescriptor::m_DataLayout, DepthwiseConvolution2dDescriptor::m_DilationX, DepthwiseConvolution2dDescriptor::m_DilationY, DepthwiseConvolution2dDescriptor::m_PadBottom, DepthwiseConvolution2dDescriptor::m_PadLeft, DepthwiseConvolution2dDescriptor::m_PadRight, DepthwiseConvolution2dDescriptor::m_PadTop, DepthwiseConvolution2dDescriptor::m_StrideX, DepthwiseConvolution2dDescriptor::m_StrideY, armnn::NHWC, SerializeNetwork(), and IOutputSlot::SetTensorInfo().

483 {
484  using namespace armnn;
485 
486  const std::string layerName("depwiseConvolution2dWithPerAxis");
487  const TensorInfo inputInfo ({ 1, 3, 3, 2 }, DataType::QAsymmU8, 0.55f, 128);
488  const TensorInfo outputInfo({ 1, 2, 2, 4 }, DataType::QAsymmU8, 0.75f, 128);
489 
490  const std::vector<float> quantScales{ 0.75f, 0.80f, 0.90f, 0.95f };
491  const unsigned int quantDimension = 0;
492  TensorInfo kernelInfo({ 2, 2, 2, 2 }, DataType::QSymmS8, quantScales, quantDimension);
493 
494  const std::vector<float> biasQuantScales{ 0.25f, 0.35f, 0.45f, 0.55f };
495  constexpr unsigned int biasQuantDimension = 0;
496  TensorInfo biasInfo({ 4 }, DataType::Signed32, biasQuantScales, biasQuantDimension);
497 
498  std::vector<int8_t> kernelData = GenerateRandomData<int8_t>(kernelInfo.GetNumElements());
499  armnn::ConstTensor weights(kernelInfo, kernelData);
500  std::vector<int32_t> biasData = GenerateRandomData<int32_t>(biasInfo.GetNumElements());
501  armnn::ConstTensor biases(biasInfo, biasData);
502 
504  descriptor.m_StrideX = 1;
505  descriptor.m_StrideY = 1;
506  descriptor.m_PadLeft = 0;
507  descriptor.m_PadRight = 0;
508  descriptor.m_PadTop = 0;
509  descriptor.m_PadBottom = 0;
510  descriptor.m_DilationX = 1;
511  descriptor.m_DilationY = 1;
512  descriptor.m_BiasEnabled = true;
514 
516  armnn::IConnectableLayer* const inputLayer = network->AddInputLayer(0);
517  armnn::IConnectableLayer* const depthwiseConvLayer =
518  network->AddDepthwiseConvolution2dLayer(descriptor,
519  weights,
521  layerName.c_str());
522  armnn::IConnectableLayer* const outputLayer = network->AddOutputLayer(0);
523 
524  inputLayer->GetOutputSlot(0).Connect(depthwiseConvLayer->GetInputSlot(0));
525  depthwiseConvLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
526 
527  inputLayer->GetOutputSlot(0).SetTensorInfo(inputInfo);
528  depthwiseConvLayer->GetOutputSlot(0).SetTensorInfo(outputInfo);
529 
530  armnn::INetworkPtr deserializedNetwork = DeserializeNetwork(SerializeNetwork(*network));
531  BOOST_CHECK(deserializedNetwork);
532 
533  const std::vector<armnn::ConstTensor>& constants {weights, biases};
535  layerName, {inputInfo}, {outputInfo}, descriptor, constants);
536  deserializedNetwork->ExecuteStrategy(verifier);
537 }
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition: INetwork.hpp:62
bool m_BiasEnabled
Enable/disable bias.
uint32_t m_PadBottom
Padding bottom value in the height dimension.
armnn::INetworkPtr DeserializeNetwork(const std::string &serializerString)
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
uint32_t m_PadLeft
Padding left value in the width dimension.
Copyright (c) 2021 ARM Limited and Contributors.
uint32_t m_DilationY
Dilation factor value for height dimension.
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
uint32_t m_StrideX
Stride value when proceeding through input for the width dimension.
uint32_t m_DilationX
Dilation factor value for width dimension.
uint32_t m_PadTop
Padding top value in the height dimension.
void ExecuteStrategy(const armnn::IConnectableLayer *layer, const armnn::BaseDescriptor &descriptor, const std::vector< armnn::ConstTensor > &constants, const char *name, const armnn::LayerBindingId id=0) override
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
Definition: Tensor.hpp:314
uint32_t m_StrideY
Stride value when proceeding through input for the height dimension.
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:173
virtual int Connect(IInputSlot &destination)=0
std::string SerializeNetwork(const armnn::INetwork &network)
static INetworkPtr Create(NetworkOptions networkOptions={})
Definition: Network.cpp:510
A DepthwiseConvolution2dDescriptor for the DepthwiseConvolution2dLayer.
uint32_t m_PadRight
Padding right value in the width dimension.

◆ BOOST_AUTO_TEST_CASE() [13/61]

BOOST_AUTO_TEST_CASE ( SerializeDequantize  )

Definition at line 539 of file SerializerTests.cpp.

References IOutputSlot::Connect(), INetwork::Create(), DeserializeNetwork(), LayerVerifierBase::ExecuteStrategy(), armnn::Float32, IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), armnn::QAsymmU8, SerializeNetwork(), and IOutputSlot::SetTensorInfo().

540 {
541  const std::string layerName("dequantize");
542  const armnn::TensorInfo inputInfo({ 1, 5, 2, 3 }, armnn::DataType::QAsymmU8, 0.5f, 1);
543  const armnn::TensorInfo outputInfo({ 1, 5, 2, 3 }, armnn::DataType::Float32);
544 
546  armnn::IConnectableLayer* const inputLayer = network->AddInputLayer(0);
547  armnn::IConnectableLayer* const dequantizeLayer = network->AddDequantizeLayer(layerName.c_str());
548  armnn::IConnectableLayer* const outputLayer = network->AddOutputLayer(0);
549 
550  inputLayer->GetOutputSlot(0).Connect(dequantizeLayer->GetInputSlot(0));
551  dequantizeLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
552 
553  inputLayer->GetOutputSlot(0).SetTensorInfo(inputInfo);
554  dequantizeLayer->GetOutputSlot(0).SetTensorInfo(outputInfo);
555 
556  armnn::INetworkPtr deserializedNetwork = DeserializeNetwork(SerializeNetwork(*network));
557  BOOST_CHECK(deserializedNetwork);
558 
559  LayerVerifierBase verifier(layerName, {inputInfo}, {outputInfo});
560  deserializedNetwork->ExecuteStrategy(verifier);
561 }
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition: INetwork.hpp:62
armnn::INetworkPtr DeserializeNetwork(const std::string &serializerString)
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
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:173
virtual int Connect(IInputSlot &destination)=0
std::string SerializeNetwork(const armnn::INetwork &network)
static INetworkPtr Create(NetworkOptions networkOptions={})
Definition: Network.cpp:510
void ExecuteStrategy(const armnn::IConnectableLayer *layer, const armnn::BaseDescriptor &descriptor, const std::vector< armnn::ConstTensor > &constants, const char *name, const armnn::LayerBindingId id=0) override

◆ BOOST_AUTO_TEST_CASE() [14/61]

BOOST_AUTO_TEST_CASE ( SerializeDeserializeDetectionPostProcess  )

Definition at line 563 of file SerializerTests.cpp.

References anchors(), anchorsInfo, IOutputSlot::Connect(), INetwork::Create(), DeserializeNetwork(), armnn::Float32, IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), DetectionPostProcessDescriptor::m_DetectionsPerClass, DetectionPostProcessDescriptor::m_MaxClassesPerDetection, DetectionPostProcessDescriptor::m_MaxDetections, DetectionPostProcessDescriptor::m_NmsIouThreshold, DetectionPostProcessDescriptor::m_NmsScoreThreshold, DetectionPostProcessDescriptor::m_NumClasses, DetectionPostProcessDescriptor::m_ScaleH, DetectionPostProcessDescriptor::m_ScaleW, DetectionPostProcessDescriptor::m_ScaleX, DetectionPostProcessDescriptor::m_ScaleY, DetectionPostProcessDescriptor::m_UseRegularNms, SerializeNetwork(), and IOutputSlot::SetTensorInfo().

564 {
565  const std::string layerName("detectionPostProcess");
566 
567  const std::vector<armnn::TensorInfo> inputInfos({
570  });
571 
572  const std::vector<armnn::TensorInfo> outputInfos({
577  });
578 
580  descriptor.m_UseRegularNms = true;
581  descriptor.m_MaxDetections = 3;
582  descriptor.m_MaxClassesPerDetection = 1;
583  descriptor.m_DetectionsPerClass =1;
584  descriptor.m_NmsScoreThreshold = 0.0;
585  descriptor.m_NmsIouThreshold = 0.5;
586  descriptor.m_NumClasses = 2;
587  descriptor.m_ScaleY = 10.0;
588  descriptor.m_ScaleX = 10.0;
589  descriptor.m_ScaleH = 5.0;
590  descriptor.m_ScaleW = 5.0;
591 
593  const std::vector<float> anchorsData({
594  0.5f, 0.5f, 1.0f, 1.0f,
595  0.5f, 0.5f, 1.0f, 1.0f,
596  0.5f, 0.5f, 1.0f, 1.0f,
597  0.5f, 10.5f, 1.0f, 1.0f,
598  0.5f, 10.5f, 1.0f, 1.0f,
599  0.5f, 100.5f, 1.0f, 1.0f
600  });
601  armnn::ConstTensor anchors(anchorsInfo, anchorsData);
602 
604  armnn::IConnectableLayer* const detectionLayer =
605  network->AddDetectionPostProcessLayer(descriptor, anchors, layerName.c_str());
606 
607  for (unsigned int i = 0; i < 2; i++)
608  {
609  armnn::IConnectableLayer* const inputLayer = network->AddInputLayer(static_cast<int>(i));
610  inputLayer->GetOutputSlot(0).Connect(detectionLayer->GetInputSlot(i));
611  inputLayer->GetOutputSlot(0).SetTensorInfo(inputInfos[i]);
612  }
613 
614  for (unsigned int i = 0; i < 4; i++)
615  {
616  armnn::IConnectableLayer* const outputLayer = network->AddOutputLayer(static_cast<int>(i));
617  detectionLayer->GetOutputSlot(i).Connect(outputLayer->GetInputSlot(0));
618  detectionLayer->GetOutputSlot(i).SetTensorInfo(outputInfos[i]);
619  }
620 
621  armnn::INetworkPtr deserializedNetwork = DeserializeNetwork(SerializeNetwork(*network));
622  BOOST_CHECK(deserializedNetwork);
623 
624  const std::vector<armnn::ConstTensor>& constants {anchors};
626  layerName, inputInfos, outputInfos, descriptor, constants);
627  deserializedNetwork->ExecuteStrategy(verifier);
628 }
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition: INetwork.hpp:62
float m_ScaleW
Center size encoding scale weight.
armnn::INetworkPtr DeserializeNetwork(const std::string &serializerString)
float m_ScaleX
Center size encoding scale x.
uint32_t m_DetectionsPerClass
Detections per classes, used in Regular NMS.
armnn::TensorInfo anchorsInfo({ 6, 4 }, armnn::DataType::Float32)
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
uint32_t m_MaxClassesPerDetection
Maximum numbers of classes per detection, used in Fast NMS.
uint32_t m_MaxDetections
Maximum numbers of detections.
float m_NmsIouThreshold
Intersection over union threshold.
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
Definition: Tensor.hpp:314
uint32_t m_NumClasses
Number of classes.
bool m_UseRegularNms
Use Regular NMS.
float m_ScaleH
Center size encoding scale height.
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.
float m_ScaleY
Center size encoding scale y.
float m_NmsScoreThreshold
NMS score threshold.
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:173
virtual int Connect(IInputSlot &destination)=0
std::string SerializeNetwork(const armnn::INetwork &network)
static INetworkPtr Create(NetworkOptions networkOptions={})
Definition: Network.cpp:510
std::vector< float > anchors({ 0.5f, 0.5f, 1.0f, 1.0f, 0.5f, 0.5f, 1.0f, 1.0f, 0.5f, 0.5f, 1.0f, 1.0f, 0.5f, 10.5f, 1.0f, 1.0f, 0.5f, 10.5f, 1.0f, 1.0f, 0.5f, 100.5f, 1.0f, 1.0f })

◆ BOOST_AUTO_TEST_CASE() [15/61]

BOOST_AUTO_TEST_CASE ( SerializeDivision  )

Definition at line 630 of file SerializerTests.cpp.

References IOutputSlot::Connect(), INetwork::Create(), DeserializeNetwork(), LayerVerifierBase::ExecuteStrategy(), armnn::Float32, IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), armnn::info, SerializeNetwork(), and IOutputSlot::SetTensorInfo().

631 {
632  const std::string layerName("division");
633  const armnn::TensorInfo info({ 1, 5, 2, 3 }, armnn::DataType::Float32);
634 
636  armnn::IConnectableLayer* const inputLayer0 = network->AddInputLayer(0);
637  armnn::IConnectableLayer* const inputLayer1 = network->AddInputLayer(1);
638  armnn::IConnectableLayer* const divisionLayer = network->AddDivisionLayer(layerName.c_str());
639  armnn::IConnectableLayer* const outputLayer = network->AddOutputLayer(0);
640 
641  inputLayer0->GetOutputSlot(0).Connect(divisionLayer->GetInputSlot(0));
642  inputLayer1->GetOutputSlot(0).Connect(divisionLayer->GetInputSlot(1));
643  divisionLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
644 
645  inputLayer0->GetOutputSlot(0).SetTensorInfo(info);
646  inputLayer1->GetOutputSlot(0).SetTensorInfo(info);
647  divisionLayer->GetOutputSlot(0).SetTensorInfo(info);
648 
649  armnn::INetworkPtr deserializedNetwork = DeserializeNetwork(SerializeNetwork(*network));
650  BOOST_CHECK(deserializedNetwork);
651 
652  LayerVerifierBase verifier(layerName, {info, info}, {info});
653  deserializedNetwork->ExecuteStrategy(verifier);
654 }
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition: INetwork.hpp:62
armnn::INetworkPtr DeserializeNetwork(const std::string &serializerString)
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
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:173
virtual int Connect(IInputSlot &destination)=0
std::string SerializeNetwork(const armnn::INetwork &network)
static INetworkPtr Create(NetworkOptions networkOptions={})
Definition: Network.cpp:510
void ExecuteStrategy(const armnn::IConnectableLayer *layer, const armnn::BaseDescriptor &descriptor, const std::vector< armnn::ConstTensor > &constants, const char *name, const armnn::LayerBindingId id=0) override

◆ BOOST_AUTO_TEST_CASE() [16/61]

BOOST_AUTO_TEST_CASE ( SerializeDeserializeEqual  )

Definition at line 656 of file SerializerTests.cpp.

References ARMNN_NO_DEPRECATE_WARN_BEGIN, ARMNN_NO_DEPRECATE_WARN_END, armnn::Boolean, IOutputSlot::Connect(), INetwork::Create(), DeserializeNetwork(), LayerVerifierBase::ExecuteStrategy(), armnn::Float32, IConnectableLayer::GetOutputSlot(), SerializeNetwork(), and IOutputSlot::SetTensorInfo().

657 {
658  const std::string layerName("EqualLayer");
659  const armnn::TensorInfo inputTensorInfo1 = armnn::TensorInfo({2, 1, 2, 4}, armnn::DataType::Float32);
660  const armnn::TensorInfo inputTensorInfo2 = armnn::TensorInfo({2, 1, 2, 4}, armnn::DataType::Float32);
661  const armnn::TensorInfo outputTensorInfo = armnn::TensorInfo({2, 1, 2, 4}, armnn::DataType::Boolean);
662 
664  armnn::IConnectableLayer* const inputLayer1 = network->AddInputLayer(0);
665  armnn::IConnectableLayer* const inputLayer2 = network->AddInputLayer(1);
667  armnn::IConnectableLayer* const equalLayer = network->AddEqualLayer(layerName.c_str());
669  armnn::IConnectableLayer* const outputLayer = network->AddOutputLayer(0);
670 
671  inputLayer1->GetOutputSlot(0).Connect(equalLayer->GetInputSlot(0));
672  inputLayer1->GetOutputSlot(0).SetTensorInfo(inputTensorInfo1);
673  inputLayer2->GetOutputSlot(0).Connect(equalLayer->GetInputSlot(1));
674  inputLayer2->GetOutputSlot(0).SetTensorInfo(inputTensorInfo2);
675  equalLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
676  equalLayer->GetOutputSlot(0).SetTensorInfo(outputTensorInfo);
677 
678  armnn::INetworkPtr deserializedNetwork = DeserializeNetwork(SerializeNetwork(*network));
679  BOOST_CHECK(deserializedNetwork);
680 
681  LayerVerifierBase verifier(layerName, {inputTensorInfo1, inputTensorInfo2}, {outputTensorInfo});
682  deserializedNetwork->ExecuteStrategy(verifier);
683 }
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition: INetwork.hpp:62
armnn::INetworkPtr DeserializeNetwork(const std::string &serializerString)
#define ARMNN_NO_DEPRECATE_WARN_BEGIN
Definition: Deprecated.hpp:33
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
#define ARMNN_NO_DEPRECATE_WARN_END
Definition: Deprecated.hpp:34
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:173
virtual int Connect(IInputSlot &destination)=0
std::string SerializeNetwork(const armnn::INetwork &network)
static INetworkPtr Create(NetworkOptions networkOptions={})
Definition: Network.cpp:510
void ExecuteStrategy(const armnn::IConnectableLayer *layer, const armnn::BaseDescriptor &descriptor, const std::vector< armnn::ConstTensor > &constants, const char *name, const armnn::LayerBindingId id=0) override

◆ BOOST_AUTO_TEST_CASE() [17/61]

BOOST_AUTO_TEST_CASE ( SerializeFill  )

Definition at line 685 of file SerializerTests.cpp.

References IOutputSlot::Connect(), INetwork::Create(), DeserializeNetwork(), LayerVerifierBaseWithDescriptor< Descriptor >::ExecuteStrategy(), armnn::Float32, IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), SerializeNetwork(), IOutputSlot::SetTensorInfo(), and armnn::Signed32.

686 {
687  const std::string layerName("fill");
688  const armnn::TensorInfo inputInfo({4}, armnn::DataType::Signed32);
689  const armnn::TensorInfo outputInfo({1, 3, 3, 1}, armnn::DataType::Float32);
690 
691  armnn::FillDescriptor descriptor(1.0f);
692 
694  armnn::IConnectableLayer* const inputLayer = network->AddInputLayer(0);
695  armnn::IConnectableLayer* const fillLayer = network->AddFillLayer(descriptor, layerName.c_str());
696  armnn::IConnectableLayer* const outputLayer = network->AddOutputLayer(0);
697 
698  inputLayer->GetOutputSlot(0).Connect(fillLayer->GetInputSlot(0));
699  fillLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
700 
701  inputLayer->GetOutputSlot(0).SetTensorInfo(inputInfo);
702  fillLayer->GetOutputSlot(0).SetTensorInfo(outputInfo);
703 
704  armnn::INetworkPtr deserializedNetwork = DeserializeNetwork(SerializeNetwork(*network));
705  BOOST_CHECK(deserializedNetwork);
706 
707  LayerVerifierBaseWithDescriptor<armnn::FillDescriptor> verifier(layerName, {inputInfo}, {outputInfo}, descriptor);
708 
709  deserializedNetwork->ExecuteStrategy(verifier);
710 }
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition: INetwork.hpp:62
armnn::INetworkPtr DeserializeNetwork(const std::string &serializerString)
void ExecuteStrategy(const armnn::IConnectableLayer *layer, const armnn::BaseDescriptor &descriptor, const std::vector< armnn::ConstTensor > &constants, const char *name, const armnn::LayerBindingId id=0) override
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
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:173
virtual int Connect(IInputSlot &destination)=0
std::string SerializeNetwork(const armnn::INetwork &network)
static INetworkPtr Create(NetworkOptions networkOptions={})
Definition: Network.cpp:510
A FillDescriptor for the FillLayer.

◆ BOOST_AUTO_TEST_CASE() [18/61]

BOOST_AUTO_TEST_CASE ( SerializeFloor  )

Definition at line 712 of file SerializerTests.cpp.

References IOutputSlot::Connect(), INetwork::Create(), DeserializeNetwork(), LayerVerifierBase::ExecuteStrategy(), armnn::Float32, IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), armnn::info, SerializeNetwork(), and IOutputSlot::SetTensorInfo().

713 {
714  const std::string layerName("floor");
716 
718  armnn::IConnectableLayer* const inputLayer = network->AddInputLayer(0);
719  armnn::IConnectableLayer* const floorLayer = network->AddFloorLayer(layerName.c_str());
720  armnn::IConnectableLayer* const outputLayer = network->AddOutputLayer(0);
721 
722  inputLayer->GetOutputSlot(0).Connect(floorLayer->GetInputSlot(0));
723  floorLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
724 
725  inputLayer->GetOutputSlot(0).SetTensorInfo(info);
726  floorLayer->GetOutputSlot(0).SetTensorInfo(info);
727 
728  armnn::INetworkPtr deserializedNetwork = DeserializeNetwork(SerializeNetwork(*network));
729  BOOST_CHECK(deserializedNetwork);
730 
731  LayerVerifierBase verifier(layerName, {info}, {info});
732  deserializedNetwork->ExecuteStrategy(verifier);
733 }
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition: INetwork.hpp:62
armnn::INetworkPtr DeserializeNetwork(const std::string &serializerString)
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
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:173
virtual int Connect(IInputSlot &destination)=0
std::string SerializeNetwork(const armnn::INetwork &network)
static INetworkPtr Create(NetworkOptions networkOptions={})
Definition: Network.cpp:510
void ExecuteStrategy(const armnn::IConnectableLayer *layer, const armnn::BaseDescriptor &descriptor, const std::vector< armnn::ConstTensor > &constants, const char *name, const armnn::LayerBindingId id=0) override

◆ BOOST_AUTO_TEST_CASE() [19/61]

BOOST_AUTO_TEST_CASE ( SerializeFullyConnected  )

Definition at line 735 of file SerializerTests.cpp.

References IOutputSlot::Connect(), INetwork::Create(), DeserializeNetwork(), LayerVerifierBaseWithDescriptorAndConstants< Descriptor >::ExecuteStrategy(), armnn::Float32, IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), FullyConnectedDescriptor::m_BiasEnabled, FullyConnectedDescriptor::m_TransposeWeightMatrix, SerializeNetwork(), and IOutputSlot::SetTensorInfo().

736 {
737  const std::string layerName("fullyConnected");
738  const armnn::TensorInfo inputInfo ({ 2, 5, 1, 1 }, armnn::DataType::Float32);
739  const armnn::TensorInfo outputInfo({ 2, 3 }, armnn::DataType::Float32);
740 
741  const armnn::TensorInfo weightsInfo({ 5, 3 }, armnn::DataType::Float32);
742  const armnn::TensorInfo biasesInfo ({ 3 }, armnn::DataType::Float32);
743  std::vector<float> weightsData = GenerateRandomData<float>(weightsInfo.GetNumElements());
744  std::vector<float> biasesData = GenerateRandomData<float>(biasesInfo.GetNumElements());
745  armnn::ConstTensor weights(weightsInfo, weightsData);
746  armnn::ConstTensor biases(biasesInfo, biasesData);
747 
749  descriptor.m_BiasEnabled = true;
750  descriptor.m_TransposeWeightMatrix = false;
751 
753  armnn::IConnectableLayer* const inputLayer = network->AddInputLayer(0);
754  armnn::IConnectableLayer* const fullyConnectedLayer =
755  network->AddFullyConnectedLayer(descriptor,
756  weights,
758  layerName.c_str());
759  armnn::IConnectableLayer* const outputLayer = network->AddOutputLayer(0);
760 
761  inputLayer->GetOutputSlot(0).Connect(fullyConnectedLayer->GetInputSlot(0));
762  fullyConnectedLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
763 
764  inputLayer->GetOutputSlot(0).SetTensorInfo(inputInfo);
765  fullyConnectedLayer->GetOutputSlot(0).SetTensorInfo(outputInfo);
766 
767  armnn::INetworkPtr deserializedNetwork = DeserializeNetwork(SerializeNetwork(*network));
768  BOOST_CHECK(deserializedNetwork);
769 
770  const std::vector<armnn::ConstTensor> constants {weights, biases};
772  layerName, {inputInfo}, {outputInfo}, descriptor, constants);
773  deserializedNetwork->ExecuteStrategy(verifier);
774 }
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition: INetwork.hpp:62
armnn::INetworkPtr DeserializeNetwork(const std::string &serializerString)
bool m_TransposeWeightMatrix
Enable/disable transpose weight matrix.
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
void ExecuteStrategy(const armnn::IConnectableLayer *layer, const armnn::BaseDescriptor &descriptor, const std::vector< armnn::ConstTensor > &constants, const char *name, const armnn::LayerBindingId id=0) override
A FullyConnectedDescriptor for the FullyConnectedLayer.
bool m_BiasEnabled
Enable/disable bias.
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
Definition: Tensor.hpp:314
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:173
virtual int Connect(IInputSlot &destination)=0
std::string SerializeNetwork(const armnn::INetwork &network)
static INetworkPtr Create(NetworkOptions networkOptions={})
Definition: Network.cpp:510

◆ BOOST_AUTO_TEST_CASE() [20/61]

BOOST_AUTO_TEST_CASE ( SerializeGather  )

Definition at line 776 of file SerializerTests.cpp.

References IOutputSlot::Connect(), armnn::Constant, INetwork::Create(), DeserializeNetwork(), IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), IConnectableLayer::GetType(), armnn::IgnoreUnused(), armnn::Input, GatherDescriptor::m_Axis, armnn::Output, armnn::QAsymmU8, SerializeNetwork(), IOutputSlot::SetTensorInfo(), and armnn::Signed32.

777 {
779  class GatherLayerVerifier : public LayerVerifierBaseWithDescriptor<GatherDescriptor>
780  {
781  public:
782  GatherLayerVerifier(const std::string& layerName,
783  const std::vector<armnn::TensorInfo>& inputInfos,
784  const std::vector<armnn::TensorInfo>& outputInfos,
785  const GatherDescriptor& descriptor)
786  : LayerVerifierBaseWithDescriptor<GatherDescriptor>(layerName, inputInfos, outputInfos, descriptor) {}
787 
788  void ExecuteStrategy(const armnn::IConnectableLayer* layer,
789  const armnn::BaseDescriptor& descriptor,
790  const std::vector<armnn::ConstTensor>& constants,
791  const char* name,
792  const armnn::LayerBindingId id = 0) override
793  {
794  armnn::IgnoreUnused(constants, id);
795  switch (layer->GetType())
796  {
797  case armnn::LayerType::Input: break;
798  case armnn::LayerType::Output: break;
799  case armnn::LayerType::Constant: break;
800  default:
801  {
802  VerifyNameAndConnections(layer, name);
803  const GatherDescriptor& layerDescriptor = static_cast<const GatherDescriptor&>(descriptor);
804  BOOST_CHECK(layerDescriptor.m_Axis == m_Descriptor.m_Axis);
805  }
806  }
807  }
808  };
809 
810  const std::string layerName("gather");
811  armnn::TensorInfo paramsInfo({ 8 }, armnn::DataType::QAsymmU8);
812  armnn::TensorInfo outputInfo({ 3 }, armnn::DataType::QAsymmU8);
813  const armnn::TensorInfo indicesInfo({ 3 }, armnn::DataType::Signed32);
814  GatherDescriptor descriptor;
815  descriptor.m_Axis = 1;
816 
817  paramsInfo.SetQuantizationScale(1.0f);
818  paramsInfo.SetQuantizationOffset(0);
819  outputInfo.SetQuantizationScale(1.0f);
820  outputInfo.SetQuantizationOffset(0);
821 
822  const std::vector<int32_t>& indicesData = {7, 6, 5};
823 
825  armnn::IConnectableLayer *const inputLayer = network->AddInputLayer(0);
826  armnn::IConnectableLayer *const constantLayer =
827  network->AddConstantLayer(armnn::ConstTensor(indicesInfo, indicesData));
828  armnn::IConnectableLayer *const gatherLayer = network->AddGatherLayer(descriptor, layerName.c_str());
829  armnn::IConnectableLayer *const outputLayer = network->AddOutputLayer(0);
830 
831  inputLayer->GetOutputSlot(0).Connect(gatherLayer->GetInputSlot(0));
832  constantLayer->GetOutputSlot(0).Connect(gatherLayer->GetInputSlot(1));
833  gatherLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
834 
835  inputLayer->GetOutputSlot(0).SetTensorInfo(paramsInfo);
836  constantLayer->GetOutputSlot(0).SetTensorInfo(indicesInfo);
837  gatherLayer->GetOutputSlot(0).SetTensorInfo(outputInfo);
838 
839  armnn::INetworkPtr deserializedNetwork = DeserializeNetwork(SerializeNetwork(*network));
840  BOOST_CHECK(deserializedNetwork);
841 
842  GatherLayerVerifier verifier(layerName, {paramsInfo, indicesInfo}, {outputInfo}, descriptor);
843  deserializedNetwork->ExecuteStrategy(verifier);
844 }
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition: INetwork.hpp:62
armnn::INetworkPtr DeserializeNetwork(const std::string &serializerString)
void ExecuteStrategy(const armnn::IConnectableLayer *layer, const armnn::BaseDescriptor &descriptor, const std::vector< armnn::ConstTensor > &constants, const char *name, const armnn::LayerBindingId id=0) override
void IgnoreUnused(Ts &&...)
int LayerBindingId
Type of identifiers for bindable layers (inputs, outputs).
Definition: Types.hpp:210
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
Base class for all descriptors.
Definition: Descriptors.hpp:22
void VerifyNameAndConnections(const armnn::IConnectableLayer *layer, const char *name)
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
Definition: Tensor.hpp:314
A GatherDescriptor for the GatherLayer.
virtual LayerType GetType() const =0
Returns the armnn::LayerType of this layer.
int32_t m_Axis
The axis in params to gather indices from.
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:173
virtual int Connect(IInputSlot &destination)=0
std::string SerializeNetwork(const armnn::INetwork &network)
static INetworkPtr Create(NetworkOptions networkOptions={})
Definition: Network.cpp:510

◆ BOOST_AUTO_TEST_CASE() [21/61]

BOOST_AUTO_TEST_CASE ( SerializeGreaterDeprecated  )

Definition at line 850 of file SerializerTests.cpp.

References ARMNN_NO_DEPRECATE_WARN_BEGIN, ARMNN_NO_DEPRECATE_WARN_END, armnn::Boolean, IOutputSlot::Connect(), INetwork::Create(), DeserializeNetwork(), LayerVerifierBase::ExecuteStrategy(), armnn::Float32, IConnectableLayer::GetOutputSlot(), SerializeNetwork(), and IOutputSlot::SetTensorInfo().

851 {
852  const std::string layerName("greater");
853 
854  const armnn::TensorShape shape{2, 1, 2, 4};
855 
858 
860  armnn::IConnectableLayer* const inputLayer0 = network->AddInputLayer(0);
861  armnn::IConnectableLayer* const inputLayer1 = network->AddInputLayer(1);
863  armnn::IConnectableLayer* const equalLayer = network->AddGreaterLayer(layerName.c_str());
865  armnn::IConnectableLayer* const outputLayer = network->AddOutputLayer(0);
866 
867  inputLayer0->GetOutputSlot(0).Connect(equalLayer->GetInputSlot(0));
868  inputLayer1->GetOutputSlot(0).Connect(equalLayer->GetInputSlot(1));
869  equalLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
870 
871  inputLayer0->GetOutputSlot(0).SetTensorInfo(inputInfo);
872  inputLayer1->GetOutputSlot(0).SetTensorInfo(inputInfo);
873  equalLayer->GetOutputSlot(0).SetTensorInfo(outputInfo);
874 
875  armnn::INetworkPtr deserializedNetwork = DeserializeNetwork(SerializeNetwork(*network));
876  BOOST_CHECK(deserializedNetwork);
877 
878  LayerVerifierBase verifier(layerName, { inputInfo, inputInfo }, { outputInfo });
879  deserializedNetwork->ExecuteStrategy(verifier);
880 }
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition: INetwork.hpp:62
armnn::INetworkPtr DeserializeNetwork(const std::string &serializerString)
#define ARMNN_NO_DEPRECATE_WARN_BEGIN
Definition: Deprecated.hpp:33
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
#define ARMNN_NO_DEPRECATE_WARN_END
Definition: Deprecated.hpp:34
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:173
virtual int Connect(IInputSlot &destination)=0
std::string SerializeNetwork(const armnn::INetwork &network)
static INetworkPtr Create(NetworkOptions networkOptions={})
Definition: Network.cpp:510
void ExecuteStrategy(const armnn::IConnectableLayer *layer, const armnn::BaseDescriptor &descriptor, const std::vector< armnn::ConstTensor > &constants, const char *name, const armnn::LayerBindingId id=0) override

◆ BOOST_AUTO_TEST_CASE() [22/61]

BOOST_AUTO_TEST_CASE ( SerializeInstanceNormalization  )

Definition at line 883 of file SerializerTests.cpp.

References IOutputSlot::Connect(), INetwork::Create(), DeserializeNetwork(), LayerVerifierBaseWithDescriptor< Descriptor >::ExecuteStrategy(), armnn::Float32, IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), armnn::info, InstanceNormalizationDescriptor::m_Gamma, armnn::NHWC, SerializeNetwork(), and IOutputSlot::SetTensorInfo().

884 {
885  const std::string layerName("instanceNormalization");
886  const armnn::TensorInfo info({ 1, 2, 1, 5 }, armnn::DataType::Float32);
887 
889  descriptor.m_Gamma = 1.1f;
890  descriptor.m_Beta = 0.1f;
891  descriptor.m_Eps = 0.0001f;
892  descriptor.m_DataLayout = armnn::DataLayout::NHWC;
893 
895  armnn::IConnectableLayer* const inputLayer = network->AddInputLayer(0);
896  armnn::IConnectableLayer* const instanceNormLayer =
897  network->AddInstanceNormalizationLayer(descriptor, layerName.c_str());
898  armnn::IConnectableLayer* const outputLayer = network->AddOutputLayer(0);
899 
900  inputLayer->GetOutputSlot(0).Connect(instanceNormLayer->GetInputSlot(0));
901  instanceNormLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
902 
903  inputLayer->GetOutputSlot(0).SetTensorInfo(info);
904  instanceNormLayer->GetOutputSlot(0).SetTensorInfo(info);
905 
906  armnn::INetworkPtr deserializedNetwork = DeserializeNetwork(SerializeNetwork(*network));
907  BOOST_CHECK(deserializedNetwork);
908 
910  layerName, {info}, {info}, descriptor);
911  deserializedNetwork->ExecuteStrategy(verifier);
912 }
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition: INetwork.hpp:62
armnn::INetworkPtr DeserializeNetwork(const std::string &serializerString)
float m_Gamma
Gamma, the scale scalar value applied for the normalized tensor. Defaults to 1.0. ...
void ExecuteStrategy(const armnn::IConnectableLayer *layer, const armnn::BaseDescriptor &descriptor, const std::vector< armnn::ConstTensor > &constants, const char *name, const armnn::LayerBindingId id=0) override
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
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:173
virtual int Connect(IInputSlot &destination)=0
std::string SerializeNetwork(const armnn::INetwork &network)
An InstanceNormalizationDescriptor for InstanceNormalizationLayer.
static INetworkPtr Create(NetworkOptions networkOptions={})
Definition: Network.cpp:510

◆ BOOST_AUTO_TEST_CASE() [23/61]

BOOST_AUTO_TEST_CASE ( SerializeL2Normalization  )

Definition at line 914 of file SerializerTests.cpp.

References IOutputSlot::Connect(), INetwork::Create(), DeserializeNetwork(), LayerVerifierBaseWithDescriptor< Descriptor >::ExecuteStrategy(), armnn::Float32, IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), armnn::info, L2NormalizationDescriptor::m_DataLayout, armnn::NCHW, SerializeNetwork(), and IOutputSlot::SetTensorInfo().

915 {
916  const std::string l2NormLayerName("l2Normalization");
917  const armnn::TensorInfo info({1, 2, 1, 5}, armnn::DataType::Float32);
918 
921  desc.m_Eps = 0.0001f;
922 
924  armnn::IConnectableLayer* const inputLayer0 = network->AddInputLayer(0);
925  armnn::IConnectableLayer* const l2NormLayer = network->AddL2NormalizationLayer(desc, l2NormLayerName.c_str());
926  armnn::IConnectableLayer* const outputLayer = network->AddOutputLayer(0);
927 
928  inputLayer0->GetOutputSlot(0).Connect(l2NormLayer->GetInputSlot(0));
929  l2NormLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
930 
931  inputLayer0->GetOutputSlot(0).SetTensorInfo(info);
932  l2NormLayer->GetOutputSlot(0).SetTensorInfo(info);
933 
934  armnn::INetworkPtr deserializedNetwork = DeserializeNetwork(SerializeNetwork(*network));
935  BOOST_CHECK(deserializedNetwork);
936 
938  l2NormLayerName, {info}, {info}, desc);
939  deserializedNetwork->ExecuteStrategy(verifier);
940 }
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition: INetwork.hpp:62
armnn::INetworkPtr DeserializeNetwork(const std::string &serializerString)
void ExecuteStrategy(const armnn::IConnectableLayer *layer, const armnn::BaseDescriptor &descriptor, const std::vector< armnn::ConstTensor > &constants, const char *name, const armnn::LayerBindingId id=0) override
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
A L2NormalizationDescriptor for the L2NormalizationLayer.
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:173
virtual int Connect(IInputSlot &destination)=0
std::string SerializeNetwork(const armnn::INetwork &network)
static INetworkPtr Create(NetworkOptions networkOptions={})
Definition: Network.cpp:510

◆ BOOST_AUTO_TEST_CASE() [24/61]

BOOST_AUTO_TEST_CASE ( EnsureL2NormalizationBackwardCompatibility  )

Definition at line 942 of file SerializerTests.cpp.

References DeserializeNetwork(), LayerVerifierBaseWithDescriptor< Descriptor >::ExecuteStrategy(), armnn::Float32, L2NormalizationDescriptor::m_DataLayout, and armnn::NCHW.

943 {
944  // The hex data below is a flat buffer containing a simple network with one input
945  // a L2Normalization layer and an output layer with dimensions as per the tensor infos below.
946  //
947  // This test verifies that we can still read back these old style
948  // models without the normalization epsilon value.
949  const std::vector<uint8_t> l2NormalizationModel =
950  {
951  0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x10, 0x00, 0x04, 0x00, 0x08, 0x00, 0x0C, 0x00, 0x0A, 0x00,
952  0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
953  0x3C, 0x01, 0x00, 0x00, 0x74, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
954  0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xE8, 0xFE, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x0B,
955  0x04, 0x00, 0x00, 0x00, 0xD6, 0xFE, 0xFF, 0xFF, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x08, 0x00,
956  0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x9E, 0xFF, 0xFF, 0xFF, 0x02, 0x00, 0x00, 0x00,
957  0x10, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00,
958  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
959  0x4C, 0xFF, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x44, 0xFF, 0xFF, 0xFF, 0x00, 0x00,
960  0x00, 0x20, 0x0C, 0x00, 0x00, 0x00, 0x08, 0x00, 0x0C, 0x00, 0x04, 0x00, 0x08, 0x00, 0x08, 0x00, 0x00, 0x00,
961  0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x06, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00,
962  0x0E, 0x00, 0x18, 0x00, 0x04, 0x00, 0x08, 0x00, 0x0C, 0x00, 0x10, 0x00, 0x14, 0x00, 0x0E, 0x00, 0x00, 0x00,
963  0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x00, 0x20, 0x00,
964  0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x6C, 0x32, 0x4E, 0x6F, 0x72, 0x6D, 0x61, 0x6C, 0x69, 0x7A, 0x61, 0x74,
965  0x69, 0x6F, 0x6E, 0x00, 0x01, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0C, 0x00,
966  0x00, 0x00, 0x08, 0x00, 0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
967  0x52, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x01, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00,
968  0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
969  0x08, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
970  0x00, 0x00, 0x08, 0x00, 0x0C, 0x00, 0x07, 0x00, 0x08, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09,
971  0x04, 0x00, 0x00, 0x00, 0xF6, 0xFF, 0xFF, 0xFF, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x0A, 0x00,
972  0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x14, 0x00, 0x00, 0x00,
973  0x04, 0x00, 0x08, 0x00, 0x0C, 0x00, 0x10, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00,
974  0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
975  0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x08, 0x00, 0x0A, 0x00, 0x00, 0x00,
976  0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x10, 0x00, 0x08, 0x00,
977  0x07, 0x00, 0x0C, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
978  0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
979  0x05, 0x00, 0x00, 0x00, 0x00
980  };
981 
982  armnn::INetworkPtr deserializedNetwork =
983  DeserializeNetwork(std::string(l2NormalizationModel.begin(), l2NormalizationModel.end()));
984  BOOST_CHECK(deserializedNetwork);
985 
986  const std::string layerName("l2Normalization");
987  const armnn::TensorInfo inputInfo = armnn::TensorInfo({1, 2, 1, 5}, armnn::DataType::Float32);
988 
991  // Since this variable does not exist in the l2NormalizationModel dump, the default value will be loaded
992  desc.m_Eps = 1e-12f;
993 
995  layerName, {inputInfo}, {inputInfo}, desc);
996  deserializedNetwork->ExecuteStrategy(verifier);
997 }
armnn::INetworkPtr DeserializeNetwork(const std::string &serializerString)
void ExecuteStrategy(const armnn::IConnectableLayer *layer, const armnn::BaseDescriptor &descriptor, const std::vector< armnn::ConstTensor > &constants, const char *name, const armnn::LayerBindingId id=0) override
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
A L2NormalizationDescriptor for the L2NormalizationLayer.
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:173

◆ BOOST_AUTO_TEST_CASE() [25/61]

BOOST_AUTO_TEST_CASE ( SerializeLogicalBinary  )

Definition at line 999 of file SerializerTests.cpp.

References armnn::Boolean, IOutputSlot::Connect(), INetwork::Create(), DeserializeNetwork(), LayerVerifierBaseWithDescriptor< Descriptor >::ExecuteStrategy(), IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), armnn::LogicalAnd, SerializeNetwork(), and IOutputSlot::SetTensorInfo().

1000 {
1001  const std::string layerName("logicalBinaryAnd");
1002 
1003  const armnn::TensorShape shape{2, 1, 2, 2};
1004 
1007 
1009 
1011  armnn::IConnectableLayer* const inputLayer0 = network->AddInputLayer(0);
1012  armnn::IConnectableLayer* const inputLayer1 = network->AddInputLayer(1);
1013  armnn::IConnectableLayer* const logicalBinaryLayer = network->AddLogicalBinaryLayer(descriptor, layerName.c_str());
1014  armnn::IConnectableLayer* const outputLayer = network->AddOutputLayer(0);
1015 
1016  inputLayer0->GetOutputSlot(0).Connect(logicalBinaryLayer->GetInputSlot(0));
1017  inputLayer1->GetOutputSlot(0).Connect(logicalBinaryLayer->GetInputSlot(1));
1018  logicalBinaryLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
1019 
1020  inputLayer0->GetOutputSlot(0).SetTensorInfo(inputInfo);
1021  inputLayer1->GetOutputSlot(0).SetTensorInfo(inputInfo);
1022  logicalBinaryLayer->GetOutputSlot(0).SetTensorInfo(outputInfo);
1023 
1024  armnn::INetworkPtr deserializedNetwork = DeserializeNetwork(SerializeNetwork(*network));
1025  BOOST_CHECK(deserializedNetwork);
1026 
1028  layerName, { inputInfo, inputInfo }, { outputInfo }, descriptor);
1029  deserializedNetwork->ExecuteStrategy(verifier);
1030 }
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition: INetwork.hpp:62
armnn::INetworkPtr DeserializeNetwork(const std::string &serializerString)
A LogicalBinaryDescriptor for the LogicalBinaryLayer.
void ExecuteStrategy(const armnn::IConnectableLayer *layer, const armnn::BaseDescriptor &descriptor, const std::vector< armnn::ConstTensor > &constants, const char *name, const armnn::LayerBindingId id=0) override
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
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:173
virtual int Connect(IInputSlot &destination)=0
std::string SerializeNetwork(const armnn::INetwork &network)
static INetworkPtr Create(NetworkOptions networkOptions={})
Definition: Network.cpp:510

◆ BOOST_AUTO_TEST_CASE() [26/61]

BOOST_AUTO_TEST_CASE ( SerializeLogicalUnary  )

Definition at line 1032 of file SerializerTests.cpp.

References armnn::Boolean, IOutputSlot::Connect(), INetwork::Create(), DeserializeNetwork(), LayerVerifierBaseWithDescriptor< Descriptor >::ExecuteStrategy(), IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), armnn::LogicalNot, SerializeNetwork(), and IOutputSlot::SetTensorInfo().

1033 {
1034  const std::string layerName("elementwiseUnaryLogicalNot");
1035 
1036  const armnn::TensorShape shape{2, 1, 2, 2};
1037 
1040 
1042 
1044  armnn::IConnectableLayer* const inputLayer = network->AddInputLayer(0);
1045  armnn::IConnectableLayer* const elementwiseUnaryLayer =
1046  network->AddElementwiseUnaryLayer(descriptor, layerName.c_str());
1047  armnn::IConnectableLayer* const outputLayer = network->AddOutputLayer(0);
1048 
1049  inputLayer->GetOutputSlot(0).Connect(elementwiseUnaryLayer->GetInputSlot(0));
1050  elementwiseUnaryLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
1051 
1052  inputLayer->GetOutputSlot(0).SetTensorInfo(inputInfo);
1053  elementwiseUnaryLayer->GetOutputSlot(0).SetTensorInfo(outputInfo);
1054 
1055  armnn::INetworkPtr deserializedNetwork = DeserializeNetwork(SerializeNetwork(*network));
1056 
1057  BOOST_CHECK(deserializedNetwork);
1058 
1060  layerName, { inputInfo }, { outputInfo }, descriptor);
1061 
1062  deserializedNetwork->ExecuteStrategy(verifier);
1063 }
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition: INetwork.hpp:62
armnn::INetworkPtr DeserializeNetwork(const std::string &serializerString)
void ExecuteStrategy(const armnn::IConnectableLayer *layer, const armnn::BaseDescriptor &descriptor, const std::vector< armnn::ConstTensor > &constants, const char *name, const armnn::LayerBindingId id=0) override
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
A ElementwiseUnaryDescriptor for the ElementwiseUnaryLayer.
Definition: Descriptors.hpp:98
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:173
virtual int Connect(IInputSlot &destination)=0
std::string SerializeNetwork(const armnn::INetwork &network)
static INetworkPtr Create(NetworkOptions networkOptions={})
Definition: Network.cpp:510

◆ BOOST_AUTO_TEST_CASE() [27/61]

BOOST_AUTO_TEST_CASE ( SerializeLogSoftmax  )

Definition at line 1065 of file SerializerTests.cpp.

References IOutputSlot::Connect(), INetwork::Create(), DeserializeNetwork(), LayerVerifierBaseWithDescriptor< Descriptor >::ExecuteStrategy(), armnn::Float32, IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), armnn::info, SoftmaxDescriptor::m_Beta, SerializeNetwork(), and IOutputSlot::SetTensorInfo().

1066 {
1067  const std::string layerName("log_softmax");
1069 
1070  armnn::LogSoftmaxDescriptor descriptor;
1071  descriptor.m_Beta = 1.0f;
1072  descriptor.m_Axis = -1;
1073 
1075  armnn::IConnectableLayer* const inputLayer = network->AddInputLayer(0);
1076  armnn::IConnectableLayer* const logSoftmaxLayer = network->AddLogSoftmaxLayer(descriptor, layerName.c_str());
1077  armnn::IConnectableLayer* const outputLayer = network->AddOutputLayer(0);
1078 
1079  inputLayer->GetOutputSlot(0).Connect(logSoftmaxLayer->GetInputSlot(0));
1080  logSoftmaxLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
1081 
1082  inputLayer->GetOutputSlot(0).SetTensorInfo(info);
1083  logSoftmaxLayer->GetOutputSlot(0).SetTensorInfo(info);
1084 
1085  armnn::INetworkPtr deserializedNetwork = DeserializeNetwork(SerializeNetwork(*network));
1086  BOOST_CHECK(deserializedNetwork);
1087 
1088  LayerVerifierBaseWithDescriptor<armnn::LogSoftmaxDescriptor> verifier(layerName, {info}, {info}, descriptor);
1089  deserializedNetwork->ExecuteStrategy(verifier);
1090 }
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition: INetwork.hpp:62
armnn::INetworkPtr DeserializeNetwork(const std::string &serializerString)
float m_Beta
Exponentiation value.
void ExecuteStrategy(const armnn::IConnectableLayer *layer, const armnn::BaseDescriptor &descriptor, const std::vector< armnn::ConstTensor > &constants, const char *name, const armnn::LayerBindingId id=0) override
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
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:173
virtual int Connect(IInputSlot &destination)=0
std::string SerializeNetwork(const armnn::INetwork &network)
static INetworkPtr Create(NetworkOptions networkOptions={})
Definition: Network.cpp:510
A SoftmaxDescriptor for the SoftmaxLayer.

◆ BOOST_AUTO_TEST_CASE() [28/61]

BOOST_AUTO_TEST_CASE ( SerializeMaximum  )

Definition at line 1092 of file SerializerTests.cpp.

References IOutputSlot::Connect(), INetwork::Create(), DeserializeNetwork(), LayerVerifierBase::ExecuteStrategy(), armnn::Float32, IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), armnn::info, SerializeNetwork(), and IOutputSlot::SetTensorInfo().

1093 {
1094  const std::string layerName("maximum");
1095  const armnn::TensorInfo info({ 1, 2, 2, 3 }, armnn::DataType::Float32);
1096 
1098  armnn::IConnectableLayer* const inputLayer0 = network->AddInputLayer(0);
1099  armnn::IConnectableLayer* const inputLayer1 = network->AddInputLayer(1);
1100  armnn::IConnectableLayer* const maximumLayer = network->AddMaximumLayer(layerName.c_str());
1101  armnn::IConnectableLayer* const outputLayer = network->AddOutputLayer(0);
1102 
1103  inputLayer0->GetOutputSlot(0).Connect(maximumLayer->GetInputSlot(0));
1104  inputLayer1->GetOutputSlot(0).Connect(maximumLayer->GetInputSlot(1));
1105  maximumLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
1106 
1107  inputLayer0->GetOutputSlot(0).SetTensorInfo(info);
1108  inputLayer1->GetOutputSlot(0).SetTensorInfo(info);
1109  maximumLayer->GetOutputSlot(0).SetTensorInfo(info);
1110 
1111  armnn::INetworkPtr deserializedNetwork = DeserializeNetwork(SerializeNetwork(*network));
1112  BOOST_CHECK(deserializedNetwork);
1113 
1114  LayerVerifierBase verifier(layerName, {info, info}, {info});
1115  deserializedNetwork->ExecuteStrategy(verifier);
1116 }
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition: INetwork.hpp:62
armnn::INetworkPtr DeserializeNetwork(const std::string &serializerString)
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
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:173
virtual int Connect(IInputSlot &destination)=0
std::string SerializeNetwork(const armnn::INetwork &network)
static INetworkPtr Create(NetworkOptions networkOptions={})
Definition: Network.cpp:510
void ExecuteStrategy(const armnn::IConnectableLayer *layer, const armnn::BaseDescriptor &descriptor, const std::vector< armnn::ConstTensor > &constants, const char *name, const armnn::LayerBindingId id=0) override

◆ BOOST_AUTO_TEST_CASE() [29/61]

BOOST_AUTO_TEST_CASE ( SerializeMean  )

Definition at line 1118 of file SerializerTests.cpp.

References IOutputSlot::Connect(), INetwork::Create(), DeserializeNetwork(), LayerVerifierBaseWithDescriptor< Descriptor >::ExecuteStrategy(), armnn::Float32, IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), MeanDescriptor::m_Axis, SerializeNetwork(), and IOutputSlot::SetTensorInfo().

1119 {
1120  const std::string layerName("mean");
1121  const armnn::TensorInfo inputInfo({1, 1, 3, 2}, armnn::DataType::Float32);
1122  const armnn::TensorInfo outputInfo({1, 1, 1, 2}, armnn::DataType::Float32);
1123 
1124  armnn::MeanDescriptor descriptor;
1125  descriptor.m_Axis = { 2 };
1126  descriptor.m_KeepDims = true;
1127 
1129  armnn::IConnectableLayer* const inputLayer = network->AddInputLayer(0);
1130  armnn::IConnectableLayer* const meanLayer = network->AddMeanLayer(descriptor, layerName.c_str());
1131  armnn::IConnectableLayer* const outputLayer = network->AddOutputLayer(0);
1132 
1133  inputLayer->GetOutputSlot(0).Connect(meanLayer->GetInputSlot(0));
1134  meanLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
1135 
1136  inputLayer->GetOutputSlot(0).SetTensorInfo(inputInfo);
1137  meanLayer->GetOutputSlot(0).SetTensorInfo(outputInfo);
1138 
1139  armnn::INetworkPtr deserializedNetwork = DeserializeNetwork(SerializeNetwork(*network));
1140  BOOST_CHECK(deserializedNetwork);
1141 
1142  LayerVerifierBaseWithDescriptor<armnn::MeanDescriptor> verifier(layerName, {inputInfo}, {outputInfo}, descriptor);
1143  deserializedNetwork->ExecuteStrategy(verifier);
1144 }
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition: INetwork.hpp:62
armnn::INetworkPtr DeserializeNetwork(const std::string &serializerString)
void ExecuteStrategy(const armnn::IConnectableLayer *layer, const armnn::BaseDescriptor &descriptor, const std::vector< armnn::ConstTensor > &constants, const char *name, const armnn::LayerBindingId id=0) override
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
std::vector< unsigned int > m_Axis
Values for the dimensions to reduce.
virtual const IInputSlot & GetInputSlot(unsigned int index) const =0
Get a const input slot handle by slot index.
A MeanDescriptor for the MeanLayer.
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:173
virtual int Connect(IInputSlot &destination)=0
std::string SerializeNetwork(const armnn::INetwork &network)
static INetworkPtr Create(NetworkOptions networkOptions={})
Definition: Network.cpp:510

◆ BOOST_AUTO_TEST_CASE() [30/61]

BOOST_AUTO_TEST_CASE ( SerializeMerge  )

Definition at line 1146 of file SerializerTests.cpp.

References armnn::Concat, IOutputSlot::Connect(), INetwork::Create(), DeserializeNetwork(), LayerVerifierBase::ExecuteStrategy(), armnn::Float32, IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), IConnectableLayer::GetType(), armnn::IgnoreUnused(), armnn::info, armnn::Input, armnn::Merge, armnn::Output, SerializeNetwork(), and IOutputSlot::SetTensorInfo().

1147 {
1148  const std::string layerName("merge");
1149  const armnn::TensorInfo info({ 1, 2, 2, 3 }, armnn::DataType::Float32);
1150 
1152  armnn::IConnectableLayer* const inputLayer0 = network->AddInputLayer(0);
1153  armnn::IConnectableLayer* const inputLayer1 = network->AddInputLayer(1);
1154  armnn::IConnectableLayer* const mergeLayer = network->AddMergeLayer(layerName.c_str());
1155  armnn::IConnectableLayer* const outputLayer = network->AddOutputLayer(0);
1156 
1157  inputLayer0->GetOutputSlot(0).Connect(mergeLayer->GetInputSlot(0));
1158  inputLayer1->GetOutputSlot(0).Connect(mergeLayer->GetInputSlot(1));
1159  mergeLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
1160 
1161  inputLayer0->GetOutputSlot(0).SetTensorInfo(info);
1162  inputLayer1->GetOutputSlot(0).SetTensorInfo(info);
1163  mergeLayer->GetOutputSlot(0).SetTensorInfo(info);
1164 
1165  armnn::INetworkPtr deserializedNetwork = DeserializeNetwork(SerializeNetwork(*network));
1166  BOOST_CHECK(deserializedNetwork);
1167 
1168  LayerVerifierBase verifier(layerName, {info, info}, {info});
1169  deserializedNetwork->ExecuteStrategy(verifier);
1170 }
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition: INetwork.hpp:62
armnn::INetworkPtr DeserializeNetwork(const std::string &serializerString)
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
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:173
virtual int Connect(IInputSlot &destination)=0
std::string SerializeNetwork(const armnn::INetwork &network)
static INetworkPtr Create(NetworkOptions networkOptions={})
Definition: Network.cpp:510
void ExecuteStrategy(const armnn::IConnectableLayer *layer, const armnn::BaseDescriptor &descriptor, const std::vector< armnn::ConstTensor > &constants, const char *name, const armnn::LayerBindingId id=0) override

◆ BOOST_AUTO_TEST_CASE() [31/61]

BOOST_AUTO_TEST_CASE ( SerializeMerger  )

Definition at line 1216 of file SerializerTests.cpp.

References ARMNN_NO_DEPRECATE_WARN_BEGIN, ARMNN_NO_DEPRECATE_WARN_END, IOutputSlot::Connect(), INetwork::Create(), armnn::CreateDescriptorForConcatenation(), DeserializeNetwork(), armnn::Float32, IConnectableLayer::GetOutputSlot(), TensorInfo::GetShape(), SerializeNetwork(), and IOutputSlot::SetTensorInfo().

1217 {
1218  const std::string layerName("merger");
1219  const armnn::TensorInfo inputInfo = armnn::TensorInfo({2, 3, 2, 2}, armnn::DataType::Float32);
1220  const armnn::TensorInfo outputInfo = armnn::TensorInfo({4, 3, 2, 2}, armnn::DataType::Float32);
1221 
1222  const std::vector<armnn::TensorShape> shapes({inputInfo.GetShape(), inputInfo.GetShape()});
1223 
1224  armnn::OriginsDescriptor descriptor =
1225  armnn::CreateDescriptorForConcatenation(shapes.begin(), shapes.end(), 0);
1226 
1228  armnn::IConnectableLayer* const inputLayerOne = network->AddInputLayer(0);
1229  armnn::IConnectableLayer* const inputLayerTwo = network->AddInputLayer(1);
1231  armnn::IConnectableLayer* const mergerLayer = network->AddMergerLayer(descriptor, layerName.c_str());
1233  armnn::IConnectableLayer* const outputLayer = network->AddOutputLayer(0);
1234 
1235  inputLayerOne->GetOutputSlot(0).Connect(mergerLayer->GetInputSlot(0));
1236  inputLayerTwo->GetOutputSlot(0).Connect(mergerLayer->GetInputSlot(1));
1237  mergerLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
1238 
1239  inputLayerOne->GetOutputSlot(0).SetTensorInfo(inputInfo);
1240  inputLayerTwo->GetOutputSlot(0).SetTensorInfo(inputInfo);
1241  mergerLayer->GetOutputSlot(0).SetTensorInfo(outputInfo);
1242 
1243  std::string mergerLayerNetwork = SerializeNetwork(*network);
1244  armnn::INetworkPtr deserializedNetwork = DeserializeNetwork(mergerLayerNetwork);
1245  BOOST_CHECK(deserializedNetwork);
1246 
1247  MergerLayerVerifier verifier(layerName, {inputInfo, inputInfo}, {outputInfo}, descriptor);
1248  deserializedNetwork->ExecuteStrategy(verifier);
1249 }
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition: INetwork.hpp:62
const TensorShape & GetShape() const
Definition: Tensor.hpp:187
armnn::INetworkPtr DeserializeNetwork(const std::string &serializerString)
#define ARMNN_NO_DEPRECATE_WARN_BEGIN
Definition: Deprecated.hpp:33
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
#define ARMNN_NO_DEPRECATE_WARN_END
Definition: Deprecated.hpp:34
An OriginsDescriptor for the ConcatLayer.
virtual const IOutputSlot & GetOutputSlot(unsigned int index) const =0
Get the const output slot handle by slot index.
OriginsDescriptor CreateDescriptorForConcatenation(TensorShapeIt first, TensorShapeIt last, unsigned int concatenationDimension)
Convenience template to create an OriginsDescriptor to use when creating a ConcatLayer for performing...
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:173
virtual int Connect(IInputSlot &destination)=0
std::string SerializeNetwork(const armnn::INetwork &network)
static INetworkPtr Create(NetworkOptions networkOptions={})
Definition: Network.cpp:510

◆ BOOST_AUTO_TEST_CASE() [32/61]

BOOST_AUTO_TEST_CASE ( EnsureMergerLayerBackwardCompatibility  )

Definition at line 1251 of file SerializerTests.cpp.

References armnn::CreateDescriptorForConcatenation(), DeserializeNetwork(), armnn::Float32, and TensorInfo::GetShape().

1252 {
1253  // The hex data below is a flat buffer containing a simple network with two inputs
1254  // a merger layer (now deprecated) and an output layer with dimensions as per the tensor infos below.
1255  //
1256  // This test verifies that we can still read back these old style
1257  // models replacing the MergerLayers with ConcatLayers with the same parameters.
1258  const std::vector<uint8_t> mergerModel =
1259  {
1260  0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x10, 0x00, 0x04, 0x00, 0x08, 0x00, 0x0C, 0x00, 0x0A, 0x00,
1261  0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
1262  0x38, 0x02, 0x00, 0x00, 0x8C, 0x01, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x02, 0x00,
1263  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
1264  0xF4, 0xFD, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x0B, 0x04, 0x00, 0x00, 0x00, 0x92, 0xFE, 0xFF, 0xFF, 0x04, 0x00,
1265  0x00, 0x00, 0x9A, 0xFE, 0xFF, 0xFF, 0x04, 0x00, 0x00, 0x00, 0x7E, 0xFE, 0xFF, 0xFF, 0x03, 0x00, 0x00, 0x00,
1266  0x10, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00,
1267  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1268  0xF8, 0xFE, 0xFF, 0xFF, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0xFE, 0xFF, 0xFF, 0x00, 0x00,
1269  0x00, 0x1F, 0x0C, 0x00, 0x00, 0x00, 0x08, 0x00, 0x0C, 0x00, 0x04, 0x00, 0x08, 0x00, 0x08, 0x00, 0x00, 0x00,
1270  0x68, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x10, 0x00, 0x00, 0x00, 0x04, 0x00, 0x08, 0x00,
1271  0x0C, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
1272  0x02, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x22, 0xFF, 0xFF, 0xFF, 0x04, 0x00,
1273  0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1274  0x00, 0x00, 0x00, 0x00, 0x3E, 0xFF, 0xFF, 0xFF, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00,
1275  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0xFF, 0xFF, 0xFF,
1276  0x02, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x1C, 0x00,
1277  0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x6D, 0x65, 0x72, 0x67, 0x65, 0x72, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
1278  0x5C, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x34, 0xFF,
1279  0xFF, 0xFF, 0x04, 0x00, 0x00, 0x00, 0x92, 0xFE, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x01, 0x08, 0x00, 0x00, 0x00,
1280  0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00,
1281  0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, 0x10, 0x00, 0x04, 0x00, 0x08, 0x00, 0x08, 0x00, 0x00, 0x00,
1282  0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x0C, 0x00, 0x00, 0x00,
1283  0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x0E, 0x00,
1284  0x07, 0x00, 0x08, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00,
1285  0x06, 0x00, 0x08, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x08, 0x00, 0x0E, 0x00,
1286  0x04, 0x00, 0x08, 0x00, 0x08, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
1287  0x0E, 0x00, 0x18, 0x00, 0x04, 0x00, 0x08, 0x00, 0x0C, 0x00, 0x10, 0x00, 0x14, 0x00, 0x0E, 0x00, 0x00, 0x00,
1288  0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x10, 0x00,
1289  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
1290  0x0C, 0x00, 0x00, 0x00, 0x08, 0x00, 0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x04, 0x00,
1291  0x00, 0x00, 0x66, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x01, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1292  0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00,
1293  0x00, 0x00, 0x08, 0x00, 0x0C, 0x00, 0x07, 0x00, 0x08, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09,
1294  0x04, 0x00, 0x00, 0x00, 0xF6, 0xFF, 0xFF, 0xFF, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x0A, 0x00,
1295  0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x14, 0x00, 0x00, 0x00,
1296  0x04, 0x00, 0x08, 0x00, 0x0C, 0x00, 0x10, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00,
1297  0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1298  0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x08, 0x00, 0x0A, 0x00, 0x00, 0x00,
1299  0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x10, 0x00, 0x08, 0x00,
1300  0x07, 0x00, 0x0C, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
1301  0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
1302  0x02, 0x00, 0x00, 0x00
1303  };
1304 
1305  armnn::INetworkPtr deserializedNetwork = DeserializeNetwork(std::string(mergerModel.begin(), mergerModel.end()));
1306  BOOST_CHECK(deserializedNetwork);
1307 
1308  const armnn::TensorInfo inputInfo = armnn::TensorInfo({ 2, 3, 2, 2 }, armnn::DataType::Float32);
1309  const armnn::TensorInfo outputInfo = armnn::TensorInfo({ 4, 3, 2, 2 }, armnn::DataType::Float32);
1310 
1311  const std::vector<armnn::TensorShape> shapes({inputInfo.GetShape(), inputInfo.GetShape()});
1312 
1313  armnn::OriginsDescriptor descriptor =
1314  armnn::CreateDescriptorForConcatenation(shapes.begin(), shapes.end(), 0);
1315 
1316  MergerLayerVerifier verifier("merger", { inputInfo, inputInfo }, { outputInfo }, descriptor);
1317  deserializedNetwork->ExecuteStrategy(verifier);
1318 }
const TensorShape & GetShape() const
Definition: Tensor.hpp:187
armnn::INetworkPtr DeserializeNetwork(const std::string &serializerString)
An OriginsDescriptor for the ConcatLayer.
OriginsDescriptor CreateDescriptorForConcatenation(TensorShapeIt first, TensorShapeIt last, unsigned int concatenationDimension)
Convenience template to create an OriginsDescriptor to use when creating a ConcatLayer for performing...
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:173

◆ BOOST_AUTO_TEST_CASE() [33/61]

BOOST_AUTO_TEST_CASE ( SerializeConcat  )

Definition at line 1320 of file SerializerTests.cpp.

References IOutputSlot::Connect(), INetwork::Create(), armnn::CreateDescriptorForConcatenation(), DeserializeNetwork(), armnn::Float32, IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), TensorInfo::GetShape(), SerializeNetwork(), and IOutputSlot::SetTensorInfo().

1321 {
1322  const std::string layerName("concat");
1323  const armnn::TensorInfo inputInfo = armnn::TensorInfo({2, 3, 2, 2}, armnn::DataType::Float32);
1324  const armnn::TensorInfo outputInfo = armnn::TensorInfo({4, 3, 2, 2}, armnn::DataType::Float32);
1325 
1326  const std::vector<armnn::TensorShape> shapes({inputInfo.GetShape(), inputInfo.GetShape()});
1327 
1328  armnn::OriginsDescriptor descriptor =
1329  armnn::CreateDescriptorForConcatenation(shapes.begin(), shapes.end(), 0);
1330 
1332  armnn::IConnectableLayer* const inputLayerOne = network->AddInputLayer(0);
1333  armnn::IConnectableLayer* const inputLayerTwo = network->AddInputLayer(1);
1334  armnn::IConnectableLayer* const concatLayer = network->AddConcatLayer(descriptor, layerName.c_str());
1335  armnn::IConnectableLayer* const outputLayer = network->AddOutputLayer(0);
1336 
1337  inputLayerOne->GetOutputSlot(0).Connect(concatLayer->GetInputSlot(0));
1338  inputLayerTwo->GetOutputSlot(0).Connect(concatLayer->GetInputSlot(1));
1339  concatLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
1340 
1341  inputLayerOne->GetOutputSlot(0).SetTensorInfo(inputInfo);
1342  inputLayerTwo->GetOutputSlot(0).SetTensorInfo(inputInfo);
1343  concatLayer->GetOutputSlot(0).SetTensorInfo(outputInfo);
1344 
1345  std::string concatLayerNetwork = SerializeNetwork(*network);
1346  armnn::INetworkPtr deserializedNetwork = DeserializeNetwork(concatLayerNetwork);
1347  BOOST_CHECK(deserializedNetwork);
1348 
1349  // NOTE: using the MergerLayerVerifier to ensure that it is a concat layer and not a
1350  // merger layer that gets placed into the graph.
1351  MergerLayerVerifier verifier(layerName, {inputInfo, inputInfo}, {outputInfo}, descriptor);
1352  deserializedNetwork->ExecuteStrategy(verifier);
1353 }
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition: INetwork.hpp:62
const TensorShape & GetShape() const
Definition: Tensor.hpp:187
armnn::INetworkPtr DeserializeNetwork(const std::string &serializerString)
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
An OriginsDescriptor for the ConcatLayer.
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.
OriginsDescriptor CreateDescriptorForConcatenation(TensorShapeIt first, TensorShapeIt last, unsigned int concatenationDimension)
Convenience template to create an OriginsDescriptor to use when creating a ConcatLayer for performing...
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:173
virtual int Connect(IInputSlot &destination)=0
std::string SerializeNetwork(const armnn::INetwork &network)
static INetworkPtr Create(NetworkOptions networkOptions={})
Definition: Network.cpp:510

◆ BOOST_AUTO_TEST_CASE() [34/61]

BOOST_AUTO_TEST_CASE ( SerializeMinimum  )

Definition at line 1355 of file SerializerTests.cpp.

References IOutputSlot::Connect(), INetwork::Create(), DeserializeNetwork(), LayerVerifierBase::ExecuteStrategy(), armnn::Float32, IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), armnn::info, SerializeNetwork(), and IOutputSlot::SetTensorInfo().

1356 {
1357  const std::string layerName("minimum");
1358  const armnn::TensorInfo info({ 1, 2, 2, 3 }, armnn::DataType::Float32);
1359 
1361  armnn::IConnectableLayer* const inputLayer0 = network->AddInputLayer(0);
1362  armnn::IConnectableLayer* const inputLayer1 = network->AddInputLayer(1);
1363  armnn::IConnectableLayer* const minimumLayer = network->AddMinimumLayer(layerName.c_str());
1364  armnn::IConnectableLayer* const outputLayer = network->AddOutputLayer(0);
1365 
1366  inputLayer0->GetOutputSlot(0).Connect(minimumLayer->GetInputSlot(0));
1367  inputLayer1->GetOutputSlot(0).Connect(minimumLayer->GetInputSlot(1));
1368  minimumLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
1369 
1370  inputLayer0->GetOutputSlot(0).SetTensorInfo(info);
1371  inputLayer1->GetOutputSlot(0).SetTensorInfo(info);
1372  minimumLayer->GetOutputSlot(0).SetTensorInfo(info);
1373 
1374  armnn::INetworkPtr deserializedNetwork = DeserializeNetwork(SerializeNetwork(*network));
1375  BOOST_CHECK(deserializedNetwork);
1376 
1377  LayerVerifierBase verifier(layerName, {info, info}, {info});
1378  deserializedNetwork->ExecuteStrategy(verifier);
1379 }
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition: INetwork.hpp:62
armnn::INetworkPtr DeserializeNetwork(const std::string &serializerString)
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
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:173
virtual int Connect(IInputSlot &destination)=0
std::string SerializeNetwork(const armnn::INetwork &network)
static INetworkPtr Create(NetworkOptions networkOptions={})
Definition: Network.cpp:510
void ExecuteStrategy(const armnn::IConnectableLayer *layer, const armnn::BaseDescriptor &descriptor, const std::vector< armnn::ConstTensor > &constants, const char *name, const armnn::LayerBindingId id=0) override

◆ BOOST_AUTO_TEST_CASE() [35/61]

BOOST_AUTO_TEST_CASE ( SerializeMultiplication  )

Definition at line 1381 of file SerializerTests.cpp.

References IOutputSlot::Connect(), INetwork::Create(), DeserializeNetwork(), LayerVerifierBase::ExecuteStrategy(), armnn::Float32, IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), armnn::info, SerializeNetwork(), and IOutputSlot::SetTensorInfo().

1382 {
1383  const std::string layerName("multiplication");
1384  const armnn::TensorInfo info({ 1, 5, 2, 3 }, armnn::DataType::Float32);
1385 
1387  armnn::IConnectableLayer* const inputLayer0 = network->AddInputLayer(0);
1388  armnn::IConnectableLayer* const inputLayer1 = network->AddInputLayer(1);
1389  armnn::IConnectableLayer* const multiplicationLayer = network->AddMultiplicationLayer(layerName.c_str());
1390  armnn::IConnectableLayer* const outputLayer = network->AddOutputLayer(0);
1391 
1392  inputLayer0->GetOutputSlot(0).Connect(multiplicationLayer->GetInputSlot(0));
1393  inputLayer1->GetOutputSlot(0).Connect(multiplicationLayer->GetInputSlot(1));
1394  multiplicationLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
1395 
1396  inputLayer0->GetOutputSlot(0).SetTensorInfo(info);
1397  inputLayer1->GetOutputSlot(0).SetTensorInfo(info);
1398  multiplicationLayer->GetOutputSlot(0).SetTensorInfo(info);
1399 
1400  armnn::INetworkPtr deserializedNetwork = DeserializeNetwork(SerializeNetwork(*network));
1401  BOOST_CHECK(deserializedNetwork);
1402 
1403  LayerVerifierBase verifier(layerName, {info, info}, {info});
1404  deserializedNetwork->ExecuteStrategy(verifier);
1405 }
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition: INetwork.hpp:62
armnn::INetworkPtr DeserializeNetwork(const std::string &serializerString)
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
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:173
virtual int Connect(IInputSlot &destination)=0
std::string SerializeNetwork(const armnn::INetwork &network)
static INetworkPtr Create(NetworkOptions networkOptions={})
Definition: Network.cpp:510
void ExecuteStrategy(const armnn::IConnectableLayer *layer, const armnn::BaseDescriptor &descriptor, const std::vector< armnn::ConstTensor > &constants, const char *name, const armnn::LayerBindingId id=0) override

◆ BOOST_AUTO_TEST_CASE() [36/61]

BOOST_AUTO_TEST_CASE ( SerializePrelu  )

Definition at line 1407 of file SerializerTests.cpp.

References IOutputSlot::Connect(), INetwork::Create(), DeserializeNetwork(), LayerVerifierBase::ExecuteStrategy(), armnn::Float32, IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), SerializeNetwork(), and IOutputSlot::SetTensorInfo().

1408 {
1409  const std::string layerName("prelu");
1410 
1411  armnn::TensorInfo inputTensorInfo ({ 4, 1, 2 }, armnn::DataType::Float32);
1412  armnn::TensorInfo alphaTensorInfo ({ 5, 4, 3, 1 }, armnn::DataType::Float32);
1413  armnn::TensorInfo outputTensorInfo({ 5, 4, 3, 2 }, armnn::DataType::Float32);
1414 
1416  armnn::IConnectableLayer* const inputLayer = network->AddInputLayer(0);
1417  armnn::IConnectableLayer* const alphaLayer = network->AddInputLayer(1);
1418  armnn::IConnectableLayer* const preluLayer = network->AddPreluLayer(layerName.c_str());
1419  armnn::IConnectableLayer* const outputLayer = network->AddOutputLayer(0);
1420 
1421  inputLayer->GetOutputSlot(0).Connect(preluLayer->GetInputSlot(0));
1422  alphaLayer->GetOutputSlot(0).Connect(preluLayer->GetInputSlot(1));
1423  preluLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
1424 
1425  inputLayer->GetOutputSlot(0).SetTensorInfo(inputTensorInfo);
1426  alphaLayer->GetOutputSlot(0).SetTensorInfo(alphaTensorInfo);
1427  preluLayer->GetOutputSlot(0).SetTensorInfo(outputTensorInfo);
1428 
1429  armnn::INetworkPtr deserializedNetwork = DeserializeNetwork(SerializeNetwork(*network));
1430  BOOST_CHECK(deserializedNetwork);
1431 
1432  LayerVerifierBase verifier(layerName, {inputTensorInfo, alphaTensorInfo}, {outputTensorInfo});
1433  deserializedNetwork->ExecuteStrategy(verifier);
1434 }
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition: INetwork.hpp:62
armnn::INetworkPtr DeserializeNetwork(const std::string &serializerString)
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
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:173
virtual int Connect(IInputSlot &destination)=0
std::string SerializeNetwork(const armnn::INetwork &network)
static INetworkPtr Create(NetworkOptions networkOptions={})
Definition: Network.cpp:510
void ExecuteStrategy(const armnn::IConnectableLayer *layer, const armnn::BaseDescriptor &descriptor, const std::vector< armnn::ConstTensor > &constants, const char *name, const armnn::LayerBindingId id=0) override

◆ BOOST_AUTO_TEST_CASE() [37/61]

BOOST_AUTO_TEST_CASE ( SerializeNormalization  )

Definition at line 1436 of file SerializerTests.cpp.

References IOutputSlot::Connect(), INetwork::Create(), DeserializeNetwork(), LayerVerifierBaseWithDescriptor< Descriptor >::ExecuteStrategy(), armnn::Float32, IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), armnn::info, NormalizationDescriptor::m_DataLayout, armnn::NCHW, SerializeNetwork(), and IOutputSlot::SetTensorInfo().

1437 {
1438  const std::string layerName("normalization");
1439  const armnn::TensorInfo info({2, 1, 2, 2}, armnn::DataType::Float32);
1440 
1443  desc.m_NormSize = 3;
1444  desc.m_Alpha = 1;
1445  desc.m_Beta = 1;
1446  desc.m_K = 1;
1447 
1449  armnn::IConnectableLayer* const inputLayer = network->AddInputLayer(0);
1450  armnn::IConnectableLayer* const normalizationLayer = network->AddNormalizationLayer(desc, layerName.c_str());
1451  armnn::IConnectableLayer* const outputLayer = network->AddOutputLayer(0);
1452 
1453  inputLayer->GetOutputSlot(0).Connect(normalizationLayer->GetInputSlot(0));
1454  normalizationLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
1455 
1456  inputLayer->GetOutputSlot(0).SetTensorInfo(info);
1457  normalizationLayer->GetOutputSlot(0).SetTensorInfo(info);
1458 
1459  armnn::INetworkPtr deserializedNetwork = DeserializeNetwork(SerializeNetwork(*network));
1460  BOOST_CHECK(deserializedNetwork);
1461 
1463  deserializedNetwork->ExecuteStrategy(verifier);
1464 }
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition: INetwork.hpp:62
armnn::INetworkPtr DeserializeNetwork(const std::string &serializerString)
void ExecuteStrategy(const armnn::IConnectableLayer *layer, const armnn::BaseDescriptor &descriptor, const std::vector< armnn::ConstTensor > &constants, const char *name, const armnn::LayerBindingId id=0) override
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
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:173
virtual int Connect(IInputSlot &destination)=0
std::string SerializeNetwork(const armnn::INetwork &network)
A NormalizationDescriptor for the NormalizationLayer.
static INetworkPtr Create(NetworkOptions networkOptions={})
Definition: Network.cpp:510

◆ BOOST_AUTO_TEST_CASE() [38/61]

BOOST_AUTO_TEST_CASE ( SerializePad  )

Definition at line 1466 of file SerializerTests.cpp.

References IOutputSlot::Connect(), INetwork::Create(), DeserializeNetwork(), LayerVerifierBaseWithDescriptor< Descriptor >::ExecuteStrategy(), armnn::Float32, IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), SerializeNetwork(), and IOutputSlot::SetTensorInfo().

1467 {
1468  const std::string layerName("pad");
1469  const armnn::TensorInfo inputTensorInfo = armnn::TensorInfo({1, 2, 3, 4}, armnn::DataType::Float32);
1470  const armnn::TensorInfo outputTensorInfo = armnn::TensorInfo({1, 3, 5, 7}, armnn::DataType::Float32);
1471 
1472  armnn::PadDescriptor desc({{0, 0}, {1, 0}, {1, 1}, {1, 2}});
1473 
1475  armnn::IConnectableLayer* const inputLayer = network->AddInputLayer(0);
1476  armnn::IConnectableLayer* const padLayer = network->AddPadLayer(desc, layerName.c_str());
1477  armnn::IConnectableLayer* const outputLayer = network->AddOutputLayer(0);
1478 
1479  inputLayer->GetOutputSlot(0).Connect(padLayer->GetInputSlot(0));
1480  padLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
1481 
1482  inputLayer->GetOutputSlot(0).SetTensorInfo(inputTensorInfo);
1483  padLayer->GetOutputSlot(0).SetTensorInfo(outputTensorInfo);
1484 
1485  armnn::INetworkPtr deserializedNetwork = DeserializeNetwork(SerializeNetwork(*network));
1486  BOOST_CHECK(deserializedNetwork);
1487 
1489  {inputTensorInfo},
1490  {outputTensorInfo},
1491  desc);
1492  deserializedNetwork->ExecuteStrategy(verifier);
1493 }
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition: INetwork.hpp:62
armnn::INetworkPtr DeserializeNetwork(const std::string &serializerString)
void ExecuteStrategy(const armnn::IConnectableLayer *layer, const armnn::BaseDescriptor &descriptor, const std::vector< armnn::ConstTensor > &constants, const char *name, const armnn::LayerBindingId id=0) override
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
A PadDescriptor for the PadLayer.
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:173
virtual int Connect(IInputSlot &destination)=0
std::string SerializeNetwork(const armnn::INetwork &network)
static INetworkPtr Create(NetworkOptions networkOptions={})
Definition: Network.cpp:510

◆ BOOST_AUTO_TEST_CASE() [39/61]

BOOST_AUTO_TEST_CASE ( EnsurePadBackwardCompatibility  )

Definition at line 1495 of file SerializerTests.cpp.

References DeserializeNetwork(), LayerVerifierBaseWithDescriptor< Descriptor >::ExecuteStrategy(), and armnn::Float32.

1496 {
1497  // The PadDescriptor is being extended with a float PadValue (so a value other than 0
1498  // can be used to pad the tensor.
1499  //
1500  // This test contains a binary representation of a simple input->pad->output network
1501  // prior to this change to test that the descriptor has been updated in a backward
1502  // compatible way with respect to Deserialization of older binary dumps
1503  const std::vector<uint8_t> padModel =
1504  {
1505  0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x10, 0x00, 0x04, 0x00, 0x08, 0x00, 0x0C, 0x00, 0x0A, 0x00,
1506  0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
1507  0x54, 0x01, 0x00, 0x00, 0x6C, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
1508  0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xD0, 0xFE, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x0B,
1509  0x04, 0x00, 0x00, 0x00, 0x96, 0xFF, 0xFF, 0xFF, 0x04, 0x00, 0x00, 0x00, 0x9E, 0xFF, 0xFF, 0xFF, 0x04, 0x00,
1510  0x00, 0x00, 0x72, 0xFF, 0xFF, 0xFF, 0x02, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
1511  0x10, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,
1512  0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2C, 0xFF, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00,
1513  0x00, 0x00, 0x00, 0x00, 0x24, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x16, 0x0C, 0x00, 0x00, 0x00, 0x08, 0x00,
1514  0x0E, 0x00, 0x04, 0x00, 0x08, 0x00, 0x08, 0x00, 0x00, 0x00, 0x4C, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00,
1515  0x00, 0x00, 0x06, 0x00, 0x08, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, 0x00,
1516  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1517  0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
1518  0x0E, 0x00, 0x18, 0x00, 0x04, 0x00, 0x08, 0x00, 0x0C, 0x00, 0x10, 0x00, 0x14, 0x00, 0x0E, 0x00, 0x00, 0x00,
1519  0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x14, 0x00,
1520  0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x70, 0x61, 0x64, 0x00, 0x01, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00,
1521  0x01, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x08, 0x00, 0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x08, 0x00,
1522  0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x52, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x01, 0x08, 0x00, 0x00, 0x00,
1523  0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0x00,
1524  0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x08, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00,
1525  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x0C, 0x00, 0x07, 0x00, 0x08, 0x00, 0x08, 0x00,
1526  0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x04, 0x00, 0x00, 0x00, 0xF6, 0xFF, 0xFF, 0xFF, 0x0C, 0x00, 0x00, 0x00,
1527  0x00, 0x00, 0x06, 0x00, 0x0A, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00,
1528  0x0E, 0x00, 0x14, 0x00, 0x00, 0x00, 0x04, 0x00, 0x08, 0x00, 0x0C, 0x00, 0x10, 0x00, 0x0E, 0x00, 0x00, 0x00,
1529  0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
1530  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00,
1531  0x08, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
1532  0x0A, 0x00, 0x10, 0x00, 0x08, 0x00, 0x07, 0x00, 0x0C, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
1533  0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00,
1534  0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00
1535  };
1536 
1537  armnn::INetworkPtr deserializedNetwork = DeserializeNetwork(std::string(padModel.begin(), padModel.end()));
1538  BOOST_CHECK(deserializedNetwork);
1539 
1540  const armnn::TensorInfo inputInfo = armnn::TensorInfo({ 1, 2, 3, 4 }, armnn::DataType::Float32);
1541  const armnn::TensorInfo outputInfo = armnn::TensorInfo({ 1, 3, 5, 7 }, armnn::DataType::Float32);
1542 
1543  armnn::PadDescriptor descriptor({{ 0, 0 }, { 1, 0 }, { 1, 1 }, { 1, 2 }});
1544 
1545  LayerVerifierBaseWithDescriptor<armnn::PadDescriptor> verifier("pad", { inputInfo }, { outputInfo }, descriptor);
1546  deserializedNetwork->ExecuteStrategy(verifier);
1547 }
armnn::INetworkPtr DeserializeNetwork(const std::string &serializerString)
void ExecuteStrategy(const armnn::IConnectableLayer *layer, const armnn::BaseDescriptor &descriptor, const std::vector< armnn::ConstTensor > &constants, const char *name, const armnn::LayerBindingId id=0) override
A PadDescriptor for the PadLayer.
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:173

◆ BOOST_AUTO_TEST_CASE() [40/61]

BOOST_AUTO_TEST_CASE ( SerializePermute  )

Definition at line 1549 of file SerializerTests.cpp.

References IOutputSlot::Connect(), INetwork::Create(), DeserializeNetwork(), LayerVerifierBaseWithDescriptor< Descriptor >::ExecuteStrategy(), armnn::Float32, IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), SerializeNetwork(), and IOutputSlot::SetTensorInfo().

1550 {
1551  const std::string layerName("permute");
1552  const armnn::TensorInfo inputTensorInfo({4, 3, 2, 1}, armnn::DataType::Float32);
1553  const armnn::TensorInfo outputTensorInfo({1, 2, 3, 4}, armnn::DataType::Float32);
1554 
1555  armnn::PermuteDescriptor descriptor(armnn::PermutationVector({3, 2, 1, 0}));
1556 
1558  armnn::IConnectableLayer* const inputLayer = network->AddInputLayer(0);
1559  armnn::IConnectableLayer* const permuteLayer = network->AddPermuteLayer(descriptor, layerName.c_str());
1560  armnn::IConnectableLayer* const outputLayer = network->AddOutputLayer(0);
1561 
1562  inputLayer->GetOutputSlot(0).Connect(permuteLayer->GetInputSlot(0));
1563  permuteLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
1564 
1565  inputLayer->GetOutputSlot(0).SetTensorInfo(inputTensorInfo);
1566  permuteLayer->GetOutputSlot(0).SetTensorInfo(outputTensorInfo);
1567 
1568  armnn::INetworkPtr deserializedNetwork = DeserializeNetwork(SerializeNetwork(*network));
1569  BOOST_CHECK(deserializedNetwork);
1570 
1572  layerName, {inputTensorInfo}, {outputTensorInfo}, descriptor);
1573  deserializedNetwork->ExecuteStrategy(verifier);
1574 }
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition: INetwork.hpp:62
armnn::INetworkPtr DeserializeNetwork(const std::string &serializerString)
void ExecuteStrategy(const armnn::IConnectableLayer *layer, const armnn::BaseDescriptor &descriptor, const std::vector< armnn::ConstTensor > &constants, const char *name, const armnn::LayerBindingId id=0) override
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
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:173
virtual int Connect(IInputSlot &destination)=0
std::string SerializeNetwork(const armnn::INetwork &network)
static INetworkPtr Create(NetworkOptions networkOptions={})
Definition: Network.cpp:510
A PermuteDescriptor for the PermuteLayer.

◆ BOOST_AUTO_TEST_CASE() [41/61]

BOOST_AUTO_TEST_CASE ( SerializePooling2d  )

Definition at line 1576 of file SerializerTests.cpp.

References armnn::Average, IOutputSlot::Connect(), INetwork::Create(), DeserializeNetwork(), armnn::Exclude, LayerVerifierBaseWithDescriptor< Descriptor >::ExecuteStrategy(), armnn::Float32, armnn::Floor, IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), Pooling2dDescriptor::m_DataLayout, armnn::NHWC, SerializeNetwork(), and IOutputSlot::SetTensorInfo().

1577 {
1578  const std::string layerName("pooling2d");
1579  const armnn::TensorInfo inputInfo({1, 2, 2, 1}, armnn::DataType::Float32);
1580  const armnn::TensorInfo outputInfo({1, 1, 1, 1}, armnn::DataType::Float32);
1581 
1584  desc.m_PadTop = 0;
1585  desc.m_PadBottom = 0;
1586  desc.m_PadLeft = 0;
1587  desc.m_PadRight = 0;
1588  desc.m_PoolType = armnn::PoolingAlgorithm::Average;
1589  desc.m_OutputShapeRounding = armnn::OutputShapeRounding::Floor;
1590  desc.m_PaddingMethod = armnn::PaddingMethod::Exclude;
1591  desc.m_PoolHeight = 2;
1592  desc.m_PoolWidth = 2;
1593  desc.m_StrideX = 2;
1594  desc.m_StrideY = 2;
1595 
1597  armnn::IConnectableLayer* const inputLayer = network->AddInputLayer(0);
1598  armnn::IConnectableLayer* const pooling2dLayer = network->AddPooling2dLayer(desc, layerName.c_str());
1599  armnn::IConnectableLayer* const outputLayer = network->AddOutputLayer(0);
1600 
1601  inputLayer->GetOutputSlot(0).Connect(pooling2dLayer->GetInputSlot(0));
1602  pooling2dLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
1603 
1604  inputLayer->GetOutputSlot(0).SetTensorInfo(inputInfo);
1605  pooling2dLayer->GetOutputSlot(0).SetTensorInfo(outputInfo);
1606 
1607  armnn::INetworkPtr deserializedNetwork = DeserializeNetwork(SerializeNetwork(*network));
1608  BOOST_CHECK(deserializedNetwork);
1609 
1611  layerName, {inputInfo}, {outputInfo}, desc);
1612  deserializedNetwork->ExecuteStrategy(verifier);
1613 }
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition: INetwork.hpp:62
armnn::INetworkPtr DeserializeNetwork(const std::string &serializerString)
The padding fields don&#39;t count and are ignored.
void ExecuteStrategy(const armnn::IConnectableLayer *layer, const armnn::BaseDescriptor &descriptor, const std::vector< armnn::ConstTensor > &constants, const char *name, const armnn::LayerBindingId id=0) override
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
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:173
virtual int Connect(IInputSlot &destination)=0
A Pooling2dDescriptor for the Pooling2dLayer.
std::string SerializeNetwork(const armnn::INetwork &network)
static INetworkPtr Create(NetworkOptions networkOptions={})
Definition: Network.cpp:510

◆ BOOST_AUTO_TEST_CASE() [42/61]

BOOST_AUTO_TEST_CASE ( SerializeQuantize  )

Definition at line 1615 of file SerializerTests.cpp.

References IOutputSlot::Connect(), INetwork::Create(), DeserializeNetwork(), LayerVerifierBase::ExecuteStrategy(), armnn::Float32, IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), armnn::info, SerializeNetwork(), and IOutputSlot::SetTensorInfo().

1616 {
1617  const std::string layerName("quantize");
1618  const armnn::TensorInfo info({ 1, 2, 2, 3 }, armnn::DataType::Float32);
1619 
1621  armnn::IConnectableLayer* const inputLayer = network->AddInputLayer(0);
1622  armnn::IConnectableLayer* const quantizeLayer = network->AddQuantizeLayer(layerName.c_str());
1623  armnn::IConnectableLayer* const outputLayer = network->AddOutputLayer(0);
1624 
1625  inputLayer->GetOutputSlot(0).Connect(quantizeLayer->GetInputSlot(0));
1626  quantizeLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
1627 
1628  inputLayer->GetOutputSlot(0).SetTensorInfo(info);
1629  quantizeLayer->GetOutputSlot(0).SetTensorInfo(info);
1630 
1631  armnn::INetworkPtr deserializedNetwork = DeserializeNetwork(SerializeNetwork(*network));
1632  BOOST_CHECK(deserializedNetwork);
1633 
1634  LayerVerifierBase verifier(layerName, {info}, {info});
1635  deserializedNetwork->ExecuteStrategy(verifier);
1636 }
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition: INetwork.hpp:62
armnn::INetworkPtr DeserializeNetwork(const std::string &serializerString)
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
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:173
virtual int Connect(IInputSlot &destination)=0
std::string SerializeNetwork(const armnn::INetwork &network)
static INetworkPtr Create(NetworkOptions networkOptions={})
Definition: Network.cpp:510
void ExecuteStrategy(const armnn::IConnectableLayer *layer, const armnn::BaseDescriptor &descriptor, const std::vector< armnn::ConstTensor > &constants, const char *name, const armnn::LayerBindingId id=0) override

◆ BOOST_AUTO_TEST_CASE() [43/61]

BOOST_AUTO_TEST_CASE ( SerializeRank  )

Definition at line 1638 of file SerializerTests.cpp.

References IOutputSlot::Connect(), INetwork::Create(), DeserializeNetwork(), LayerVerifierBase::ExecuteStrategy(), armnn::Float32, IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), SerializeNetwork(), IOutputSlot::SetTensorInfo(), and armnn::Signed32.

1639 {
1640  const std::string layerName("rank");
1641  const armnn::TensorInfo inputInfo({1, 9}, armnn::DataType::Float32);
1642  const armnn::TensorInfo outputInfo({1}, armnn::DataType::Signed32);
1643 
1645  armnn::IConnectableLayer* const inputLayer = network->AddInputLayer(0);
1646  armnn::IConnectableLayer* const rankLayer = network->AddRankLayer(layerName.c_str());
1647  armnn::IConnectableLayer* const outputLayer = network->AddOutputLayer(0);
1648 
1649  inputLayer->GetOutputSlot(0).Connect(rankLayer->GetInputSlot(0));
1650  rankLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
1651 
1652  inputLayer->GetOutputSlot(0).SetTensorInfo(inputInfo);
1653  rankLayer->GetOutputSlot(0).SetTensorInfo(outputInfo);
1654 
1655  armnn::INetworkPtr deserializedNetwork = DeserializeNetwork(SerializeNetwork(*network));
1656  BOOST_CHECK(deserializedNetwork);
1657 
1658  LayerVerifierBase verifier(layerName, {inputInfo}, {outputInfo});
1659  deserializedNetwork->ExecuteStrategy(verifier);
1660 }
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition: INetwork.hpp:62
armnn::INetworkPtr DeserializeNetwork(const std::string &serializerString)
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
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:173
virtual int Connect(IInputSlot &destination)=0
std::string SerializeNetwork(const armnn::INetwork &network)
static INetworkPtr Create(NetworkOptions networkOptions={})
Definition: Network.cpp:510
void ExecuteStrategy(const armnn::IConnectableLayer *layer, const armnn::BaseDescriptor &descriptor, const std::vector< armnn::ConstTensor > &constants, const char *name, const armnn::LayerBindingId id=0) override

◆ BOOST_AUTO_TEST_CASE() [44/61]

BOOST_AUTO_TEST_CASE ( SerializeReduceSum  )

Definition at line 1662 of file SerializerTests.cpp.

References IOutputSlot::Connect(), INetwork::Create(), DeserializeNetwork(), LayerVerifierBaseWithDescriptor< Descriptor >::ExecuteStrategy(), armnn::Float32, IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), ReduceDescriptor::m_vAxis, SerializeNetwork(), IOutputSlot::SetTensorInfo(), and armnn::Sum.

1663 {
1664  const std::string layerName("Reduce_Sum");
1665  const armnn::TensorInfo inputInfo({1, 1, 3, 2}, armnn::DataType::Float32);
1666  const armnn::TensorInfo outputInfo({1, 1, 1, 2}, armnn::DataType::Float32);
1667 
1668  armnn::ReduceDescriptor descriptor;
1669  descriptor.m_vAxis = { 2 };
1670  descriptor.m_ReduceOperation = armnn::ReduceOperation::Sum;
1671 
1673  armnn::IConnectableLayer* const inputLayer = network->AddInputLayer(0);
1674  armnn::IConnectableLayer* const reduceSumLayer = network->AddReduceLayer(descriptor, layerName.c_str());
1675  armnn::IConnectableLayer* const outputLayer = network->AddOutputLayer(0);
1676 
1677  inputLayer->GetOutputSlot(0).Connect(reduceSumLayer->GetInputSlot(0));
1678  reduceSumLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
1679 
1680  inputLayer->GetOutputSlot(0).SetTensorInfo(inputInfo);
1681  reduceSumLayer->GetOutputSlot(0).SetTensorInfo(outputInfo);
1682 
1683  armnn::INetworkPtr deserializedNetwork = DeserializeNetwork(SerializeNetwork(*network));
1684  BOOST_CHECK(deserializedNetwork);
1685 
1686  LayerVerifierBaseWithDescriptor<armnn::ReduceDescriptor> verifier(layerName, {inputInfo}, {outputInfo}, descriptor);
1687  deserializedNetwork->ExecuteStrategy(verifier);
1688 }
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition: INetwork.hpp:62
armnn::INetworkPtr DeserializeNetwork(const std::string &serializerString)
void ExecuteStrategy(const armnn::IConnectableLayer *layer, const armnn::BaseDescriptor &descriptor, const std::vector< armnn::ConstTensor > &constants, const char *name, const armnn::LayerBindingId id=0) override
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
A ReduceDescriptor for the REDUCE operators.
std::vector< uint32_t > m_vAxis
The indices of the dimensions to reduce.
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:173
virtual int Connect(IInputSlot &destination)=0
std::string SerializeNetwork(const armnn::INetwork &network)
static INetworkPtr Create(NetworkOptions networkOptions={})
Definition: Network.cpp:510

◆ BOOST_AUTO_TEST_CASE() [45/61]

BOOST_AUTO_TEST_CASE ( SerializeReshape  )

Definition at line 1690 of file SerializerTests.cpp.

References IOutputSlot::Connect(), INetwork::Create(), DeserializeNetwork(), LayerVerifierBaseWithDescriptor< Descriptor >::ExecuteStrategy(), armnn::Float32, IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), SerializeNetwork(), and IOutputSlot::SetTensorInfo().

1691 {
1692  const std::string layerName("reshape");
1693  const armnn::TensorInfo inputInfo({1, 9}, armnn::DataType::Float32);
1694  const armnn::TensorInfo outputInfo({3, 3}, armnn::DataType::Float32);
1695 
1696  armnn::ReshapeDescriptor descriptor({3, 3});
1697 
1699  armnn::IConnectableLayer* const inputLayer = network->AddInputLayer(0);
1700  armnn::IConnectableLayer* const reshapeLayer = network->AddReshapeLayer(descriptor, layerName.c_str());
1701  armnn::IConnectableLayer* const outputLayer = network->AddOutputLayer(0);
1702 
1703  inputLayer->GetOutputSlot(0).Connect(reshapeLayer->GetInputSlot(0));
1704  reshapeLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
1705 
1706  inputLayer->GetOutputSlot(0).SetTensorInfo(inputInfo);
1707  reshapeLayer->GetOutputSlot(0).SetTensorInfo(outputInfo);
1708 
1709  armnn::INetworkPtr deserializedNetwork = DeserializeNetwork(SerializeNetwork(*network));
1710  BOOST_CHECK(deserializedNetwork);
1711 
1713  layerName, {inputInfo}, {outputInfo}, descriptor);
1714  deserializedNetwork->ExecuteStrategy(verifier);
1715 }
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition: INetwork.hpp:62
A ReshapeDescriptor for the ReshapeLayer.
armnn::INetworkPtr DeserializeNetwork(const std::string &serializerString)
void ExecuteStrategy(const armnn::IConnectableLayer *layer, const armnn::BaseDescriptor &descriptor, const std::vector< armnn::ConstTensor > &constants, const char *name, const armnn::LayerBindingId id=0) override
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
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:173
virtual int Connect(IInputSlot &destination)=0
std::string SerializeNetwork(const armnn::INetwork &network)
static INetworkPtr Create(NetworkOptions networkOptions={})
Definition: Network.cpp:510

◆ BOOST_AUTO_TEST_CASE() [46/61]

BOOST_AUTO_TEST_CASE ( SerializeResize  )

Definition at line 1717 of file SerializerTests.cpp.

References armnn::Bilinear, IOutputSlot::Connect(), INetwork::Create(), DeserializeNetwork(), LayerVerifierBaseWithDescriptor< Descriptor >::ExecuteStrategy(), armnn::Float32, IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), IConnectableLayer::GetType(), armnn::IgnoreUnused(), armnn::Input, ResizeDescriptor::m_AlignCorners, ResizeDescriptor::m_DataLayout, ResizeDescriptor::m_HalfPixelCenters, ResizeDescriptor::m_Method, ResizeDescriptor::m_TargetHeight, ResizeDescriptor::m_TargetWidth, armnn::NearestNeighbor, armnn::Output, armnn::Resize, SerializeNetwork(), and IOutputSlot::SetTensorInfo().

1718 {
1719  const std::string layerName("resize");
1720  const armnn::TensorInfo inputInfo = armnn::TensorInfo({1, 3, 5, 5}, armnn::DataType::Float32);
1721  const armnn::TensorInfo outputInfo = armnn::TensorInfo({1, 3, 2, 4}, armnn::DataType::Float32);
1722 
1724  desc.m_TargetWidth = 4;
1725  desc.m_TargetHeight = 2;
1726  desc.m_Method = armnn::ResizeMethod::NearestNeighbor;
1727  desc.m_AlignCorners = true;
1728  desc.m_HalfPixelCenters = true;
1729 
1731  armnn::IConnectableLayer* const inputLayer = network->AddInputLayer(0);
1732  armnn::IConnectableLayer* const resizeLayer = network->AddResizeLayer(desc, layerName.c_str());
1733  armnn::IConnectableLayer* const outputLayer = network->AddOutputLayer(0);
1734 
1735  inputLayer->GetOutputSlot(0).Connect(resizeLayer->GetInputSlot(0));
1736  resizeLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
1737 
1738  inputLayer->GetOutputSlot(0).SetTensorInfo(inputInfo);
1739  resizeLayer->GetOutputSlot(0).SetTensorInfo(outputInfo);
1740 
1741  armnn::INetworkPtr deserializedNetwork = DeserializeNetwork(SerializeNetwork(*network));
1742  BOOST_CHECK(deserializedNetwork);
1743 
1744  LayerVerifierBaseWithDescriptor<armnn::ResizeDescriptor> verifier(layerName, {inputInfo}, {outputInfo}, desc);
1745  deserializedNetwork->ExecuteStrategy(verifier);
1746 }
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition: INetwork.hpp:62
armnn::INetworkPtr DeserializeNetwork(const std::string &serializerString)
void ExecuteStrategy(const armnn::IConnectableLayer *layer, const armnn::BaseDescriptor &descriptor, const std::vector< armnn::ConstTensor > &constants, const char *name, const armnn::LayerBindingId id=0) override
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
A ResizeDescriptor for the ResizeLayer.
uint32_t m_TargetWidth
Target width value.
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:173
virtual int Connect(IInputSlot &destination)=0
std::string SerializeNetwork(const armnn::INetwork &network)
static INetworkPtr Create(NetworkOptions networkOptions={})
Definition: Network.cpp:510

◆ BOOST_AUTO_TEST_CASE() [47/61]

BOOST_AUTO_TEST_CASE ( SerializeResizeBilinear  )

Definition at line 1794 of file SerializerTests.cpp.

References ARMNN_NO_DEPRECATE_WARN_BEGIN, ARMNN_NO_DEPRECATE_WARN_END, IOutputSlot::Connect(), INetwork::Create(), DeserializeNetwork(), armnn::Float32, IConnectableLayer::GetOutputSlot(), ResizeBilinearDescriptor::m_TargetWidth, SerializeNetwork(), and IOutputSlot::SetTensorInfo().

1795 {
1796  const std::string layerName("resizeBilinear");
1797  const armnn::TensorInfo inputInfo = armnn::TensorInfo({1, 3, 5, 5}, armnn::DataType::Float32);
1798  const armnn::TensorInfo outputInfo = armnn::TensorInfo({1, 3, 2, 4}, armnn::DataType::Float32);
1799 
1801  desc.m_TargetWidth = 4u;
1802  desc.m_TargetHeight = 2u;
1803  desc.m_AlignCorners = true;
1804  desc.m_HalfPixelCenters = true;
1805 
1807  armnn::IConnectableLayer* const inputLayer = network->AddInputLayer(0);
1809  armnn::IConnectableLayer* const resizeLayer = network->AddResizeBilinearLayer(desc, layerName.c_str());
1811  armnn::IConnectableLayer* const outputLayer = network->AddOutputLayer(0);
1812 
1813  inputLayer->GetOutputSlot(0).Connect(resizeLayer->GetInputSlot(0));
1814  resizeLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
1815 
1816  inputLayer->GetOutputSlot(0).SetTensorInfo(inputInfo);
1817  resizeLayer->GetOutputSlot(0).SetTensorInfo(outputInfo);
1818 
1819  armnn::INetworkPtr deserializedNetwork = DeserializeNetwork(SerializeNetwork(*network));
1820  BOOST_CHECK(deserializedNetwork);
1821 
1822  ResizeBilinearLayerVerifier verifier(layerName, {inputInfo}, {outputInfo}, desc);
1823  deserializedNetwork->ExecuteStrategy(verifier);
1824 }
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition: INetwork.hpp:62
armnn::INetworkPtr DeserializeNetwork(const std::string &serializerString)
#define ARMNN_NO_DEPRECATE_WARN_BEGIN
Definition: Deprecated.hpp:33
uint32_t m_TargetWidth
Target width value.
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
#define ARMNN_NO_DEPRECATE_WARN_END
Definition: Deprecated.hpp:34
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:173
virtual int Connect(IInputSlot &destination)=0
std::string SerializeNetwork(const armnn::INetwork &network)
A ResizeBilinearDescriptor for the ResizeBilinearLayer.
static INetworkPtr Create(NetworkOptions networkOptions={})
Definition: Network.cpp:510

◆ BOOST_AUTO_TEST_CASE() [48/61]

BOOST_AUTO_TEST_CASE ( EnsureResizeBilinearBackwardCompatibility  )

Definition at line 1826 of file SerializerTests.cpp.

References DeserializeNetwork(), armnn::Float32, and ResizeBilinearDescriptor::m_TargetWidth.

1827 {
1828  // The hex data below is a flat buffer containing a simple network with an input,
1829  // a ResizeBilinearLayer (now deprecated) and an output
1830  //
1831  // This test verifies that we can still deserialize this old-style model by replacing
1832  // the ResizeBilinearLayer with an equivalent ResizeLayer
1833  const std::vector<uint8_t> resizeBilinearModel =
1834  {
1835  0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x10, 0x00, 0x04, 0x00, 0x08, 0x00, 0x0C, 0x00, 0x0A, 0x00,
1836  0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
1837  0x50, 0x01, 0x00, 0x00, 0x74, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
1838  0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xD4, 0xFE, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x0B,
1839  0x04, 0x00, 0x00, 0x00, 0xC2, 0xFE, 0xFF, 0xFF, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x08, 0x00,
1840  0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x8A, 0xFF, 0xFF, 0xFF, 0x02, 0x00, 0x00, 0x00,
1841  0x10, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00,
1842  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1843  0x38, 0xFF, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0xFF, 0xFF, 0xFF, 0x00, 0x00,
1844  0x00, 0x1A, 0x0C, 0x00, 0x00, 0x00, 0x08, 0x00, 0x0E, 0x00, 0x04, 0x00, 0x08, 0x00, 0x08, 0x00, 0x00, 0x00,
1845  0x34, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x12, 0x00, 0x08, 0x00, 0x0C, 0x00,
1846  0x07, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
1847  0x00, 0x00, 0x0E, 0x00, 0x18, 0x00, 0x04, 0x00, 0x08, 0x00, 0x0C, 0x00, 0x10, 0x00, 0x14, 0x00, 0x0E, 0x00,
1848  0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x00,
1849  0x20, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x72, 0x65, 0x73, 0x69, 0x7A, 0x65, 0x42, 0x69, 0x6C, 0x69,
1850  0x6E, 0x65, 0x61, 0x72, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
1851  0x0C, 0x00, 0x00, 0x00, 0x08, 0x00, 0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x04, 0x00,
1852  0x00, 0x00, 0x52, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x01, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1853  0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x04, 0x00,
1854  0x00, 0x00, 0x08, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1855  0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x0C, 0x00, 0x07, 0x00, 0x08, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
1856  0x00, 0x09, 0x04, 0x00, 0x00, 0x00, 0xF6, 0xFF, 0xFF, 0xFF, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00,
1857  0x0A, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x14, 0x00,
1858  0x00, 0x00, 0x04, 0x00, 0x08, 0x00, 0x0C, 0x00, 0x10, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
1859  0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1860  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x08, 0x00, 0x0A, 0x00,
1861  0x00, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x10, 0x00,
1862  0x08, 0x00, 0x07, 0x00, 0x0C, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x08, 0x00, 0x00, 0x00,
1863  0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0x00,
1864  0x00, 0x00, 0x05, 0x00, 0x00, 0x00
1865  };
1866 
1867  armnn::INetworkPtr deserializedNetwork =
1868  DeserializeNetwork(std::string(resizeBilinearModel.begin(), resizeBilinearModel.end()));
1869  BOOST_CHECK(deserializedNetwork);
1870 
1871  const armnn::TensorInfo inputInfo = armnn::TensorInfo({1, 3, 5, 5}, armnn::DataType::Float32);
1872  const armnn::TensorInfo outputInfo = armnn::TensorInfo({1, 3, 2, 4}, armnn::DataType::Float32);
1873 
1875  descriptor.m_TargetWidth = 4u;
1876  descriptor.m_TargetHeight = 2u;
1877 
1878  ResizeBilinearLayerVerifier verifier("resizeBilinear", { inputInfo }, { outputInfo }, descriptor);
1879  deserializedNetwork->ExecuteStrategy(verifier);
1880 }
armnn::INetworkPtr DeserializeNetwork(const std::string &serializerString)
uint32_t m_TargetWidth
Target width value.
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:173
A ResizeBilinearDescriptor for the ResizeBilinearLayer.

◆ BOOST_AUTO_TEST_CASE() [49/61]

BOOST_AUTO_TEST_CASE ( SerializeSlice  )

Definition at line 1882 of file SerializerTests.cpp.

References IOutputSlot::Connect(), INetwork::Create(), DeserializeNetwork(), LayerVerifierBaseWithDescriptor< Descriptor >::ExecuteStrategy(), armnn::Float32, IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), SerializeNetwork(), and IOutputSlot::SetTensorInfo().

1883 {
1884  const std::string layerName{"slice"};
1885 
1886  const armnn::TensorInfo inputInfo = armnn::TensorInfo({3, 2, 3, 1}, armnn::DataType::Float32);
1887  const armnn::TensorInfo outputInfo = armnn::TensorInfo({2, 2, 2, 1}, armnn::DataType::Float32);
1888 
1889  armnn::SliceDescriptor descriptor({ 0, 0, 1, 0}, {2, 2, 2, 1});
1890 
1892 
1893  armnn::IConnectableLayer* const inputLayer = network->AddInputLayer(0);
1894  armnn::IConnectableLayer* const sliceLayer = network->AddSliceLayer(descriptor, layerName.c_str());
1895  armnn::IConnectableLayer* const outputLayer = network->AddOutputLayer(0);
1896 
1897  inputLayer->GetOutputSlot(0).Connect(sliceLayer->GetInputSlot(0));
1898  sliceLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
1899 
1900  inputLayer->GetOutputSlot(0).SetTensorInfo(inputInfo);
1901  sliceLayer->GetOutputSlot(0).SetTensorInfo(outputInfo);
1902 
1903  armnn::INetworkPtr deserializedNetwork = DeserializeNetwork(SerializeNetwork(*network));
1904  BOOST_CHECK(deserializedNetwork);
1905 
1906  LayerVerifierBaseWithDescriptor<armnn::SliceDescriptor> verifier(layerName, {inputInfo}, {outputInfo}, descriptor);
1907  deserializedNetwork->ExecuteStrategy(verifier);
1908 }
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition: INetwork.hpp:62
armnn::INetworkPtr DeserializeNetwork(const std::string &serializerString)
void ExecuteStrategy(const armnn::IConnectableLayer *layer, const armnn::BaseDescriptor &descriptor, const std::vector< armnn::ConstTensor > &constants, const char *name, const armnn::LayerBindingId id=0) override
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
A SliceDescriptor for the SliceLayer.
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:173
virtual int Connect(IInputSlot &destination)=0
std::string SerializeNetwork(const armnn::INetwork &network)
static INetworkPtr Create(NetworkOptions networkOptions={})
Definition: Network.cpp:510

◆ BOOST_AUTO_TEST_CASE() [50/61]

BOOST_AUTO_TEST_CASE ( SerializeSoftmax  )

Definition at line 1910 of file SerializerTests.cpp.

References IOutputSlot::Connect(), INetwork::Create(), DeserializeNetwork(), LayerVerifierBaseWithDescriptor< Descriptor >::ExecuteStrategy(), armnn::Float32, IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), armnn::info, SoftmaxDescriptor::m_Beta, SerializeNetwork(), and IOutputSlot::SetTensorInfo().

1911 {
1912  const std::string layerName("softmax");
1914 
1915  armnn::SoftmaxDescriptor descriptor;
1916  descriptor.m_Beta = 1.0f;
1917 
1919  armnn::IConnectableLayer* const inputLayer = network->AddInputLayer(0);
1920  armnn::IConnectableLayer* const softmaxLayer = network->AddSoftmaxLayer(descriptor, layerName.c_str());
1921  armnn::IConnectableLayer* const outputLayer = network->AddOutputLayer(0);
1922 
1923  inputLayer->GetOutputSlot(0).Connect(softmaxLayer->GetInputSlot(0));
1924  softmaxLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
1925 
1926  inputLayer->GetOutputSlot(0).SetTensorInfo(info);
1927  softmaxLayer->GetOutputSlot(0).SetTensorInfo(info);
1928 
1929  armnn::INetworkPtr deserializedNetwork = DeserializeNetwork(SerializeNetwork(*network));
1930  BOOST_CHECK(deserializedNetwork);
1931 
1932  LayerVerifierBaseWithDescriptor<armnn::SoftmaxDescriptor> verifier(layerName, {info}, {info}, descriptor);
1933  deserializedNetwork->ExecuteStrategy(verifier);
1934 }
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition: INetwork.hpp:62
armnn::INetworkPtr DeserializeNetwork(const std::string &serializerString)
float m_Beta
Exponentiation value.
void ExecuteStrategy(const armnn::IConnectableLayer *layer, const armnn::BaseDescriptor &descriptor, const std::vector< armnn::ConstTensor > &constants, const char *name, const armnn::LayerBindingId id=0) override
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
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:173
virtual int Connect(IInputSlot &destination)=0
std::string SerializeNetwork(const armnn::INetwork &network)
static INetworkPtr Create(NetworkOptions networkOptions={})
Definition: Network.cpp:510
A SoftmaxDescriptor for the SoftmaxLayer.

◆ BOOST_AUTO_TEST_CASE() [51/61]

BOOST_AUTO_TEST_CASE ( SerializeSpaceToBatchNd  )

Definition at line 1936 of file SerializerTests.cpp.

References IOutputSlot::Connect(), INetwork::Create(), DeserializeNetwork(), LayerVerifierBaseWithDescriptor< Descriptor >::ExecuteStrategy(), armnn::Float32, IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), SpaceToBatchNdDescriptor::m_DataLayout, armnn::NCHW, SerializeNetwork(), and IOutputSlot::SetTensorInfo().

1937 {
1938  const std::string layerName("spaceToBatchNd");
1939  const armnn::TensorInfo inputInfo({2, 1, 2, 4}, armnn::DataType::Float32);
1940  const armnn::TensorInfo outputInfo({8, 1, 1, 3}, armnn::DataType::Float32);
1941 
1944  desc.m_BlockShape = {2, 2};
1945  desc.m_PadList = {{0, 0}, {2, 0}};
1946 
1948  armnn::IConnectableLayer* const inputLayer = network->AddInputLayer(0);
1949  armnn::IConnectableLayer* const spaceToBatchNdLayer = network->AddSpaceToBatchNdLayer(desc, layerName.c_str());
1950  armnn::IConnectableLayer* const outputLayer = network->AddOutputLayer(0);
1951 
1952  inputLayer->GetOutputSlot(0).Connect(spaceToBatchNdLayer->GetInputSlot(0));
1953  spaceToBatchNdLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
1954 
1955  inputLayer->GetOutputSlot(0).SetTensorInfo(inputInfo);
1956  spaceToBatchNdLayer->GetOutputSlot(0).SetTensorInfo(outputInfo);
1957 
1958  armnn::INetworkPtr deserializedNetwork = DeserializeNetwork(SerializeNetwork(*network));
1959  BOOST_CHECK(deserializedNetwork);
1960 
1962  layerName, {inputInfo}, {outputInfo}, desc);
1963  deserializedNetwork->ExecuteStrategy(verifier);
1964 }
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition: INetwork.hpp:62
armnn::INetworkPtr DeserializeNetwork(const std::string &serializerString)
void ExecuteStrategy(const armnn::IConnectableLayer *layer, const armnn::BaseDescriptor &descriptor, const std::vector< armnn::ConstTensor > &constants, const char *name, const armnn::LayerBindingId id=0) override
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
A SpaceToBatchNdDescriptor for the SpaceToBatchNdLayer.
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:173
virtual int Connect(IInputSlot &destination)=0
std::string SerializeNetwork(const armnn::INetwork &network)
static INetworkPtr Create(NetworkOptions networkOptions={})
Definition: Network.cpp:510

◆ BOOST_AUTO_TEST_CASE() [52/61]

BOOST_AUTO_TEST_CASE ( SerializeSpaceToDepth  )

Definition at line 1966 of file SerializerTests.cpp.

References IOutputSlot::Connect(), INetwork::Create(), DeserializeNetwork(), LayerVerifierBaseWithDescriptor< Descriptor >::ExecuteStrategy(), armnn::Float32, IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), SpaceToDepthDescriptor::m_BlockSize, armnn::NHWC, SerializeNetwork(), and IOutputSlot::SetTensorInfo().

1967 {
1968  const std::string layerName("spaceToDepth");
1969 
1970  const armnn::TensorInfo inputInfo ({ 1, 16, 8, 3 }, armnn::DataType::Float32);
1971  const armnn::TensorInfo outputInfo({ 1, 8, 4, 12 }, armnn::DataType::Float32);
1972 
1974  desc.m_BlockSize = 2;
1975  desc.m_DataLayout = armnn::DataLayout::NHWC;
1976 
1978  armnn::IConnectableLayer* const inputLayer = network->AddInputLayer(0);
1979  armnn::IConnectableLayer* const spaceToDepthLayer = network->AddSpaceToDepthLayer(desc, layerName.c_str());
1980  armnn::IConnectableLayer* const outputLayer = network->AddOutputLayer(0);
1981 
1982  inputLayer->GetOutputSlot(0).Connect(spaceToDepthLayer->GetInputSlot(0));
1983  spaceToDepthLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
1984 
1985  inputLayer->GetOutputSlot(0).SetTensorInfo(inputInfo);
1986  spaceToDepthLayer->GetOutputSlot(0).SetTensorInfo(outputInfo);
1987 
1988  armnn::INetworkPtr deserializedNetwork = DeserializeNetwork(SerializeNetwork(*network));
1989  BOOST_CHECK(deserializedNetwork);
1990 
1992  layerName, {inputInfo}, {outputInfo}, desc);
1993  deserializedNetwork->ExecuteStrategy(verifier);
1994 }
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition: INetwork.hpp:62
armnn::INetworkPtr DeserializeNetwork(const std::string &serializerString)
void ExecuteStrategy(const armnn::IConnectableLayer *layer, const armnn::BaseDescriptor &descriptor, const std::vector< armnn::ConstTensor > &constants, const char *name, const armnn::LayerBindingId id=0) override
A SpaceToDepthDescriptor for the SpaceToDepthLayer.
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
unsigned int m_BlockSize
Scalar specifying the input block size. It must be >= 1.
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:173
virtual int Connect(IInputSlot &destination)=0
std::string SerializeNetwork(const armnn::INetwork &network)
static INetworkPtr Create(NetworkOptions networkOptions={})
Definition: Network.cpp:510

◆ BOOST_AUTO_TEST_CASE() [53/61]

BOOST_AUTO_TEST_CASE ( SerializeSplitter  )

Definition at line 1996 of file SerializerTests.cpp.

References IOutputSlot::Connect(), INetwork::Create(), DeserializeNetwork(), LayerVerifierBaseWithDescriptor< Descriptor >::ExecuteStrategy(), armnn::Float32, IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), SerializeNetwork(), IOutputSlot::SetTensorInfo(), ViewsDescriptor::SetViewOriginCoord(), and ViewsDescriptor::SetViewSize().

1997 {
1998  const unsigned int numViews = 3;
1999  const unsigned int numDimensions = 4;
2000  const unsigned int inputShape[] = {1, 18, 4, 4};
2001  const unsigned int outputShape[] = {1, 6, 4, 4};
2002 
2003  // This is modelled on how the caffe parser sets up a splitter layer to partition an input along dimension one.
2004  unsigned int splitterDimSizes[4] = {static_cast<unsigned int>(inputShape[0]),
2005  static_cast<unsigned int>(inputShape[1]),
2006  static_cast<unsigned int>(inputShape[2]),
2007  static_cast<unsigned int>(inputShape[3])};
2008  splitterDimSizes[1] /= numViews;
2009  armnn::ViewsDescriptor desc(numViews, numDimensions);
2010 
2011  for (unsigned int g = 0; g < numViews; ++g)
2012  {
2013  desc.SetViewOriginCoord(g, 1, splitterDimSizes[1] * g);
2014 
2015  for (unsigned int dimIdx=0; dimIdx < 4; dimIdx++)
2016  {
2017  desc.SetViewSize(g, dimIdx, splitterDimSizes[dimIdx]);
2018  }
2019  }
2020 
2021  const std::string layerName("splitter");
2022  const armnn::TensorInfo inputInfo(numDimensions, inputShape, armnn::DataType::Float32);
2023  const armnn::TensorInfo outputInfo(numDimensions, outputShape, armnn::DataType::Float32);
2024 
2026  armnn::IConnectableLayer* const inputLayer = network->AddInputLayer(0);
2027  armnn::IConnectableLayer* const splitterLayer = network->AddSplitterLayer(desc, layerName.c_str());
2028  armnn::IConnectableLayer* const outputLayer0 = network->AddOutputLayer(0);
2029  armnn::IConnectableLayer* const outputLayer1 = network->AddOutputLayer(1);
2030  armnn::IConnectableLayer* const outputLayer2 = network->AddOutputLayer(2);
2031 
2032  inputLayer->GetOutputSlot(0).Connect(splitterLayer->GetInputSlot(0));
2033  splitterLayer->GetOutputSlot(0).Connect(outputLayer0->GetInputSlot(0));
2034  splitterLayer->GetOutputSlot(1).Connect(outputLayer1->GetInputSlot(0));
2035  splitterLayer->GetOutputSlot(2).Connect(outputLayer2->GetInputSlot(0));
2036 
2037  inputLayer->GetOutputSlot(0).SetTensorInfo(inputInfo);
2038  splitterLayer->GetOutputSlot(0).SetTensorInfo(outputInfo);
2039  splitterLayer->GetOutputSlot(1).SetTensorInfo(outputInfo);
2040  splitterLayer->GetOutputSlot(2).SetTensorInfo(outputInfo);
2041 
2042  armnn::INetworkPtr deserializedNetwork = DeserializeNetwork(SerializeNetwork(*network));
2043  BOOST_CHECK(deserializedNetwork);
2044 
2046  layerName, {inputInfo}, {outputInfo, outputInfo, outputInfo}, desc);
2047  deserializedNetwork->ExecuteStrategy(verifier);
2048 }
A ViewsDescriptor for the SplitterLayer.
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition: INetwork.hpp:62
armnn::INetworkPtr DeserializeNetwork(const std::string &serializerString)
void ExecuteStrategy(const armnn::IConnectableLayer *layer, const armnn::BaseDescriptor &descriptor, const std::vector< armnn::ConstTensor > &constants, const char *name, const armnn::LayerBindingId id=0) override
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
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:173
virtual int Connect(IInputSlot &destination)=0
std::string SerializeNetwork(const armnn::INetwork &network)
static INetworkPtr Create(NetworkOptions networkOptions={})
Definition: Network.cpp:510

◆ BOOST_AUTO_TEST_CASE() [54/61]

BOOST_AUTO_TEST_CASE ( SerializeStack  )

Definition at line 2050 of file SerializerTests.cpp.

References IOutputSlot::Connect(), INetwork::Create(), DeserializeNetwork(), LayerVerifierBaseWithDescriptor< Descriptor >::ExecuteStrategy(), armnn::Float32, IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), SerializeNetwork(), and IOutputSlot::SetTensorInfo().

2051 {
2052  const std::string layerName("stack");
2053 
2054  armnn::TensorInfo inputTensorInfo ({4, 3, 5}, armnn::DataType::Float32);
2055  armnn::TensorInfo outputTensorInfo({4, 3, 2, 5}, armnn::DataType::Float32);
2056 
2057  armnn::StackDescriptor descriptor(2, 2, {4, 3, 5});
2058 
2060  armnn::IConnectableLayer* const inputLayer1 = network->AddInputLayer(0);
2061  armnn::IConnectableLayer* const inputLayer2 = network->AddInputLayer(1);
2062  armnn::IConnectableLayer* const stackLayer = network->AddStackLayer(descriptor, layerName.c_str());
2063  armnn::IConnectableLayer* const outputLayer = network->AddOutputLayer(0);
2064 
2065  inputLayer1->GetOutputSlot(0).Connect(stackLayer->GetInputSlot(0));
2066  inputLayer2->GetOutputSlot(0).Connect(stackLayer->GetInputSlot(1));
2067  stackLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
2068 
2069  inputLayer1->GetOutputSlot(0).SetTensorInfo(inputTensorInfo);
2070  inputLayer2->GetOutputSlot(0).SetTensorInfo(inputTensorInfo);
2071  stackLayer->GetOutputSlot(0).SetTensorInfo(outputTensorInfo);
2072 
2073  armnn::INetworkPtr deserializedNetwork = DeserializeNetwork(SerializeNetwork(*network));
2074  BOOST_CHECK(deserializedNetwork);
2075 
2077  layerName, {inputTensorInfo, inputTensorInfo}, {outputTensorInfo}, descriptor);
2078  deserializedNetwork->ExecuteStrategy(verifier);
2079 }
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition: INetwork.hpp:62
armnn::INetworkPtr DeserializeNetwork(const std::string &serializerString)
void ExecuteStrategy(const armnn::IConnectableLayer *layer, const armnn::BaseDescriptor &descriptor, const std::vector< armnn::ConstTensor > &constants, const char *name, const armnn::LayerBindingId id=0) override
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
A StackDescriptor for the StackLayer.
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:173
virtual int Connect(IInputSlot &destination)=0
std::string SerializeNetwork(const armnn::INetwork &network)
static INetworkPtr Create(NetworkOptions networkOptions={})
Definition: Network.cpp:510

◆ BOOST_AUTO_TEST_CASE() [55/61]

BOOST_AUTO_TEST_CASE ( SerializeStandIn  )

Definition at line 2081 of file SerializerTests.cpp.

References IOutputSlot::Connect(), INetwork::Create(), DeserializeNetwork(), LayerVerifierBaseWithDescriptor< Descriptor >::ExecuteStrategy(), armnn::Float32, IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), SerializeNetwork(), and IOutputSlot::SetTensorInfo().

2082 {
2083  const std::string layerName("standIn");
2084 
2085  armnn::TensorInfo tensorInfo({ 1u }, armnn::DataType::Float32);
2086  armnn::StandInDescriptor descriptor(2u, 2u);
2087 
2089  armnn::IConnectableLayer* const inputLayer0 = network->AddInputLayer(0);
2090  armnn::IConnectableLayer* const inputLayer1 = network->AddInputLayer(1);
2091  armnn::IConnectableLayer* const standInLayer = network->AddStandInLayer(descriptor, layerName.c_str());
2092  armnn::IConnectableLayer* const outputLayer0 = network->AddOutputLayer(0);
2093  armnn::IConnectableLayer* const outputLayer1 = network->AddOutputLayer(1);
2094 
2095  inputLayer0->GetOutputSlot(0).Connect(standInLayer->GetInputSlot(0));
2096  inputLayer0->GetOutputSlot(0).SetTensorInfo(tensorInfo);
2097 
2098  inputLayer1->GetOutputSlot(0).Connect(standInLayer->GetInputSlot(1));
2099  inputLayer1->GetOutputSlot(0).SetTensorInfo(tensorInfo);
2100 
2101  standInLayer->GetOutputSlot(0).Connect(outputLayer0->GetInputSlot(0));
2102  standInLayer->GetOutputSlot(0).SetTensorInfo(tensorInfo);
2103 
2104  standInLayer->GetOutputSlot(1).Connect(outputLayer1->GetInputSlot(0));
2105  standInLayer->GetOutputSlot(1).SetTensorInfo(tensorInfo);
2106 
2107  armnn::INetworkPtr deserializedNetwork = DeserializeNetwork(SerializeNetwork(*network));
2108  BOOST_CHECK(deserializedNetwork);
2109 
2111  layerName, { tensorInfo, tensorInfo }, { tensorInfo, tensorInfo }, descriptor);
2112  deserializedNetwork->ExecuteStrategy(verifier);
2113 }
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition: INetwork.hpp:62
armnn::INetworkPtr DeserializeNetwork(const std::string &serializerString)
void ExecuteStrategy(const armnn::IConnectableLayer *layer, const armnn::BaseDescriptor &descriptor, const std::vector< armnn::ConstTensor > &constants, const char *name, const armnn::LayerBindingId id=0) override
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
A StandInDescriptor for the StandIn layer.
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:173
virtual int Connect(IInputSlot &destination)=0
std::string SerializeNetwork(const armnn::INetwork &network)
static INetworkPtr Create(NetworkOptions networkOptions={})
Definition: Network.cpp:510

◆ BOOST_AUTO_TEST_CASE() [56/61]

BOOST_AUTO_TEST_CASE ( SerializeStridedSlice  )

Definition at line 2115 of file SerializerTests.cpp.

References IOutputSlot::Connect(), INetwork::Create(), DeserializeNetwork(), LayerVerifierBaseWithDescriptor< Descriptor >::ExecuteStrategy(), armnn::Float32, IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), StridedSliceDescriptor::m_EndMask, armnn::NCHW, SerializeNetwork(), and IOutputSlot::SetTensorInfo().

2116 {
2117  const std::string layerName("stridedSlice");
2118  const armnn::TensorInfo inputInfo = armnn::TensorInfo({3, 2, 3, 1}, armnn::DataType::Float32);
2119  const armnn::TensorInfo outputInfo = armnn::TensorInfo({3, 1}, armnn::DataType::Float32);
2120 
2121  armnn::StridedSliceDescriptor desc({0, 0, 1, 0}, {1, 1, 1, 1}, {1, 1, 1, 1});
2122  desc.m_EndMask = (1 << 4) - 1;
2123  desc.m_ShrinkAxisMask = (1 << 1) | (1 << 2);
2124  desc.m_DataLayout = armnn::DataLayout::NCHW;
2125 
2127  armnn::IConnectableLayer* const inputLayer = network->AddInputLayer(0);
2128  armnn::IConnectableLayer* const stridedSliceLayer = network->AddStridedSliceLayer(desc, layerName.c_str());
2129  armnn::IConnectableLayer* const outputLayer = network->AddOutputLayer(0);
2130 
2131  inputLayer->GetOutputSlot(0).Connect(stridedSliceLayer->GetInputSlot(0));
2132  stridedSliceLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
2133 
2134  inputLayer->GetOutputSlot(0).SetTensorInfo(inputInfo);
2135  stridedSliceLayer->GetOutputSlot(0).SetTensorInfo(outputInfo);
2136 
2137  armnn::INetworkPtr deserializedNetwork = DeserializeNetwork(SerializeNetwork(*network));
2138  BOOST_CHECK(deserializedNetwork);
2139 
2141  layerName, {inputInfo}, {outputInfo}, desc);
2142  deserializedNetwork->ExecuteStrategy(verifier);
2143 }
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition: INetwork.hpp:62
armnn::INetworkPtr DeserializeNetwork(const std::string &serializerString)
void ExecuteStrategy(const armnn::IConnectableLayer *layer, const armnn::BaseDescriptor &descriptor, const std::vector< armnn::ConstTensor > &constants, const char *name, const armnn::LayerBindingId id=0) override
int32_t m_EndMask
End mask value.
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
virtual const IInputSlot & GetInputSlot(unsigned int index) const =0
Get a const input slot handle by slot index.
A StridedSliceDescriptor for the StridedSliceLayer.
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:173
virtual int Connect(IInputSlot &destination)=0
std::string SerializeNetwork(const armnn::INetwork &network)
static INetworkPtr Create(NetworkOptions networkOptions={})
Definition: Network.cpp:510

◆ BOOST_AUTO_TEST_CASE() [57/61]

BOOST_AUTO_TEST_CASE ( SerializeSubtraction  )

Definition at line 2145 of file SerializerTests.cpp.

References IOutputSlot::Connect(), INetwork::Create(), DeserializeNetwork(), LayerVerifierBase::ExecuteStrategy(), armnn::Float32, IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), armnn::info, SerializeNetwork(), and IOutputSlot::SetTensorInfo().

2146 {
2147  const std::string layerName("subtraction");
2149 
2151  armnn::IConnectableLayer* const inputLayer0 = network->AddInputLayer(0);
2152  armnn::IConnectableLayer* const inputLayer1 = network->AddInputLayer(1);
2153  armnn::IConnectableLayer* const subtractionLayer = network->AddSubtractionLayer(layerName.c_str());
2154  armnn::IConnectableLayer* const outputLayer = network->AddOutputLayer(0);
2155 
2156  inputLayer0->GetOutputSlot(0).Connect(subtractionLayer->GetInputSlot(0));
2157  inputLayer1->GetOutputSlot(0).Connect(subtractionLayer->GetInputSlot(1));
2158  subtractionLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
2159 
2160  inputLayer0->GetOutputSlot(0).SetTensorInfo(info);
2161  inputLayer1->GetOutputSlot(0).SetTensorInfo(info);
2162  subtractionLayer->GetOutputSlot(0).SetTensorInfo(info);
2163 
2164  armnn::INetworkPtr deserializedNetwork = DeserializeNetwork(SerializeNetwork(*network));
2165  BOOST_CHECK(deserializedNetwork);
2166 
2167  LayerVerifierBase verifier(layerName, {info, info}, {info});
2168  deserializedNetwork->ExecuteStrategy(verifier);
2169 }
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition: INetwork.hpp:62
armnn::INetworkPtr DeserializeNetwork(const std::string &serializerString)
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
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:173
virtual int Connect(IInputSlot &destination)=0
std::string SerializeNetwork(const armnn::INetwork &network)
static INetworkPtr Create(NetworkOptions networkOptions={})
Definition: Network.cpp:510
void ExecuteStrategy(const armnn::IConnectableLayer *layer, const armnn::BaseDescriptor &descriptor, const std::vector< armnn::ConstTensor > &constants, const char *name, const armnn::LayerBindingId id=0) override

◆ BOOST_AUTO_TEST_CASE() [58/61]

BOOST_AUTO_TEST_CASE ( SerializeSwitch  )

Definition at line 2171 of file SerializerTests.cpp.

References IOutputSlot::Connect(), armnn::Constant, INetwork::Create(), DeserializeNetwork(), armnn::Float32, IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), IConnectableLayer::GetType(), armnn::IgnoreUnused(), armnn::info, armnn::Input, armnn::Output, SerializeNetwork(), IOutputSlot::SetTensorInfo(), and armnn::Switch.

2172 {
2173  class SwitchLayerVerifier : public LayerVerifierBase
2174  {
2175  public:
2176  SwitchLayerVerifier(const std::string& layerName,
2177  const std::vector<armnn::TensorInfo>& inputInfos,
2178  const std::vector<armnn::TensorInfo>& outputInfos)
2179  : LayerVerifierBase(layerName, inputInfos, outputInfos) {}
2180 
2181  void ExecuteStrategy(const armnn::IConnectableLayer* layer,
2182  const armnn::BaseDescriptor& descriptor,
2183  const std::vector<armnn::ConstTensor>& constants,
2184  const char* name,
2185  const armnn::LayerBindingId id = 0) override
2186  {
2187  armnn::IgnoreUnused(descriptor, constants, id);
2188  switch (layer->GetType())
2189  {
2190  case armnn::LayerType::Input: break;
2191  case armnn::LayerType::Output: break;
2192  case armnn::LayerType::Constant: break;
2194  {
2195  VerifyNameAndConnections(layer, name);
2196  break;
2197  }
2198  default:
2199  {
2200  throw armnn::Exception("Unexpected layer type in Switch test model");
2201  }
2202  }
2203  }
2204  };
2205 
2206  const std::string layerName("switch");
2208 
2209  std::vector<float> constantData = GenerateRandomData<float>(info.GetNumElements());
2210  armnn::ConstTensor constTensor(info, constantData);
2211 
2213  armnn::IConnectableLayer* const inputLayer = network->AddInputLayer(0);
2214  armnn::IConnectableLayer* const constantLayer = network->AddConstantLayer(constTensor, "constant");
2215  armnn::IConnectableLayer* const switchLayer = network->AddSwitchLayer(layerName.c_str());
2216  armnn::IConnectableLayer* const trueOutputLayer = network->AddOutputLayer(0);
2217  armnn::IConnectableLayer* const falseOutputLayer = network->AddOutputLayer(1);
2218 
2219  inputLayer->GetOutputSlot(0).Connect(switchLayer->GetInputSlot(0));
2220  constantLayer->GetOutputSlot(0).Connect(switchLayer->GetInputSlot(1));
2221  switchLayer->GetOutputSlot(0).Connect(trueOutputLayer->GetInputSlot(0));
2222  switchLayer->GetOutputSlot(1).Connect(falseOutputLayer->GetInputSlot(0));
2223 
2224  inputLayer->GetOutputSlot(0).SetTensorInfo(info);
2225  constantLayer->GetOutputSlot(0).SetTensorInfo(info);
2226  switchLayer->GetOutputSlot(0).SetTensorInfo(info);
2227  switchLayer->GetOutputSlot(1).SetTensorInfo(info);
2228 
2229  armnn::INetworkPtr deserializedNetwork = DeserializeNetwork(SerializeNetwork(*network));
2230  BOOST_CHECK(deserializedNetwork);
2231 
2232  SwitchLayerVerifier verifier(layerName, {info, info}, {info, info});
2233  deserializedNetwork->ExecuteStrategy(verifier);
2234 }
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition: INetwork.hpp:62
armnn::INetworkPtr DeserializeNetwork(const std::string &serializerString)
void IgnoreUnused(Ts &&...)
int LayerBindingId
Type of identifiers for bindable layers (inputs, outputs).
Definition: Types.hpp:210
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
Base class for all descriptors.
Definition: Descriptors.hpp:22
void VerifyNameAndConnections(const armnn::IConnectableLayer *layer, const char *name)
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
Definition: Tensor.hpp:314
virtual LayerType GetType() const =0
Returns the armnn::LayerType of this layer.
Base class for all ArmNN exceptions so that users can filter to just those.
Definition: Exceptions.hpp:46
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:173
virtual int Connect(IInputSlot &destination)=0
std::string SerializeNetwork(const armnn::INetwork &network)
static INetworkPtr Create(NetworkOptions networkOptions={})
Definition: Network.cpp:510
void ExecuteStrategy(const armnn::IConnectableLayer *layer, const armnn::BaseDescriptor &descriptor, const std::vector< armnn::ConstTensor > &constants, const char *name, const armnn::LayerBindingId id=0) override

◆ BOOST_AUTO_TEST_CASE() [59/61]

BOOST_AUTO_TEST_CASE ( SerializeTranspose  )

Definition at line 2236 of file SerializerTests.cpp.

References IOutputSlot::Connect(), INetwork::Create(), DeserializeNetwork(), LayerVerifierBaseWithDescriptor< Descriptor >::ExecuteStrategy(), armnn::Float32, IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), SerializeNetwork(), and IOutputSlot::SetTensorInfo().

2237 {
2238  const std::string layerName("transpose");
2239  const armnn::TensorInfo inputTensorInfo({4, 3, 2, 1}, armnn::DataType::Float32);
2240  const armnn::TensorInfo outputTensorInfo({1, 2, 3, 4}, armnn::DataType::Float32);
2241 
2242  armnn::TransposeDescriptor descriptor(armnn::PermutationVector({3, 2, 1, 0}));
2243 
2245  armnn::IConnectableLayer* const inputLayer = network->AddInputLayer(0);
2246  armnn::IConnectableLayer* const transposeLayer = network->AddTransposeLayer(descriptor, layerName.c_str());
2247  armnn::IConnectableLayer* const outputLayer = network->AddOutputLayer(0);
2248 
2249  inputLayer->GetOutputSlot(0).Connect(transposeLayer->GetInputSlot(0));
2250  transposeLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
2251 
2252  inputLayer->GetOutputSlot(0).SetTensorInfo(inputTensorInfo);
2253  transposeLayer->GetOutputSlot(0).SetTensorInfo(outputTensorInfo);
2254 
2255  armnn::INetworkPtr deserializedNetwork = DeserializeNetwork(SerializeNetwork(*network));
2256  BOOST_CHECK(deserializedNetwork);
2257 
2259  layerName, {inputTensorInfo}, {outputTensorInfo}, descriptor);
2260  deserializedNetwork->ExecuteStrategy(verifier);
2261 }
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition: INetwork.hpp:62
armnn::INetworkPtr DeserializeNetwork(const std::string &serializerString)
void ExecuteStrategy(const armnn::IConnectableLayer *layer, const armnn::BaseDescriptor &descriptor, const std::vector< armnn::ConstTensor > &constants, const char *name, const armnn::LayerBindingId id=0) override
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
virtual const IInputSlot & GetInputSlot(unsigned int index) const =0
Get a const input slot handle by slot index.
A TransposeDescriptor for the TransposeLayer.
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:173
virtual int Connect(IInputSlot &destination)=0
std::string SerializeNetwork(const armnn::INetwork &network)
static INetworkPtr Create(NetworkOptions networkOptions={})
Definition: Network.cpp:510

◆ BOOST_AUTO_TEST_CASE() [60/61]

BOOST_AUTO_TEST_CASE ( SerializeTransposeConvolution2d  )

Definition at line 2263 of file SerializerTests.cpp.

References IOutputSlot::Connect(), INetwork::Create(), DeserializeNetwork(), LayerVerifierBaseWithDescriptorAndConstants< Descriptor >::ExecuteStrategy(), armnn::Float32, IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), TransposeConvolution2dDescriptor::m_BiasEnabled, TransposeConvolution2dDescriptor::m_DataLayout, TransposeConvolution2dDescriptor::m_PadBottom, TransposeConvolution2dDescriptor::m_PadLeft, TransposeConvolution2dDescriptor::m_PadRight, TransposeConvolution2dDescriptor::m_PadTop, TransposeConvolution2dDescriptor::m_StrideX, TransposeConvolution2dDescriptor::m_StrideY, armnn::NHWC, SerializeNetwork(), and IOutputSlot::SetTensorInfo().

2264 {
2265  const std::string layerName("transposeConvolution2d");
2266  const armnn::TensorInfo inputInfo ({ 1, 7, 7, 1 }, armnn::DataType::Float32);
2267  const armnn::TensorInfo outputInfo({ 1, 9, 9, 1 }, armnn::DataType::Float32);
2268 
2269  const armnn::TensorInfo weightsInfo({ 1, 3, 3, 1 }, armnn::DataType::Float32);
2270  const armnn::TensorInfo biasesInfo ({ 1 }, armnn::DataType::Float32);
2271 
2272  std::vector<float> weightsData = GenerateRandomData<float>(weightsInfo.GetNumElements());
2273  armnn::ConstTensor weights(weightsInfo, weightsData);
2274 
2275  std::vector<float> biasesData = GenerateRandomData<float>(biasesInfo.GetNumElements());
2276  armnn::ConstTensor biases(biasesInfo, biasesData);
2277 
2279  descriptor.m_PadLeft = 1;
2280  descriptor.m_PadRight = 1;
2281  descriptor.m_PadTop = 1;
2282  descriptor.m_PadBottom = 1;
2283  descriptor.m_StrideX = 1;
2284  descriptor.m_StrideY = 1;
2285  descriptor.m_BiasEnabled = true;
2287 
2289  armnn::IConnectableLayer* const inputLayer = network->AddInputLayer(0);
2290  armnn::IConnectableLayer* const convLayer =
2291  network->AddTransposeConvolution2dLayer(descriptor,
2292  weights,
2294  layerName.c_str());
2295  armnn::IConnectableLayer* const outputLayer = network->AddOutputLayer(0);
2296 
2297  inputLayer->GetOutputSlot(0).Connect(convLayer->GetInputSlot(0));
2298  convLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
2299 
2300  inputLayer->GetOutputSlot(0).SetTensorInfo(inputInfo);
2301  convLayer->GetOutputSlot(0).SetTensorInfo(outputInfo);
2302 
2303  armnn::INetworkPtr deserializedNetwork = DeserializeNetwork(SerializeNetwork(*network));
2304  BOOST_CHECK(deserializedNetwork);
2305 
2306  const std::vector<armnn::ConstTensor> constants {weights, biases};
2308  layerName, {inputInfo}, {outputInfo}, descriptor, constants);
2309  deserializedNetwork->ExecuteStrategy(verifier);
2310 }
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition: INetwork.hpp:62
A TransposeConvolution2dDescriptor for the TransposeConvolution2dLayer.
armnn::INetworkPtr DeserializeNetwork(const std::string &serializerString)
bool m_BiasEnabled
Enable/disable bias.
uint32_t m_PadBottom
Padding bottom value in the height dimension.
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
void ExecuteStrategy(const armnn::IConnectableLayer *layer, const armnn::BaseDescriptor &descriptor, const std::vector< armnn::ConstTensor > &constants, const char *name, const armnn::LayerBindingId id=0) override
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
Definition: Tensor.hpp:314
uint32_t m_PadTop
Padding top value in the height dimension.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
uint32_t m_PadLeft
Padding left value in the width dimension.
uint32_t m_StrideX
Stride value when proceeding through input for the width dimension.
uint32_t m_StrideY
Stride value when proceeding through input for the height dimension.
virtual const IInputSlot & GetInputSlot(unsigned int index) const =0
Get a const input slot handle by slot index.
uint32_t m_PadRight
Padding right value in the width dimension.
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:173
virtual int Connect(IInputSlot &destination)=0
std::string SerializeNetwork(const armnn::INetwork &network)
static INetworkPtr Create(NetworkOptions networkOptions={})
Definition: Network.cpp:510

◆ BOOST_AUTO_TEST_CASE() [61/61]

BOOST_AUTO_TEST_CASE ( SerializeDeserializeNonLinearNetwork  )

Definition at line 2312 of file SerializerTests.cpp.

References armnn::Addition, BOOST_AUTO_TEST_SUITE_END(), CompareConstTensor(), IOutputSlot::Connect(), armnn::Constant, INetwork::Create(), DeserializeNetwork(), armnn::Float32, IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), IConnectableLayer::GetType(), armnn::IgnoreUnused(), armnn::info, armnn::Input, armnn::Output, SerializeNetwork(), and IOutputSlot::SetTensorInfo().

2313 {
2314  class ConstantLayerVerifier : public LayerVerifierBase
2315  {
2316  public:
2317  ConstantLayerVerifier(const std::string& layerName,
2318  const std::vector<armnn::TensorInfo>& inputInfos,
2319  const std::vector<armnn::TensorInfo>& outputInfos,
2320  const armnn::ConstTensor& layerInput)
2321  : LayerVerifierBase(layerName, inputInfos, outputInfos)
2322  , m_LayerInput(layerInput) {}
2323 
2324  void ExecuteStrategy(const armnn::IConnectableLayer* layer,
2325  const armnn::BaseDescriptor& descriptor,
2326  const std::vector<armnn::ConstTensor>& constants,
2327  const char* name,
2328  const armnn::LayerBindingId id = 0) override
2329  {
2330  armnn::IgnoreUnused(descriptor, constants, id);
2331  switch (layer->GetType())
2332  {
2333  case armnn::LayerType::Input: break;
2334  case armnn::LayerType::Output: break;
2335  case armnn::LayerType::Addition: break;
2337  {
2338  VerifyNameAndConnections(layer, name);
2339  CompareConstTensor(constants.at(0), m_LayerInput);
2340  break;
2341  }
2342  default:
2343  {
2344  throw armnn::Exception("Unexpected layer type in test model");
2345  }
2346  }
2347  }
2348 
2349  private:
2350  armnn::ConstTensor m_LayerInput;
2351  };
2352 
2353  const std::string layerName("constant");
2355 
2356  std::vector<float> constantData = GenerateRandomData<float>(info.GetNumElements());
2357  armnn::ConstTensor constTensor(info, constantData);
2358 
2360  armnn::IConnectableLayer* input = network->AddInputLayer(0);
2361  armnn::IConnectableLayer* add = network->AddAdditionLayer();
2362  armnn::IConnectableLayer* constant = network->AddConstantLayer(constTensor, layerName.c_str());
2363  armnn::IConnectableLayer* output = network->AddOutputLayer(0);
2364 
2365  input->GetOutputSlot(0).Connect(add->GetInputSlot(0));
2366  constant->GetOutputSlot(0).Connect(add->GetInputSlot(1));
2367  add->GetOutputSlot(0).Connect(output->GetInputSlot(0));
2368 
2369  input->GetOutputSlot(0).SetTensorInfo(info);
2370  constant->GetOutputSlot(0).SetTensorInfo(info);
2371  add->GetOutputSlot(0).SetTensorInfo(info);
2372 
2373  armnn::INetworkPtr deserializedNetwork = DeserializeNetwork(SerializeNetwork(*network));
2374  BOOST_CHECK(deserializedNetwork);
2375 
2376  ConstantLayerVerifier verifier(layerName, {}, {info}, constTensor);
2377  deserializedNetwork->ExecuteStrategy(verifier);
2378 }
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition: INetwork.hpp:62
armnn::INetworkPtr DeserializeNetwork(const std::string &serializerString)
void IgnoreUnused(Ts &&...)
int LayerBindingId
Type of identifiers for bindable layers (inputs, outputs).
Definition: Types.hpp:210
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
Base class for all descriptors.
Definition: Descriptors.hpp:22
void VerifyNameAndConnections(const armnn::IConnectableLayer *layer, const char *name)
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
Definition: Tensor.hpp:314
virtual LayerType GetType() const =0
Returns the armnn::LayerType of this layer.
Base class for all ArmNN exceptions so that users can filter to just those.
Definition: Exceptions.hpp:46
void CompareConstTensor(const armnn::ConstTensor &tensor1, const armnn::ConstTensor &tensor2)
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:173
virtual int Connect(IInputSlot &destination)=0
std::string SerializeNetwork(const armnn::INetwork &network)
static INetworkPtr Create(NetworkOptions networkOptions={})
Definition: Network.cpp:510
void ExecuteStrategy(const armnn::IConnectableLayer *layer, const armnn::BaseDescriptor &descriptor, const std::vector< armnn::ConstTensor > &constants, const char *name, const armnn::LayerBindingId id=0) override