ArmNN
 21.02
DepthToSpaceTestImpl.hpp File Reference

Go to the source code of this file.

Functions

template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>>
LayerTestResult< T, 4 > DepthToSpaceTest1 (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, armnn::DataLayout dataLayout)
 
template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>>
LayerTestResult< T, 4 > DepthToSpaceTest2 (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, armnn::DataLayout dataLayout)
 
template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>>
LayerTestResult< T, 4 > DepthToSpaceTest3 (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, armnn::DataLayout dataLayout)
 
template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>>
LayerTestResult< T, 4 > DepthToSpaceTest4 (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, armnn::DataLayout dataLayout)
 

Function Documentation

◆ DepthToSpaceTest1()

LayerTestResult<T, 4> DepthToSpaceTest1 ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
armnn::DataLayout  dataLayout 
)

Definition at line 79 of file DepthToSpaceTestImpl.cpp.

References SpaceToDepthDescriptor::m_BlockSize, SpaceToDepthDescriptor::m_DataLayout, and QueueDescriptorWithParameters< LayerDescriptor >::m_Parameters.

83 {
84  unsigned int inputShape[] = { 1, 1, 1, 8 };
85  unsigned int outputShape[] = { 1, 2, 2, 2 };
86 
87  // in:
88  // [[[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]]]]
89  //
90  // out:
91  // [[[[1, 2, 3], [4, 5, 6]],
92  // [[7, 8, 9], [10, 11, 12]]]]
93 
94  std::vector<float> input = { 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f, 8.f };
95  std::vector<float> expectedOutput = input;
96 
98  desc.m_Parameters.m_DataLayout = dataLayout;
99  desc.m_Parameters.m_BlockSize = 2;
100 
101  armnn::TensorInfo inputInfo(4, inputShape, ArmnnType);
102  armnn::TensorInfo outputInfo(4, outputShape, ArmnnType);
103 
104  return DepthToSpaceTestImpl<T>(workloadFactory, memoryManager, inputInfo, outputInfo, input, expectedOutput, desc);
105 }
unsigned int m_BlockSize
Scalar specifying the input block size. It must be >= 1.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).

◆ DepthToSpaceTest2()

LayerTestResult<T, 4> DepthToSpaceTest2 ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
armnn::DataLayout  dataLayout 
)

Definition at line 108 of file DepthToSpaceTestImpl.cpp.

References SpaceToDepthDescriptor::m_BlockSize, SpaceToDepthDescriptor::m_DataLayout, and QueueDescriptorWithParameters< LayerDescriptor >::m_Parameters.

112 {
113  unsigned int inputShape[] = { 1, 2, 2, 4 };
114  unsigned int outputShape[] = { 1, 4, 4, 1 };
115 
116  // in:
117  // [[[[1, 2, 3, 4],
118  // [5, 6, 7, 8]],
119  // [[9, 10, 11, 12],
120  // [13, 14, 15, 16]]]]
121  //
122  // out:
123  // [[[ [1], [2], [5], [6]],
124  // [ [3], [4], [7], [8]],
125  // [ [9], [10], [13], [14]],
126  // [ [11], [12], [15], [16]]]]
127 
128  std::vector<float> input =
129  {
130  1.f, 2.f, 3.f, 4.f,
131 
132  5.f, 6.f, 7.f, 8.f,
133 
134  9.f, 10.f, 11.f, 12.f,
135 
136  13.f, 14.f, 15.f, 16.f
137  };
138 
139  std::vector<float> expectedOutput
140  {
141  1.f, 2.f, 5.f, 6.f,
142  3.f, 4.f, 7.f, 8.f,
143  9.f, 10.f, 13.f, 14.f,
144  11.f, 12.f, 15.f, 16.f
145  };
146 
148  desc.m_Parameters.m_DataLayout = dataLayout;
149  desc.m_Parameters.m_BlockSize = 2;
150 
151  armnn::TensorInfo inputInfo(4, inputShape, ArmnnType);
152  armnn::TensorInfo outputInfo(4, outputShape, ArmnnType);
153 
154  return DepthToSpaceTestImpl<T>(workloadFactory, memoryManager, inputInfo, outputInfo, input, expectedOutput, desc);
155 }
unsigned int m_BlockSize
Scalar specifying the input block size. It must be >= 1.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).

◆ DepthToSpaceTest3()

LayerTestResult<T, 4> DepthToSpaceTest3 ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
armnn::DataLayout  dataLayout 
)

Definition at line 158 of file DepthToSpaceTestImpl.cpp.

References SpaceToDepthDescriptor::m_BlockSize, SpaceToDepthDescriptor::m_DataLayout, and QueueDescriptorWithParameters< LayerDescriptor >::m_Parameters.

162 {
163  unsigned int inputShape[] = { 2, 1, 1, 4 };
164  unsigned int outputShape[] = { 2, 2, 2, 1 };
165 
166  std::vector<float> input =
167  {
168  1.f, 2.f, 3.f, 4.f, // batch 0
169  5.f, 6.f, 7.f, 8.f // batch 1
170  };
171 
172  std::vector<float> expectedOutput = input;
173 
175  desc.m_Parameters.m_DataLayout = dataLayout;
176  desc.m_Parameters.m_BlockSize = 2;
177 
178  armnn::TensorInfo inputInfo(4, inputShape, ArmnnType);
179  armnn::TensorInfo outputInfo(4, outputShape, ArmnnType);
180 
181  return DepthToSpaceTestImpl<T>(workloadFactory, memoryManager, inputInfo, outputInfo, input, expectedOutput, desc);
182 }
unsigned int m_BlockSize
Scalar specifying the input block size. It must be >= 1.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).

◆ DepthToSpaceTest4()

LayerTestResult<T, 4> DepthToSpaceTest4 ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
armnn::DataLayout  dataLayout 
)

Definition at line 185 of file DepthToSpaceTestImpl.cpp.

References SpaceToDepthDescriptor::m_BlockSize, SpaceToDepthDescriptor::m_DataLayout, and QueueDescriptorWithParameters< LayerDescriptor >::m_Parameters.

189 {
190  unsigned int inputShape[] = { 2, 2, 2, 4 };
191  unsigned int outputShape[] = { 2, 4, 4, 1 };
192 
193  std::vector<float> input =
194  {
195  1.f, 2.f, 3.f, 4.f,
196 
197  5.f, 6.f, 7.f, 8.f,
198 
199  9.f, 10.f, 11.f, 12.f,
200 
201  13.f, 14.f, 15.f, 16.f,
202 
203 
204  17.f, 18.f, 19.f, 20.f,
205 
206  21.f, 22.f, 23.f, 24.f,
207 
208  25.f, 26.f, 27.f, 28.f,
209 
210  29.f, 30.f, 31.f, 32.f
211  };
212 
213  std::vector<float> expectedOutput
214  {
215  1.f, 2.f, 5.f, 6.f,
216  3.f, 4.f, 7.f, 8.f,
217  9.f, 10.f, 13.f, 14.f,
218  11.f, 12.f, 15.f, 16.f,
219 
220 
221  17.f, 18.f, 21.f, 22.f,
222  19.f, 20.f, 23.f, 24.f,
223  25.f, 26.f, 29.f, 30.f,
224  27.f, 28.f, 31.f, 32.f
225  };
226 
228  desc.m_Parameters.m_DataLayout = dataLayout;
229  desc.m_Parameters.m_BlockSize = 2;
230 
231  armnn::TensorInfo inputInfo(4, inputShape, ArmnnType);
232  armnn::TensorInfo outputInfo(4, outputShape, ArmnnType);
233 
234  return DepthToSpaceTestImpl<T>(workloadFactory, memoryManager, inputInfo, outputInfo, input, expectedOutput, desc);
235 }
unsigned int m_BlockSize
Scalar specifying the input block size. It must be >= 1.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).