Skip to content
Merged
Show file tree
Hide file tree
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
15 changes: 6 additions & 9 deletions docarray/math/distance/torch.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ def cosine(
:param device: the computational device for `embed_model`, can be either `cpu` or `cuda`.
:return: np.ndarray with ndim=2
"""
if device == 'cuda':
x_mat = x_mat.cuda()
y_mat = y_mat.cuda()
x_mat = x_mat.to(device)
y_mat = y_mat.to(device)

a_n, b_n = x_mat.norm(dim=1)[:, None], y_mat.norm(dim=1)[:, None]
a_norm = x_mat / torch.clamp(a_n, min=eps)
Expand All @@ -37,9 +36,8 @@ def euclidean(x_mat: 'tensor', y_mat: 'tensor', device: str = 'cpu') -> 'numpy.n
:param device: the computational device for `embed_model`, can be either `cpu` or `cuda`.
:return: np.ndarray with ndim=2
"""
if device == 'cuda':
x_mat = x_mat.cuda()
y_mat = y_mat.cuda()
x_mat = x_mat.to(device)
y_mat = y_mat.to(device)

return torch.cdist(x_mat, y_mat).cpu().detach().numpy()

Expand All @@ -54,8 +52,7 @@ def sqeuclidean(
:param device: the computational device for `embed_model`, can be either `cpu` or `cuda`.
:return: np.ndarray with ndim=2
"""
if device == 'cuda':
x_mat = x_mat.cuda()
y_mat = y_mat.cuda()
x_mat = x_mat.to(device)
y_mat = y_mat.to(device)

return (torch.cdist(x_mat, y_mat) ** 2).cpu().detach().numpy()
4 changes: 2 additions & 2 deletions docs/advanced/document-store/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,9 @@ DocArray supports multiple storage backends with different search features. The
| [`Sqlite`](./sqlite.md) | `DocumentArray(storage='sqlite')` | ❌ | ❌ | ✅ |
| [`Weaviate`](./weaviate.md) | `DocumentArray(storage='weaviate')` | ✅ | ✅ | ✅ |
| [`Qdrant`](./qdrant.md) | `DocumentArray(storage='qdrant')` | ✅ | ✅ | ❌ |
| [`Annlite`](./annlite.md) | `DocumentArray(storage='annlite')` | ✅ | ✅ | ✅ |
| [`Annlite`](./annlite.md) | `DocumentArray(storage='annlite')` | ✅ | ✅ | ✅ |
| [`ElasticSearch`](./elasticsearch.md) | `DocumentArray(storage='elasticsearch')` | ✅ | ✅ | ✅ |
| [`Redis`](./redis.md) | `DocumentArray(storage='elasticsearch')` | ✅ | ✅ | ✅ |
| [`Redis`](./redis.md) | `DocumentArray(storage='redis')` | ✅ | ✅ | ✅ |


Here we understand by
Expand Down