MCPcopy Create free account
hub / github.com/NVIDIA/DALI / test_tuples

Function test_tuples

dali/test/python/conditionals/test_nests.py:110–130  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

108
109
110def test_tuples():
111 @pipeline_def(enable_conditionals=True, num_threads=4, batch_size=8, device_id=0)
112 def pipeline():
113 pred = fn.external_source(source=lambda x: np.array(x.idx_in_batch % 2), batch=False)
114 data = types.Constant(np.array(42), device="cpu")
115 if pred:
116 out = (data, data + 10, data + 20)
117 else:
118 out = (np.array(-10), data, data * 2)
119 a, b, c = out
120 return a, b, c
121
122 pipe = pipeline()
123 (
124 a,
125 b,
126 c,
127 ) = pipe.run()
128 check_batch(a, [42 if i % 2 else -10 for i in range(8)])
129 check_batch(b, [52 if i % 2 else 42 for i in range(8)])
130 check_batch(c, [62 if i % 2 else 84 for i in range(8)])
131
132
133def test_nesting_error():

Callers

nothing calls this directly

Calls 3

check_batchFunction · 0.90
pipelineFunction · 0.70
runMethod · 0.45

Tested by

no test coverage detected