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

Function test_tensorbatch_change_layout

tests/cvcuda/python/test_tensor_batch.py:82–111  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

80
81
82def test_tensorbatch_change_layout():
83 batch = cvcuda.TensorBatch(10)
84 tensorsA = random_tensors(5, np.float32, 3, "HWC")
85 batch.pushback(tensorsA)
86 assert list(batch) == tensorsA
87 assert batch.layout == "HWC"
88 assert batch.dtype == np.float32
89 assert batch.ndim == 3
90
91 batch.popback(len(tensorsA))
92 assert list(batch) == []
93 assert batch.layout is None
94 assert batch.dtype is None
95 assert batch.ndim == -1
96
97 tensorsB = [
98 cvcuda.as_tensor(cvcuda.Image(rand_shape(2), cvcuda.Format.RGBA8))
99 for _ in range(7)
100 ]
101 batch.pushback(tensorsB)
102 assert list(batch) == tensorsB
103 assert batch.layout == "NHWC"
104 assert batch.dtype == np.uint8
105 assert batch.ndim == 4
106
107 batch.clear()
108 assert list(batch) == []
109 assert batch.layout is None
110 assert batch.dtype is None
111 assert batch.ndim == -1
112
113
114def test_tensorbatch_multiply_tensors():

Callers

nothing calls this directly

Calls 5

clearMethod · 0.95
random_tensorsFunction · 0.85
rand_shapeFunction · 0.85
TensorBatchMethod · 0.45
ImageMethod · 0.45

Tested by

no test coverage detected