()
| 79 | |
| 80 | |
| 81 | def test_dicts(): |
| 82 | @pipeline_def(enable_conditionals=True, num_threads=4, batch_size=8, device_id=0) |
| 83 | def pipeline(): |
| 84 | pred = fn.external_source(source=lambda x: np.array(x.idx_in_batch % 2), batch=False) |
| 85 | if pred: |
| 86 | out = {"out": np.array(2)} |
| 87 | else: |
| 88 | out = {"out": np.array(1)} |
| 89 | return out["out"] |
| 90 | |
| 91 | pipe = pipeline() |
| 92 | (out,) = pipe.run() |
| 93 | check_batch(out, [i % 2 + 1 for i in range(8)]) |
| 94 | |
| 95 | @pipeline_def(enable_conditionals=True, num_threads=4, batch_size=8, device_id=0) |
| 96 | def pipeline_op(): |
| 97 | pred = fn.external_source(source=lambda x: np.array(x.idx_in_batch % 2), batch=False) |
| 98 | data = types.Constant(np.array(42), device="cpu") |
| 99 | if pred: |
| 100 | out = {"out": data - 1} |
| 101 | else: |
| 102 | out = {"out": data + 1} |
| 103 | return out["out"] |
| 104 | |
| 105 | pipe_op = pipeline_op() |
| 106 | (out,) = pipe_op.run() |
| 107 | check_batch(out, [41 if i % 2 else 43 for i in range(8)]) |
| 108 | |
| 109 | |
| 110 | def test_tuples(): |
nothing calls this directly
no test coverage detected