MCPcopy Create free account
hub / github.com/CVCUDA/CV-CUDA / test_tensor_reshape

Function test_tensor_reshape

tests/cvcuda/python/test_tensor.py:310–332  ·  view source on GitHub ↗
(orig_shape, orig_layout, dtype, shape_arg, layout_arg)

Source from the content-addressed store, hash-verified

308 ],
309)
310def test_tensor_reshape(orig_shape, orig_layout, dtype, shape_arg, layout_arg):
311 tensor = cvcuda.Tensor(orig_shape, dtype, layout=orig_layout, rowalign=1)
312
313 def strides(shape):
314 out = [0] * len(shape)
315 for d in range(len(shape)):
316 out[d] = 1
317 for d2 in range(d + 1, len(shape)):
318 out[d] = out[d] * shape[d2]
319 return tuple(out)
320
321 assert tensor.dtype == dtype
322 assert tensor.shape == orig_shape
323 assert tensor.cuda().strides == strides(orig_shape)
324
325 new_tensors = [
326 tensor.reshape(shape_arg, layout=layout_arg),
327 cvcuda.reshape(tensor, shape_arg, layout=layout_arg),
328 ]
329 for new_tensor in new_tensors:
330 assert new_tensor.dtype == dtype
331 assert new_tensor.shape == shape_arg
332 assert new_tensor.cuda().strides == strides(shape_arg)
333
334
335@t.mark.parametrize(

Callers

nothing calls this directly

Calls 5

cudaMethod · 0.95
reshapeMethod · 0.95
stridesFunction · 0.85
TensorMethod · 0.45
cudaMethod · 0.45

Tested by

no test coverage detected