blob: 262b8fcf2adde936c457deb12403be0d114f7d75 [file] [log] [blame]
Teresa Charlin18147332021-11-17 14:34:30 +00001# Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
Richard Burtondc0c6ed2020-04-08 16:39:05 +01002# SPDX-License-Identifier: MIT
3import inspect
4
5import pytest
6
7import pyarmnn as ann
8import numpy as np
9import pyarmnn._generated.pyarmnn as generated
10
11
12def test_activation_descriptor_default_values():
13 desc = ann.ActivationDescriptor()
14 assert desc.m_Function == ann.ActivationFunction_Sigmoid
15 assert desc.m_A == 0
16 assert desc.m_B == 0
17
18
19def test_argminmax_descriptor_default_values():
20 desc = ann.ArgMinMaxDescriptor()
21 assert desc.m_Function == ann.ArgMinMaxFunction_Min
22 assert desc.m_Axis == -1
23
24
25def test_batchnormalization_descriptor_default_values():
26 desc = ann.BatchNormalizationDescriptor()
27 assert desc.m_DataLayout == ann.DataLayout_NCHW
28 np.allclose(0.0001, desc.m_Eps)
29
30
31def test_batchtospacend_descriptor_default_values():
32 desc = ann.BatchToSpaceNdDescriptor()
33 assert desc.m_DataLayout == ann.DataLayout_NCHW
34 assert [1, 1] == desc.m_BlockShape
35 assert [(0, 0), (0, 0)] == desc.m_Crops
36
37
38def test_batchtospacend_descriptor_assignment():
39 desc = ann.BatchToSpaceNdDescriptor()
40 desc.m_BlockShape = (1, 2, 3)
41
42 ololo = [(1, 2), (3, 4)]
43 size_1 = len(ololo)
44 desc.m_Crops = ololo
45
46 assert size_1 == len(ololo)
47 desc.m_DataLayout = ann.DataLayout_NHWC
48 assert ann.DataLayout_NHWC == desc.m_DataLayout
49 assert [1, 2, 3] == desc.m_BlockShape
50 assert [(1, 2), (3, 4)] == desc.m_Crops
51
52
53@pytest.mark.parametrize("input_shape, value, vtype", [([-1], -1, 'int'), (("one", "two"), "'one'", 'str'),
54 ([1.33, 4.55], 1.33, 'float'),
55 ([{1: "one"}], "{1: 'one'}", 'dict')], ids=lambda x: str(x))
56def test_batchtospacend_descriptor_rubbish_assignment_shape(input_shape, value, vtype):
57 desc = ann.BatchToSpaceNdDescriptor()
58 with pytest.raises(TypeError) as err:
59 desc.m_BlockShape = input_shape
60
61 assert "Failed to convert python input value {} of type '{}' to C type 'j'".format(value, vtype) in str(err.value)
62
63
64@pytest.mark.parametrize("input_crops, value, vtype", [([(1, 2), (3, 4, 5)], '(3, 4, 5)', 'tuple'),
65 ([(1, 'one')], "(1, 'one')", 'tuple'),
66 ([-1], -1, 'int'),
67 ([(1, (1, 2))], '(1, (1, 2))', 'tuple'),
68 ([[1, [1, 2]]], '[1, [1, 2]]', 'list')
69 ], ids=lambda x: str(x))
70def test_batchtospacend_descriptor_rubbish_assignment_crops(input_crops, value, vtype):
71 desc = ann.BatchToSpaceNdDescriptor()
72 with pytest.raises(TypeError) as err:
73 desc.m_Crops = input_crops
74
75 assert "Failed to convert python input value {} of type '{}' to C type".format(value, vtype) in str(err.value)
76
77
78def test_batchtospacend_descriptor_empty_assignment():
79 desc = ann.BatchToSpaceNdDescriptor()
80 desc.m_BlockShape = []
81 assert [] == desc.m_BlockShape
82
83
84def test_batchtospacend_descriptor_ctor():
85 desc = ann.BatchToSpaceNdDescriptor([1, 2, 3], [(4, 5), (6, 7)])
86 assert desc.m_DataLayout == ann.DataLayout_NCHW
87 assert [1, 2, 3] == desc.m_BlockShape
88 assert [(4, 5), (6, 7)] == desc.m_Crops
89
90
Teresa Charlinf7b50112021-11-18 15:24:50 +000091def test_channelshuffle_descriptor_default_values():
92 desc = ann.ChannelShuffleDescriptor()
93 assert desc.m_Axis == 0
94 assert desc.m_NumGroups == 0
95
Richard Burtondc0c6ed2020-04-08 16:39:05 +010096def test_convolution2d_descriptor_default_values():
97 desc = ann.Convolution2dDescriptor()
98 assert desc.m_PadLeft == 0
99 assert desc.m_PadTop == 0
100 assert desc.m_PadRight == 0
101 assert desc.m_PadBottom == 0
Teresa Charlinf2ed1b82020-11-24 15:11:54 +0000102 assert desc.m_StrideX == 1
103 assert desc.m_StrideY == 1
Richard Burtondc0c6ed2020-04-08 16:39:05 +0100104 assert desc.m_DilationX == 1
105 assert desc.m_DilationY == 1
106 assert desc.m_BiasEnabled == False
107 assert desc.m_DataLayout == ann.DataLayout_NCHW
108
Teresa Charlin18147332021-11-17 14:34:30 +0000109def test_convolution3d_descriptor_default_values():
110 desc = ann.Convolution3dDescriptor()
111 assert desc.m_PadLeft == 0
112 assert desc.m_PadTop == 0
113 assert desc.m_PadRight == 0
114 assert desc.m_PadBottom == 0
115 assert desc.m_PadFront == 0
116 assert desc.m_PadBack == 0
117 assert desc.m_StrideX == 1
118 assert desc.m_StrideY == 1
119 assert desc.m_StrideZ == 1
120 assert desc.m_DilationX == 1
121 assert desc.m_DilationY == 1
122 assert desc.m_DilationZ == 1
123 assert desc.m_BiasEnabled == False
124 assert desc.m_DataLayout == ann.DataLayout_NDHWC
125
Richard Burtondc0c6ed2020-04-08 16:39:05 +0100126
127def test_depthtospace_descriptor_default_values():
128 desc = ann.DepthToSpaceDescriptor()
129 assert desc.m_BlockSize == 1
130 assert desc.m_DataLayout == ann.DataLayout_NHWC
131
132
133def test_depthwise_convolution2d_descriptor_default_values():
134 desc = ann.DepthwiseConvolution2dDescriptor()
135 assert desc.m_PadLeft == 0
136 assert desc.m_PadTop == 0
137 assert desc.m_PadRight == 0
138 assert desc.m_PadBottom == 0
Teresa Charlinf2ed1b82020-11-24 15:11:54 +0000139 assert desc.m_StrideX == 1
140 assert desc.m_StrideY == 1
Richard Burtondc0c6ed2020-04-08 16:39:05 +0100141 assert desc.m_DilationX == 1
142 assert desc.m_DilationY == 1
143 assert desc.m_BiasEnabled == False
144 assert desc.m_DataLayout == ann.DataLayout_NCHW
145
146
147def test_detectionpostprocess_descriptor_default_values():
148 desc = ann.DetectionPostProcessDescriptor()
149 assert desc.m_MaxDetections == 0
150 assert desc.m_MaxClassesPerDetection == 1
151 assert desc.m_DetectionsPerClass == 1
152 assert desc.m_NmsScoreThreshold == 0
153 assert desc.m_NmsIouThreshold == 0
154 assert desc.m_NumClasses == 0
155 assert desc.m_UseRegularNms == False
156 assert desc.m_ScaleH == 0
157 assert desc.m_ScaleW == 0
158 assert desc.m_ScaleX == 0
159 assert desc.m_ScaleY == 0
160
161
162def test_fakequantization_descriptor_default_values():
163 desc = ann.FakeQuantizationDescriptor()
164 np.allclose(6, desc.m_Max)
165 np.allclose(-6, desc.m_Min)
166
167
Jan Eilers841aca12020-08-12 14:59:06 +0100168def test_fill_descriptor_default_values():
169 desc = ann.FillDescriptor()
170 np.allclose(0, desc.m_Value)
171
172
173def test_gather_descriptor_default_values():
174 desc = ann.GatherDescriptor()
175 assert desc.m_Axis == 0
176
177
Richard Burtondc0c6ed2020-04-08 16:39:05 +0100178def test_fully_connected_descriptor_default_values():
179 desc = ann.FullyConnectedDescriptor()
180 assert desc.m_BiasEnabled == False
181 assert desc.m_TransposeWeightMatrix == False
182
183
184def test_instancenormalization_descriptor_default_values():
185 desc = ann.InstanceNormalizationDescriptor()
186 assert desc.m_Gamma == 1
187 assert desc.m_Beta == 0
188 assert desc.m_DataLayout == ann.DataLayout_NCHW
189 np.allclose(1e-12, desc.m_Eps)
190
191
192def test_lstm_descriptor_default_values():
193 desc = ann.LstmDescriptor()
194 assert desc.m_ActivationFunc == 1
195 assert desc.m_ClippingThresCell == 0
196 assert desc.m_ClippingThresProj == 0
197 assert desc.m_CifgEnabled == True
198 assert desc.m_PeepholeEnabled == False
199 assert desc.m_ProjectionEnabled == False
200 assert desc.m_LayerNormEnabled == False
201
202
203def test_l2normalization_descriptor_default_values():
204 desc = ann.L2NormalizationDescriptor()
205 assert desc.m_DataLayout == ann.DataLayout_NCHW
206 np.allclose(1e-12, desc.m_Eps)
207
208
209def test_mean_descriptor_default_values():
210 desc = ann.MeanDescriptor()
211 assert desc.m_KeepDims == False
212
213
214def test_normalization_descriptor_default_values():
215 desc = ann.NormalizationDescriptor()
216 assert desc.m_NormChannelType == ann.NormalizationAlgorithmChannel_Across
217 assert desc.m_NormMethodType == ann.NormalizationAlgorithmMethod_LocalBrightness
218 assert desc.m_NormSize == 0
219 assert desc.m_Alpha == 0
220 assert desc.m_Beta == 0
221 assert desc.m_K == 0
222 assert desc.m_DataLayout == ann.DataLayout_NCHW
223
224
225def test_origin_descriptor_default_values():
226 desc = ann.ConcatDescriptor()
227 assert 0 == desc.GetNumViews()
228 assert 0 == desc.GetNumDimensions()
229 assert 1 == desc.GetConcatAxis()
230
231
232def test_origin_descriptor_incorrect_views():
233 desc = ann.ConcatDescriptor(2, 2)
234 with pytest.raises(RuntimeError) as err:
235 desc.SetViewOriginCoord(1000, 100, 1000)
236 assert "Failed to set view origin coordinates." in str(err.value)
237
238
239def test_origin_descriptor_ctor():
240 desc = ann.ConcatDescriptor(2, 2)
241 value = 5
242 for i in range(desc.GetNumViews()):
243 for j in range(desc.GetNumDimensions()):
244 desc.SetViewOriginCoord(i, j, value+i)
245 desc.SetConcatAxis(1)
246
247 assert 2 == desc.GetNumViews()
248 assert 2 == desc.GetNumDimensions()
249 assert [5, 5] == desc.GetViewOrigin(0)
250 assert [6, 6] == desc.GetViewOrigin(1)
251 assert 1 == desc.GetConcatAxis()
252
253
254def test_pad_descriptor_default_values():
255 desc = ann.PadDescriptor()
256 assert desc.m_PadValue == 0
Teresa Charlincd3fdae2021-11-18 15:51:36 +0000257 assert desc.m_PaddingMode == ann.PaddingMode_Constant
Richard Burtondc0c6ed2020-04-08 16:39:05 +0100258
259
260def test_permute_descriptor_default_values():
261 pv = ann.PermutationVector((0, 2, 3, 1))
262 desc = ann.PermuteDescriptor(pv)
263 assert desc.m_DimMappings.GetSize() == 4
264 assert desc.m_DimMappings[0] == 0
265 assert desc.m_DimMappings[1] == 2
266 assert desc.m_DimMappings[2] == 3
267 assert desc.m_DimMappings[3] == 1
268
269
270def test_pooling_descriptor_default_values():
271 desc = ann.Pooling2dDescriptor()
272 assert desc.m_PoolType == ann.PoolingAlgorithm_Max
273 assert desc.m_PadLeft == 0
274 assert desc.m_PadTop == 0
275 assert desc.m_PadRight == 0
276 assert desc.m_PadBottom == 0
277 assert desc.m_PoolHeight == 0
278 assert desc.m_PoolWidth == 0
279 assert desc.m_StrideX == 0
280 assert desc.m_StrideY == 0
281 assert desc.m_OutputShapeRounding == ann.OutputShapeRounding_Floor
282 assert desc.m_PaddingMethod == ann.PaddingMethod_Exclude
283 assert desc.m_DataLayout == ann.DataLayout_NCHW
284
285
286def test_reshape_descriptor_default_values():
287 desc = ann.ReshapeDescriptor()
288 # check the empty Targetshape
289 assert desc.m_TargetShape.GetNumDimensions() == 0
290
Ryan OShea09a05222021-11-18 16:52:41 +0000291def test_reduce_descriptor_default_values():
292 desc = ann.ReduceDescriptor()
293 assert desc.m_KeepDims == False
294 assert desc.m_vAxis == []
295 assert desc.m_ReduceOperation == ann.ReduceOperation_Sum
Richard Burtondc0c6ed2020-04-08 16:39:05 +0100296
297def test_slice_descriptor_default_values():
298 desc = ann.SliceDescriptor()
299 assert desc.m_TargetWidth == 0
300 assert desc.m_TargetHeight == 0
301 assert desc.m_Method == ann.ResizeMethod_NearestNeighbor
302 assert desc.m_DataLayout == ann.DataLayout_NCHW
303
304
305def test_resize_descriptor_default_values():
306 desc = ann.ResizeDescriptor()
307 assert desc.m_TargetWidth == 0
308 assert desc.m_TargetHeight == 0
309 assert desc.m_Method == ann.ResizeMethod_NearestNeighbor
310 assert desc.m_DataLayout == ann.DataLayout_NCHW
Kevin May1c6e9762020-06-03 16:05:00 +0100311 assert desc.m_AlignCorners == False
Richard Burtondc0c6ed2020-04-08 16:39:05 +0100312
313
314def test_spacetobatchnd_descriptor_default_values():
315 desc = ann.SpaceToBatchNdDescriptor()
316 assert desc.m_DataLayout == ann.DataLayout_NCHW
317
318
319def test_spacetodepth_descriptor_default_values():
320 desc = ann.SpaceToDepthDescriptor()
321 assert desc.m_BlockSize == 1
322 assert desc.m_DataLayout == ann.DataLayout_NHWC
323
324
325def test_stack_descriptor_default_values():
326 desc = ann.StackDescriptor()
327 assert desc.m_Axis == 0
328 assert desc.m_NumInputs == 0
329 # check the empty Inputshape
330 assert desc.m_InputShape.GetNumDimensions() == 0
331
332
333def test_slice_descriptor_default_values():
334 desc = ann.SliceDescriptor()
335 desc.m_Begin = [1, 2, 3, 4, 5]
336 desc.m_Size = (1, 2, 3, 4)
337
338 assert [1, 2, 3, 4, 5] == desc.m_Begin
339 assert [1, 2, 3, 4] == desc.m_Size
340
341
342def test_slice_descriptor_ctor():
343 desc = ann.SliceDescriptor([1, 2, 3, 4, 5], (1, 2, 3, 4))
344
345 assert [1, 2, 3, 4, 5] == desc.m_Begin
346 assert [1, 2, 3, 4] == desc.m_Size
347
348
349def test_strided_slice_descriptor_default_values():
350 desc = ann.StridedSliceDescriptor()
351 desc.m_Begin = [1, 2, 3, 4, 5]
352 desc.m_End = [6, 7, 8, 9, 10]
353 desc.m_Stride = (10, 10)
354 desc.m_BeginMask = 1
355 desc.m_EndMask = 2
356 desc.m_ShrinkAxisMask = 3
357 desc.m_EllipsisMask = 4
358 desc.m_NewAxisMask = 5
359
360 assert [1, 2, 3, 4, 5] == desc.m_Begin
361 assert [6, 7, 8, 9, 10] == desc.m_End
362 assert [10, 10] == desc.m_Stride
363 assert 1 == desc.m_BeginMask
364 assert 2 == desc.m_EndMask
365 assert 3 == desc.m_ShrinkAxisMask
366 assert 4 == desc.m_EllipsisMask
367 assert 5 == desc.m_NewAxisMask
368
369
370def test_strided_slice_descriptor_ctor():
371 desc = ann.StridedSliceDescriptor([1, 2, 3, 4, 5], [6, 7, 8, 9, 10], (10, 10))
372 desc.m_Begin = [1, 2, 3, 4, 5]
373 desc.m_End = [6, 7, 8, 9, 10]
374 desc.m_Stride = (10, 10)
375
376 assert [1, 2, 3, 4, 5] == desc.m_Begin
377 assert [6, 7, 8, 9, 10] == desc.m_End
378 assert [10, 10] == desc.m_Stride
379
380
381def test_softmax_descriptor_default_values():
382 desc = ann.SoftmaxDescriptor()
383 assert desc.m_Axis == -1
384 np.allclose(1.0, desc.m_Beta)
385
386
387def test_space_to_batch_nd_descriptor_default_values():
388 desc = ann.SpaceToBatchNdDescriptor()
389 assert [1, 1] == desc.m_BlockShape
390 assert [(0, 0), (0, 0)] == desc.m_PadList
391 assert ann.DataLayout_NCHW == desc.m_DataLayout
392
393
394def test_space_to_batch_nd_descriptor_assigned_values():
395 desc = ann.SpaceToBatchNdDescriptor()
396 desc.m_BlockShape = (90, 100)
397 desc.m_PadList = [(1, 2), (3, 4)]
398 assert [90, 100] == desc.m_BlockShape
399 assert [(1, 2), (3, 4)] == desc.m_PadList
400 assert ann.DataLayout_NCHW == desc.m_DataLayout
401
402
403def test_space_to_batch_nd_descriptor_ctor():
404 desc = ann.SpaceToBatchNdDescriptor((1, 2, 3), [(1, 2), (3, 4)])
405 assert [1, 2, 3] == desc.m_BlockShape
406 assert [(1, 2), (3, 4)] == desc.m_PadList
407 assert ann.DataLayout_NCHW == desc.m_DataLayout
408
409
410def test_transpose_convolution2d_descriptor_default_values():
Jan Eilers841aca12020-08-12 14:59:06 +0100411 desc = ann.TransposeConvolution2dDescriptor()
Richard Burtondc0c6ed2020-04-08 16:39:05 +0100412 assert desc.m_PadLeft == 0
413 assert desc.m_PadTop == 0
414 assert desc.m_PadRight == 0
415 assert desc.m_PadBottom == 0
416 assert desc.m_StrideX == 0
417 assert desc.m_StrideY == 0
418 assert desc.m_BiasEnabled == False
419 assert desc.m_DataLayout == ann.DataLayout_NCHW
Jan Eilers841aca12020-08-12 14:59:06 +0100420 assert desc.m_OutputShapeEnabled == False
Richard Burtondc0c6ed2020-04-08 16:39:05 +0100421
Cathal Corbett2b4182f2021-11-18 10:28:47 +0000422def test_transpose_descriptor_default_values():
423 pv = ann.PermutationVector((0, 3, 2, 1, 4))
424 desc = ann.TransposeDescriptor(pv)
425 assert desc.m_DimMappings.GetSize() == 5
426 assert desc.m_DimMappings[0] == 0
427 assert desc.m_DimMappings[1] == 3
428 assert desc.m_DimMappings[2] == 2
429 assert desc.m_DimMappings[3] == 1
430 assert desc.m_DimMappings[4] == 4
Richard Burtondc0c6ed2020-04-08 16:39:05 +0100431
432def test_view_descriptor_default_values():
433 desc = ann.SplitterDescriptor()
434 assert 0 == desc.GetNumViews()
435 assert 0 == desc.GetNumDimensions()
436
437
438def test_elementwise_unary_descriptor_default_values():
439 desc = ann.ElementwiseUnaryDescriptor()
440 assert desc.m_Operation == ann.UnaryOperation_Abs
441
442
Cathal Corbettf0836e02021-11-18 18:17:38 +0000443def test_logical_binary_descriptor_default_values():
444 desc = ann.LogicalBinaryDescriptor()
445 assert desc.m_Operation == ann.LogicalBinaryOperation_LogicalAnd
446
Richard Burtondc0c6ed2020-04-08 16:39:05 +0100447def test_view_descriptor_incorrect_input():
448 desc = ann.SplitterDescriptor(2, 3)
449 with pytest.raises(RuntimeError) as err:
450 desc.SetViewOriginCoord(1000, 100, 1000)
451 assert "Failed to set view origin coordinates." in str(err.value)
452
453 with pytest.raises(RuntimeError) as err:
454 desc.SetViewSize(1000, 100, 1000)
455 assert "Failed to set view size." in str(err.value)
456
457
458def test_view_descriptor_ctor():
459 desc = ann.SplitterDescriptor(2, 3)
460 value_size = 1
461 value_orig_coord = 5
462 for i in range(desc.GetNumViews()):
463 for j in range(desc.GetNumDimensions()):
464 desc.SetViewOriginCoord(i, j, value_orig_coord+i)
465 desc.SetViewSize(i, j, value_size+i)
466
467 assert 2 == desc.GetNumViews()
468 assert 3 == desc.GetNumDimensions()
469 assert [5, 5] == desc.GetViewOrigin(0)
470 assert [6, 6] == desc.GetViewOrigin(1)
471 assert [1, 1] == desc.GetViewSizes(0)
472 assert [2, 2] == desc.GetViewSizes(1)
473
474
475def test_createdescriptorforconcatenation_ctor():
476 input_shape_vector = [ann.TensorShape((2, 1)), ann.TensorShape((3, 1)), ann.TensorShape((4, 1))]
477 desc = ann.CreateDescriptorForConcatenation(input_shape_vector, 0)
478 assert 3 == desc.GetNumViews()
479 assert 0 == desc.GetConcatAxis()
480 assert 2 == desc.GetNumDimensions()
481 c = desc.GetViewOrigin(1)
482 d = desc.GetViewOrigin(0)
483
484
485def test_createdescriptorforconcatenation_wrong_shape_for_axis():
486 input_shape_vector = [ann.TensorShape((1, 2)), ann.TensorShape((3, 4)), ann.TensorShape((5, 6))]
487 with pytest.raises(RuntimeError) as err:
488 desc = ann.CreateDescriptorForConcatenation(input_shape_vector, 0)
489
490 assert "All inputs to concatenation must be the same size along all dimensions except the concatenation dimension" in str(
491 err.value)
492
493
494@pytest.mark.parametrize("input_shape_vector", [([-1, "one"]),
495 ([1.33, 4.55]),
496 ([{1: "one"}])], ids=lambda x: str(x))
497def test_createdescriptorforconcatenation_rubbish_assignment_shape_vector(input_shape_vector):
498 with pytest.raises(TypeError) as err:
499 desc = ann.CreateDescriptorForConcatenation(input_shape_vector, 0)
500
501 assert "in method 'CreateDescriptorForConcatenation', argument 1 of type 'std::vector< armnn::TensorShape,std::allocator< armnn::TensorShape > >'" in str(
502 err.value)
503
504
505generated_classes = inspect.getmembers(generated, inspect.isclass)
506generated_classes_names = list(map(lambda x: x[0], generated_classes))
507@pytest.mark.parametrize("desc_name", ['ActivationDescriptor',
508 'ArgMinMaxDescriptor',
509 'PermuteDescriptor',
510 'SoftmaxDescriptor',
511 'ConcatDescriptor',
512 'SplitterDescriptor',
513 'Pooling2dDescriptor',
514 'FullyConnectedDescriptor',
515 'Convolution2dDescriptor',
Teresa Charlin18147332021-11-17 14:34:30 +0000516 'Convolution3dDescriptor',
Richard Burtondc0c6ed2020-04-08 16:39:05 +0100517 'DepthwiseConvolution2dDescriptor',
518 'DetectionPostProcessDescriptor',
519 'NormalizationDescriptor',
520 'L2NormalizationDescriptor',
521 'BatchNormalizationDescriptor',
522 'InstanceNormalizationDescriptor',
523 'BatchToSpaceNdDescriptor',
524 'FakeQuantizationDescriptor',
Ryan OShea09a05222021-11-18 16:52:41 +0000525 'ReduceDescriptor',
Richard Burtondc0c6ed2020-04-08 16:39:05 +0100526 'ResizeDescriptor',
527 'ReshapeDescriptor',
528 'SpaceToBatchNdDescriptor',
529 'SpaceToDepthDescriptor',
530 'LstmDescriptor',
531 'MeanDescriptor',
532 'PadDescriptor',
533 'SliceDescriptor',
534 'StackDescriptor',
535 'StridedSliceDescriptor',
536 'TransposeConvolution2dDescriptor',
Cathal Corbett2b4182f2021-11-18 10:28:47 +0000537 'TransposeDescriptor',
Jan Eilers841aca12020-08-12 14:59:06 +0100538 'ElementwiseUnaryDescriptor',
539 'FillDescriptor',
Cathal Corbettf0836e02021-11-18 18:17:38 +0000540 'GatherDescriptor',
Teresa Charlinf7b50112021-11-18 15:24:50 +0000541 'LogicalBinaryDescriptor',
542 'ChannelShuffleDescriptor'])
Richard Burtondc0c6ed2020-04-08 16:39:05 +0100543class TestDescriptorMassChecks:
544
545 def test_desc_implemented(self, desc_name):
546 assert desc_name in generated_classes_names
547
548 def test_desc_equal(self, desc_name):
549 desc_class = next(filter(lambda x: x[0] == desc_name, generated_classes))[1]
550
551 assert desc_class() == desc_class()
552
553
554generated_classes = inspect.getmembers(generated, inspect.isclass)
555generated_classes_names = list(map(lambda x: x[0], generated_classes))
556@pytest.mark.parametrize("desc_name", ['ActivationDescriptor',
557 'ArgMinMaxDescriptor',
558 'PermuteDescriptor',
559 'SoftmaxDescriptor',
560 'ConcatDescriptor',
561 'SplitterDescriptor',
562 'Pooling2dDescriptor',
563 'FullyConnectedDescriptor',
564 'Convolution2dDescriptor',
Teresa Charlin18147332021-11-17 14:34:30 +0000565 'Convolution3dDescriptor',
Richard Burtondc0c6ed2020-04-08 16:39:05 +0100566 'DepthwiseConvolution2dDescriptor',
567 'DetectionPostProcessDescriptor',
568 'NormalizationDescriptor',
569 'L2NormalizationDescriptor',
570 'BatchNormalizationDescriptor',
571 'InstanceNormalizationDescriptor',
572 'BatchToSpaceNdDescriptor',
573 'FakeQuantizationDescriptor',
Ryan OShea09a05222021-11-18 16:52:41 +0000574 'ReduceDescriptor',
Richard Burtondc0c6ed2020-04-08 16:39:05 +0100575 'ResizeDescriptor',
576 'ReshapeDescriptor',
577 'SpaceToBatchNdDescriptor',
578 'SpaceToDepthDescriptor',
579 'LstmDescriptor',
580 'MeanDescriptor',
581 'PadDescriptor',
582 'SliceDescriptor',
583 'StackDescriptor',
584 'StridedSliceDescriptor',
585 'TransposeConvolution2dDescriptor',
Cathal Corbett2b4182f2021-11-18 10:28:47 +0000586 'TransposeDescriptor',
Jan Eilers841aca12020-08-12 14:59:06 +0100587 'ElementwiseUnaryDescriptor',
588 'FillDescriptor',
Cathal Corbettf0836e02021-11-18 18:17:38 +0000589 'GatherDescriptor',
Teresa Charlinf7b50112021-11-18 15:24:50 +0000590 'LogicalBinaryDescriptor',
591 'ChannelShuffleDescriptor'])
Richard Burtondc0c6ed2020-04-08 16:39:05 +0100592class TestDescriptorMassChecks:
593
594 def test_desc_implemented(self, desc_name):
595 assert desc_name in generated_classes_names
596
597 def test_desc_equal(self, desc_name):
598 desc_class = next(filter(lambda x: x[0] == desc_name, generated_classes))[1]
599
600 assert desc_class() == desc_class()
601