Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions python/python/lance/torch/distance.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,9 @@ def pairwise_l2(
if x.dtype != y.dtype or (y2 is not None and x.dtype != y2.dtype):
raise ValueError("pairwise_l2 data types do not match")
origin_dtype = x.dtype
if x.device == torch.device("cpu") and x.dtype == torch.float16:
# Pytorch does not support `x @ y.T` for float16 on CPU
if x.device == torch.device("cpu") and x.dtype in (torch.float16, torch.bfloat16):
# Pytorch does not support `x @ y.T` for float16 on CPU, and bfloat16
# can hit backend-specific compiler paths. Accumulate in float32.
x = x.type(torch.float32)
y = y.type(torch.float32)
if y2 is not None:
Expand Down
Loading