17 TEST_CASE(
"SerializeToDot")
23 auto input = net->AddInputLayer(0);
24 auto add = net->AddAdditionLayer();
25 auto output = net->AddOutputLayer(0);
28 input->GetOutputSlot(0).Connect(add->GetInputSlot(0));
29 input->GetOutputSlot(0).Connect(add->GetInputSlot(1));
30 add->GetOutputSlot(0).Connect(output->GetInputSlot(0));
34 input->GetOutputSlot(0).SetTensorInfo(info);
35 add->GetOutputSlot(0).SetTensorInfo(info);
43 std::ostringstream ss;
44 optimizedNet->SerializeToDot(ss);
46 auto inputId = input->GetGuid();
47 auto addId = add->GetGuid();
48 auto outputId = output->GetGuid();
50 std::stringstream expected;
52 "digraph Optimized {\n" 53 " node [shape=\"record\"];\n" 54 " edge [fontsize=8 fontcolor=\"blue\" fontname=\"arial-bold\"];\n" 55 " " << inputId <<
" [label=\"{Input|Guid : " << inputId <<
"\\lLayerType : Input\\l" 56 "BackendID : CpuRef\\l}\"];\n" 57 " " << addId <<
" [label=\"{Addition|Guid : " << addId <<
"\\lLayerType : Addition\\l" 58 "BackendID : CpuRef\\l}\"];\n" 59 " " << outputId <<
" [label=\"{Output|Guid : " << outputId <<
"\\lLayerType : Output\\l" 60 "BackendID : CpuRef\\l}\"];\n" 61 " " << inputId <<
" -> " << addId <<
" [label=< [4] >];\n" 62 " " << inputId <<
" -> " << addId <<
" [label=< [4] >];\n" 63 " " << addId <<
" -> " << outputId <<
" [label=< [4] >];\n" 66 CHECK(ss.str() == expected.str());
69 TEST_CASE(
"OptimizeValidateDeviceNonSupportLayerNoFallback")
92 std::vector<std::string> errMessages;
97 FAIL(
"Should have thrown an exception.");
103 CHECK(errMessages.size() > 0);
106 TEST_CASE(
"OptimizeValidateDeviceNonSupportLayerWithFallback")
135 for (
auto&& layer : graph)
140 #if defined(ARMCOMPUTENEON_ENABLED) 155 TEST_CASE(
"OptimizeValidateWorkloadsUndefinedComputeDevice")
184 layer = net->AddActivationLayer(acDesc,
"ac");
190 layer = net->AddMultiplicationLayer(
"ml");
198 layer = net->AddSoftmaxLayer(softmaxDescriptor,
"sm");
204 layer = net->AddOutputLayer(0,
"ot");
212 std::vector<std::string> errMessages;
217 FAIL(
"Should have thrown an exception.");
223 CHECK(errMessages.size() > 0);
226 TEST_CASE(
"OptimizeValidateWorkloadsUndefinedComputeDeviceWithFallback")
255 layer = net->AddActivationLayer(acDesc,
"ac");
261 layer = net->AddMultiplicationLayer(
"ml");
269 layer = net->AddSoftmaxLayer(softmaxDescriptor,
"sm");
275 layer = net->AddOutputLayer(0,
"ot");
292 for (
auto&& layer : graph)
296 layer->CreateWorkload(fact));
300 TEST_CASE(
"OptimizeValidateWorkloadsDuplicateComputeDeviceWithFallback")
324 armnn::Compute::CpuRef };
332 for (
auto&& layer : graph)
339 #if defined(ARMCOMPUTENEON_ENABLED) 348 #elif defined(ARMCOMPUTECL_ENABLED) 363 TEST_CASE(
"OptimizeNetworkCopy")
367 std::vector<armnn::NetworkId> networkIds;
369 const std::string layerName(
"convolution2d");
376 std::vector<float> weightsData = GenerateRandomData<float>(weightsInfo.GetNumElements());
379 std::vector<float> biasesData = GenerateRandomData<float>(biasesInfo.GetNumElements());
397 network->AddConvolution2dLayer(descriptor,
409 std::vector<armnn::BackendId> preferredBackends {
"CpuRef" };
412 std::vector<std::string> errorMessages;
417 runtime->GetDeviceSpec(),
421 for (
unsigned int i = 0; i < 2; ++i)
430 std::string errorMessage;
435 networkIds.emplace_back(netId);
438 std::string errorMessage;
443 std::vector<float> inputData = GenerateRandomData<float>(runtime->GetInputTensorInfo(optNetId, 0).GetNumElements());
444 std::vector<float> outputData(runtime->GetOutputTensorInfo(optNetId, 0).GetNumElements());
455 0,
armnn::Tensor(runtime->GetOutputTensorInfo(optNetId, 0), outputData.data())
458 runtime->EnqueueWorkload(optNetId, inputTensors, outputTensors);
459 runtime->UnloadNetwork(optNetId);
462 for (
unsigned int i = 0; i < networkIds.size(); ++i)
465 std::vector<float> copyOutputData(runtime->GetOutputTensorInfo(netId, 0).GetNumElements());
476 0,
armnn::Tensor(runtime->GetOutputTensorInfo(netId, 0), copyOutputData.data())
479 runtime->EnqueueWorkload(netId, copyInputTensors, copyOutputTensors);
480 runtime->UnloadNetwork(netId);
483 for (
unsigned int j = 0; j < outputData.size(); ++j)
485 CHECK(outputData[j] == copyOutputData[j]);
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).
static IRuntimePtr Create(const CreationOptions &options)
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
CPU Execution: Reference C++ kernels.
std::vector< BackendOptions > ModelOptions
A Convolution2dDescriptor for the Convolution2dLayer.
std::unique_ptr< IRuntime, void(*)(IRuntime *runtime)> IRuntimePtr
std::vector< std::pair< LayerBindingId, class ConstTensor > > InputTensors
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
A tensor defined by a TensorInfo (shape and data type) and a mutable backing store.
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.
IOptimizedNetworkPtr Optimize(const INetwork &network, const std::vector< BackendId > &backendPreferences, const IDeviceSpec &deviceSpec, const OptimizerOptions &options=OptimizerOptions(), Optional< std::vector< std::string > &> messages=EmptyOptional())
Create an optimized version of the network.
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
std::vector< std::pair< LayerBindingId, class Tensor > > OutputTensors
std::unique_ptr< IOptimizedNetwork, void(*)(IOptimizedNetwork *network)> IOptimizedNetworkPtr
GPU Execution: OpenCL: ArmCompute.
An ActivationDescriptor for the ActivationLayer.
uint32_t m_StrideY
Stride value when proceeding through input for the height dimension.
virtual LayerType GetType() const =0
Returns the armnn::LayerType of this layer.
Graph & GetGraphForTesting(IOptimizedNetwork *optNet)
uint32_t m_DilationX
Dilation along x axis.
CPU Execution: NEON: ArmCompute.
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
virtual int Connect(IInputSlot &destination)=0
A NormalizationDescriptor for the NormalizationLayer.
Status AllocateDynamicBuffers()
Allocates memory for all tensors under output tensor handers of each layer.
static INetworkPtr Create(NetworkOptions networkOptions={})
static void Destroy(IOptimizedNetwork *network)
A SoftmaxDescriptor for the SoftmaxLayer.
uint32_t m_PadLeft
Padding left value in the width dimension.