Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 34bf27f

Browse filesBrowse files
authored
fix(find): make device more generic (#515)
1 parent 459703e commit 34bf27f
Copy full SHA for 34bf27f

2 files changed

+8-11Lines changed: 8 additions & 11 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎docarray/math/distance/torch.py‎

Copy file name to clipboardExpand all lines: docarray/math/distance/torch.py
+6-9Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@ def cosine(
1818
:param device: the computational device for `embed_model`, can be either `cpu` or `cuda`.
1919
:return: np.ndarray with ndim=2
2020
"""
21-
if device == 'cuda':
22-
x_mat = x_mat.cuda()
23-
y_mat = y_mat.cuda()
21+
x_mat = x_mat.to(device)
22+
y_mat = y_mat.to(device)
2423

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

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

@@ -54,8 +52,7 @@ def sqeuclidean(
5452
:param device: the computational device for `embed_model`, can be either `cpu` or `cuda`.
5553
:return: np.ndarray with ndim=2
5654
"""
57-
if device == 'cuda':
58-
x_mat = x_mat.cuda()
59-
y_mat = y_mat.cuda()
55+
x_mat = x_mat.to(device)
56+
y_mat = y_mat.to(device)
6057

6158
return (torch.cdist(x_mat, y_mat) ** 2).cpu().detach().numpy()
Collapse file

‎docs/advanced/document-store/index.md‎

Copy file name to clipboardExpand all lines: docs/advanced/document-store/index.md
+2-2Lines changed: 2 additions & 2 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,9 @@ DocArray supports multiple storage backends with different search features. The
157157
| [`Sqlite`](./sqlite.md) | `DocumentArray(storage='sqlite')` ||||
158158
| [`Weaviate`](./weaviate.md) | `DocumentArray(storage='weaviate')` ||||
159159
| [`Qdrant`](./qdrant.md) | `DocumentArray(storage='qdrant')` ||||
160-
| [`Annlite`](./annlite.md) | `DocumentArray(storage='annlite')` ||||
160+
| [`Annlite`](./annlite.md) | `DocumentArray(storage='annlite')` ||||
161161
| [`ElasticSearch`](./elasticsearch.md) | `DocumentArray(storage='elasticsearch')` ||||
162-
| [`Redis`](./redis.md) | `DocumentArray(storage='elasticsearch')` ||||
162+
| [`Redis`](./redis.md) | `DocumentArray(storage='redis')` ||||
163163

164164

165165
Here we understand by

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.