(left, right)
| 69 | |
| 70 | |
| 71 | def assert_equal(left, right): |
| 72 | if torch.is_tensor(left): |
| 73 | assert left.shape == right.shape and left.dtype == right.dtype |
| 74 | assert torch.equal(left.contiguous().reshape(-1).view(torch.uint8), |
| 75 | right.contiguous().reshape(-1).view(torch.uint8)) |
| 76 | elif isinstance(left, dict): |
| 77 | assert left.keys() == right.keys() |
| 78 | for key in left: |
| 79 | assert_equal(left[key], right[key]) |
| 80 | elif isinstance(left, (tuple, list)): |
| 81 | assert type(left) is type(right) and len(left) == len(right) |
| 82 | for a, b in zip(left, right): |
| 83 | assert_equal(a, b) |
| 84 | else: |
| 85 | assert type(left) is type(right) and left == right |
| 86 | |
| 87 | |
| 88 | @pytest.mark.parametrize("stage", [0, 2, 3]) |
no test coverage detected