MCPcopy Create free account
hub / github.com/deepspeedai/DeepSpeed / assert_equal

Function assert_equal

tests/unit/runtime/test_determinism.py:71–85  ·  view source on GitHub ↗
(left, right)

Source from the content-addressed store, hash-verified

69
70
71def 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])

Callers 1

Calls 2

contiguousMethod · 0.80
reshapeMethod · 0.45

Tested by

no test coverage detected