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

Function test_nesting_error

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

Source from the content-addressed store, hash-verified

131
132
133def test_nesting_error():
134 @pipeline_def(enable_conditionals=True, num_threads=4, batch_size=8, device_id=0)
135 def pipeline():
136 pred = fn.external_source(source=lambda x: np.array(x.idx_in_batch % 2), batch=False)
137 if pred:
138 out = {"out": np.array(2), "mismatched": np.array(9999)}
139 else:
140 out = {"out": np.array(1)}
141 return out
142
143 with assert_raises(
144 ValueError,
145 glob=(
146 "*Divergent data found in different branches of `if/else` control"
147 " flow statement. Variables in all code paths are merged into common"
148 " output batches. The values assigned to a given variable need to"
149 " have the same nesting structure in every code path (both `if` branches).*"
150 "'If' output structure:*"
151 "'Else' output structure:*"
152 ),
153 ):
154 _ = pipeline()

Callers

nothing calls this directly

Calls 2

assert_raisesFunction · 0.90
pipelineFunction · 0.70

Tested by

no test coverage detected