| 308 | ], |
| 309 | ) |
| 310 | def 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( |