MCPcopy Create free account
hub / github.com/YesianRohn/TextSSR / torch_all_close

Function torch_all_close

diffusers/src/diffusers/utils/testing_utils.py:94–99  ·  view source on GitHub ↗
(a, b, *args, **kwargs)

Source from the content-addressed store, hash-verified

92
93
94def torch_all_close(a, b, *args, **kwargs):
95 if not is_torch_available():
96 raise ValueError("PyTorch needs to be installed to use this function.")
97 if not torch.allclose(a, b, *args, **kwargs):
98 assert False, f"Max diff is absolute {(a - b).abs().max()}. Diff tensor is {(a - b).abs()}."
99 return True
100
101
102def numpy_cosine_similarity_distance(a, b):

Calls 1

is_torch_availableFunction · 0.85

Tested by

no test coverage detected