ArmNN
 21.11
ChannelShuffleTestImpl.hpp File Reference

Go to the source code of this file.

Functions

template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>>
LayerTestResult< T, 4 > SimpleChannelShuffleTest (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 
template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>>
LayerTestResult< T, 2 > ChannelShuffle2DTest (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 
template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>>
LayerTestResult< T, 4 > ChannelShuffle4DTest (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 

Function Documentation

◆ ChannelShuffle2DTest()

LayerTestResult<T, 2> ChannelShuffle2DTest ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory 
)

Definition at line 100 of file ChannelShuffleTestImpl.cpp.

References ChannelShuffleDescriptor::m_Axis, ChannelShuffleDescriptor::m_NumGroups, and TensorInfo::SetQuantizationScale().

104 {
105  armnn::TensorInfo inputTensorInfo;
106  armnn::TensorInfo outputTensorInfo;
107 
108  unsigned int inputShape[] = { 3, 12 };
109  unsigned int outputShape[] = { 3, 12 };
110 
112  descriptor.m_Axis = 1;
113  descriptor.m_NumGroups = 3;
114 
115  inputTensorInfo = armnn::TensorInfo(2, inputShape, ArmnnType);
116  inputTensorInfo.SetQuantizationScale(1.0f);
117  outputTensorInfo = armnn::TensorInfo(2, outputShape, ArmnnType);
118  outputTensorInfo.SetQuantizationScale(1.0f);
119 
120  auto input = ConvertToDataType<ArmnnType>(
121  {
122  0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
123  12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
124  24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35
125  },
126  inputTensorInfo);
127 
128  auto outputExpected = ConvertToDataType<ArmnnType>(
129  {
130  0, 4, 8, 1, 5, 9, 2, 6, 10, 3, 7, 11,
131  12, 16, 20, 13, 17, 21, 14, 18, 22, 15, 19, 23,
132  24, 28, 32, 25, 29, 33, 26, 30, 34, 27, 31, 35
133  },
134  outputTensorInfo);
135 
136  return ChannelShuffleTestImpl<T, 2>(
137  workloadFactory,
138  memoryManager,
139  tensorHandleFactory,
140  descriptor,
141  inputTensorInfo,
142  outputTensorInfo,
143  input,
144  outputExpected);
145 }
void SetQuantizationScale(float scale)
Definition: Tensor.cpp:475
uint32_t m_NumGroups
Number of groups for the channel shuffle operation.
uint32_t m_Axis
Axis to apply channel shuffle operation on.
A ChannelShuffleDescriptor for the ChannelShuffle operator.

◆ ChannelShuffle4DTest()

LayerTestResult<T, 4> ChannelShuffle4DTest ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory 
)

Definition at line 148 of file ChannelShuffleTestImpl.cpp.

References ChannelShuffleDescriptor::m_Axis, ChannelShuffleDescriptor::m_NumGroups, and TensorInfo::SetQuantizationScale().

152 {
153  armnn::TensorInfo inputTensorInfo;
154  armnn::TensorInfo outputTensorInfo;
155 
156  unsigned int inputShape[] = { 2, 9, 1, 2 };
157  unsigned int outputShape[] = { 2, 9, 1, 2 };
158 
160  descriptor.m_Axis = 1;
161  descriptor.m_NumGroups = 3;
162 
163  inputTensorInfo = armnn::TensorInfo(4, inputShape, ArmnnType);
164  inputTensorInfo.SetQuantizationScale(1.0f);
165  outputTensorInfo = armnn::TensorInfo(4, outputShape, ArmnnType);
166  outputTensorInfo.SetQuantizationScale(1.0f);
167 
168  auto input = ConvertToDataType<ArmnnType>(
169  {
170  0.0f, 1.0f,
171  2.0f, 3.0f,
172  4.0f, 5.0f,
173 
174  6.0f, 7.0f,
175  8.0f, 9.0f,
176  10.0f, 11.0f,
177 
178  12.0f, 13.0f,
179  14.0f, 15.0f,
180  16.0f, 17.0f,
181 
182  18.0f, 19.0f,
183  20.0f, 21.0f,
184  22.0f, 23.0f,
185 
186  24.0f, 25.0f,
187  26.0f, 27.0f,
188  28.0f, 29.0f,
189 
190  30.0f, 31.0f,
191  32.0f, 33.0f,
192  34.0f, 35.0f
193  },
194  inputTensorInfo);
195 
196  auto outputExpected = ConvertToDataType<ArmnnType>(
197  {
198  0.0f, 1.0f,
199  6.0f, 7.0f,
200  12.0f, 13.0f,
201  2.0f, 3.0f,
202  8.0f, 9.0f,
203  14.0f, 15.0f,
204  4.0f, 5.0f,
205  10.0f, 11.0f,
206  16.0f, 17.0f,
207 
208  18.0f, 19.0f,
209  24.0f, 25.0f,
210  30.0f, 31.0f,
211  20.0f, 21.0f,
212  26.0f, 27.0f,
213  32.0f, 33.0f,
214  22.0f, 23.0f,
215  28.0f, 29.0f,
216  34.0f, 35.0f
217  },
218  outputTensorInfo);
219 
220  return ChannelShuffleTestImpl<T, 4>(
221  workloadFactory,
222  memoryManager,
223  tensorHandleFactory,
224  descriptor,
225  inputTensorInfo,
226  outputTensorInfo,
227  input,
228  outputExpected);
229 }
void SetQuantizationScale(float scale)
Definition: Tensor.cpp:475
uint32_t m_NumGroups
Number of groups for the channel shuffle operation.
uint32_t m_Axis
Axis to apply channel shuffle operation on.
A ChannelShuffleDescriptor for the ChannelShuffle operator.

◆ SimpleChannelShuffleTest()

LayerTestResult<T, 4> SimpleChannelShuffleTest ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory 
)

Definition at line 57 of file ChannelShuffleTestImpl.cpp.

References ChannelShuffleDescriptor::m_Axis, ChannelShuffleDescriptor::m_NumGroups, and TensorInfo::SetQuantizationScale().

61 {
62  armnn::TensorInfo inputTensorInfo;
63  armnn::TensorInfo outputTensorInfo;
64 
65  unsigned int inputShape[] = { 1,9,1,1 };
66  unsigned int outputShape[] = { 1,9,1,1 };
67 
69  descriptor.m_Axis = 1;
70  descriptor.m_NumGroups = 3;
71 
72  inputTensorInfo = armnn::TensorInfo(4, inputShape, ArmnnType);
73  inputTensorInfo.SetQuantizationScale(1.0f);
74  outputTensorInfo = armnn::TensorInfo(4, outputShape, ArmnnType);
75  outputTensorInfo.SetQuantizationScale(1.0f);
76 
77  auto input = ConvertToDataType<ArmnnType>(
78  {
79  0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f
80  },
81  inputTensorInfo);
82  auto outputExpected = ConvertToDataType<ArmnnType>(
83  {
84  0.0f, 3.0f, 6.0f, 1.0f, 4.0f, 7.0f, 2.0f, 5.0f, 8.0f
85  },
86  outputTensorInfo);
87 
88  return ChannelShuffleTestImpl<T, 4>(
89  workloadFactory,
90  memoryManager,
91  tensorHandleFactory,
92  descriptor,
93  inputTensorInfo,
94  outputTensorInfo,
95  input,
96  outputExpected);
97 }
void SetQuantizationScale(float scale)
Definition: Tensor.cpp:475
uint32_t m_NumGroups
Number of groups for the channel shuffle operation.
uint32_t m_Axis
Axis to apply channel shuffle operation on.
A ChannelShuffleDescriptor for the ChannelShuffle operator.