From a983e4699082a0b1ef685bab7354f2ad9cd37a44 Mon Sep 17 00:00:00 2001 From: Colm Donelan Date: Wed, 20 May 2020 16:12:19 +0100 Subject: Updating Doxygen documentation for 20.05 release. Change-Id: I4d624343ed5fd6ae269c3d53532903084508fd14 Signed-off-by: Colm Donelan --- ...to_space_end_to_end_test_impl_8hpp_source.xhtml | 133 +++++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 20.05/_depth_to_space_end_to_end_test_impl_8hpp_source.xhtml (limited to '20.05/_depth_to_space_end_to_end_test_impl_8hpp_source.xhtml') diff --git a/20.05/_depth_to_space_end_to_end_test_impl_8hpp_source.xhtml b/20.05/_depth_to_space_end_to_end_test_impl_8hpp_source.xhtml new file mode 100644 index 0000000000..d6f06446d8 --- /dev/null +++ b/20.05/_depth_to_space_end_to_end_test_impl_8hpp_source.xhtml @@ -0,0 +1,133 @@ + + + + + + + + + + + + + +ArmNN: src/backends/backendsCommon/test/DepthToSpaceEndToEndTestImpl.hpp Source File + + + + + + + + + + + + + + + + +
+
+ + + + ArmNN + + + +
+
+  20.05 +
+
+
+ + + + + + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+ +
+ +
+
+
DepthToSpaceEndToEndTestImpl.hpp
+
+
+Go to the documentation of this file.
1 //
2 // Copyright © 2019 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #pragma once
7 
8 #include <ResolveType.hpp>
9 
10 
11 #include <QuantizeHelper.hpp>
12 
14 
15 namespace
16 {
17 
18 armnn::INetworkPtr CreateDepthToSpaceNetwork(const armnn::TensorInfo& inputInfo,
19  const armnn::TensorInfo& outputInfo,
20  const armnn::DepthToSpaceDescriptor& descriptor)
21 {
22  using namespace armnn;
23 
24  INetworkPtr network(INetwork::Create());
25 
26  IConnectableLayer* input = network->AddInputLayer(0, "input");
27  IConnectableLayer* depthToSpace = network->AddDepthToSpaceLayer(descriptor, "depthToSpace");
28  IConnectableLayer* output = network->AddOutputLayer(0, "output");
29 
30  Connect(input, depthToSpace, inputInfo, 0, 0);
31  Connect(depthToSpace, output, outputInfo, 0, 0);
32 
33  return network;
34 }
35 
36 template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>>
37 void DepthToSpaceEndToEndImpl(const std::vector<armnn::BackendId>& backends,
38  const DepthToSpaceDescriptor& descriptor,
39  const armnn::TensorShape& nhwcInputShape,
40  const armnn::TensorShape& nhwcOutputShape,
41  const std::vector<float>& floatInputData,
42  const std::vector<float>& floatExpectedOutputData)
43 {
44  using namespace armnn;
45 
46  TensorInfo inputInfo(nhwcInputShape, ArmnnType);
47  TensorInfo outputInfo(nhwcOutputShape, ArmnnType);
48 
49  constexpr float qScale = 0.25f;
50  constexpr int32_t qOffset = 128;
51 
52  // Set quantization parameters for quantized types
53  if (IsQuantizedType<T>())
54  {
55  inputInfo.SetQuantizationScale(qScale);
56  inputInfo.SetQuantizationOffset(qOffset);
57  outputInfo.SetQuantizationScale(qScale);
58  outputInfo.SetQuantizationOffset(qOffset);
59  }
60 
61  std::vector<T> inputData = armnnUtils::QuantizedVector<T>(floatInputData, qScale, qOffset);
62  std::vector<T> expectedOutputData = armnnUtils::QuantizedVector<T>(floatExpectedOutputData, qScale, qOffset);
63 
64  // Permute tensors from NHWC to NCHW (if needed)
65  if (descriptor.m_DataLayout == DataLayout::NCHW)
66  {
67  PermuteTensorNhwcToNchw(inputInfo, inputData);
68  PermuteTensorNhwcToNchw(outputInfo, expectedOutputData);
69  }
70 
71  INetworkPtr network = CreateDepthToSpaceNetwork(inputInfo, outputInfo, descriptor);
72  EndToEndLayerTestImpl<ArmnnType, ArmnnType>(std::move(network),
73  { { 0, inputData } },
74  { { 0, expectedOutputData } },
75  backends);
76 }
77 
78 } // anonymous namespace
79 
80 template<armnn::DataType ArmnnType>
81 void DepthToSpaceEndToEnd(const std::vector<armnn::BackendId>& defaultBackends,
82  armnn::DataLayout dataLayout)
83 {
84  using namespace armnn;
85 
86  TensorShape inputShape = { 2, 2, 2, 4 };
87  TensorShape outputShape = { 2, 4, 4, 1 };
88 
89  std::vector<float> inputData =
90  {
91  1.f, 2.f, 3.f, 4.f,
92  5.f, 6.f, 7.f, 8.f,
93  9.f, 10.f, 11.f, 12.f,
94  13.f, 14.f, 15.f, 16.f,
95 
96  17.f, 18.f, 19.f, 20.f,
97  21.f, 22.f, 23.f, 24.f,
98  25.f, 26.f, 27.f, 28.f,
99  29.f, 30.f, 31.f, 32.f
100  };
101 
102  std::vector<float> expectedOutputData =
103  {
104  1.f, 2.f, 5.f, 6.f,
105  3.f, 4.f, 7.f, 8.f,
106  9.f, 10.f, 13.f, 14.f,
107  11.f, 12.f, 15.f, 16.f,
108 
109  17.f, 18.f, 21.f, 22.f,
110  19.f, 20.f, 23.f, 24.f,
111  25.f, 26.f, 29.f, 30.f,
112  27.f, 28.f, 31.f, 32.f
113  };
114 
115  DepthToSpaceEndToEndImpl<ArmnnType>(defaultBackends,
116  DepthToSpaceDescriptor(2, dataLayout),
117  inputShape,
118  outputShape,
119  inputData,
120  expectedOutputData);
121 }
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition: INetwork.hpp:61
+
DataLayout
Definition: Types.hpp:49
+ +
void DepthToSpaceEndToEnd(const std::vector< armnn::BackendId > &defaultBackends, armnn::DataLayout dataLayout)
+ + +
Copyright (c) 2020 ARM Limited.
+ +
A SpaceToDepthDescriptor for the SpaceToDepthLayer.
+
void SetQuantizationScale(float scale)
Definition: Tensor.cpp:260
+
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
+
std::vector< armnn::BackendId > defaultBackends
+
void SetQuantizationOffset(int32_t offset)
Definition: Tensor.cpp:276
+
void Connect(armnn::IConnectableLayer *from, armnn::IConnectableLayer *to, const armnn::TensorInfo &tensorInfo, unsigned int fromIndex, unsigned int toIndex)
Definition: TestUtils.cpp:12
+
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:101
+ + +
static INetworkPtr Create()
Definition: Network.cpp:50
+
SpaceToDepthDescriptor DepthToSpaceDescriptor
A DepthToSpaceDescriptor for the DepthToSpaceLayer.
+
void PermuteTensorNhwcToNchw(armnn::TensorInfo &tensorInfo, std::vector< T > &tensorData)
+
+
+ + + + -- cgit v1.2.1