(out)
| 737 | out = model(x) |
| 738 | |
| 739 | def check_out(out): |
| 740 | prec = 0.01 |
| 741 | try: |
| 742 | # We first try to assert the entire output if possible. This is not |
| 743 | # only the best way to assert results but also handles the cases |
| 744 | # where we need to create a new expected result. |
| 745 | _assert_expected(out.cpu(), model_name, prec=prec) |
| 746 | except AssertionError: |
| 747 | # Unfortunately some segmentation models are flaky with autocast |
| 748 | # so instead of validating the probability scores, check that the class |
| 749 | # predictions match. |
| 750 | expected_file = _get_expected_file(model_name) |
| 751 | expected = torch.load(expected_file, weights_only=True) |
| 752 | torch.testing.assert_close( |
| 753 | out.argmax(dim=1), expected.argmax(dim=1), rtol=prec, atol=prec, check_device=False |
| 754 | ) |
| 755 | return False # Partial validation performed |
| 756 | |
| 757 | return True # Full validation performed |
| 758 | |
| 759 | full_validation = check_out(out["out"]) |
| 760 |
no test coverage detected
searching dependent graphs…