Checks the outputs of the pipeline. `outputs` return value from pipeline `run` `ref_out` a batch or tuple of batches `ref_is_list_of_outputs` only meaningful when there's just one output - if True, ref_out is a one-element list containing a single batch f
(outputs, ref_out, ref_is_list_of_outputs=None)
| 527 | |
| 528 | |
| 529 | def check_output(outputs, ref_out, ref_is_list_of_outputs=None): |
| 530 | """Checks the outputs of the pipeline. |
| 531 | |
| 532 | `outputs` |
| 533 | return value from pipeline `run` |
| 534 | `ref_out` |
| 535 | a batch or tuple of batches |
| 536 | `ref_is_list_of_outputs` |
| 537 | only meaningful when there's just one output - if True, ref_out is a one-element |
| 538 | list containing a single batch for output 0; otherwise ref_out _is_ a batch |
| 539 | """ |
| 540 | import_numpy() |
| 541 | if ref_is_list_of_outputs is None: |
| 542 | ref_is_list_of_outputs = len(outputs) > 1 |
| 543 | |
| 544 | assert ref_is_list_of_outputs or (len(outputs) == 1) |
| 545 | |
| 546 | for idx in range(len(outputs)): |
| 547 | out = outputs[idx] |
| 548 | ref = ref_out[idx] if ref_is_list_of_outputs else ref_out |
| 549 | out = out.as_cpu() |
| 550 | for i in range(len(out)): |
| 551 | if not np.array_equal(out[i], ref[i]): |
| 552 | print("Mismatch at sample", i) |
| 553 | print("Out: ", out.at(i)) |
| 554 | print("Ref: ", ref[i]) |
| 555 | assert np.array_equal(out[i], ref[i]) |
| 556 | |
| 557 | |
| 558 | def dali_type(t): |
no test coverage detected