Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to work with OutputDistances object? #95

Closed
hsm207 opened this issue Mar 4, 2024 · 5 comments
Closed

How to work with OutputDistances object? #95

hsm207 opened this issue Mar 4, 2024 · 5 comments

Comments

@hsm207
Copy link

hsm207 commented Mar 4, 2024

In simsimd 3.7.7, this code:

import simsimd
import numpy as np

X = np.array([[1, 2, 3]], dtype=np.float32)
Y = np.array([[4, 5, 6]], dtype=np.float32)

simsimd.cosine(X, Y)

returns

array([0.02940369], dtype=float32)

but in 3.9.0, it now returns:

<simsimd.OutputDistances at 0xffff6257ec70>

how do I get the result like in 3.7.7?

@ashvardanian
Copy link
Owner

Hi, @hsm207! Have you tried wrapping via np.array?

@ashvardanian
Copy link
Owner

I had to change this behavior to output a generic buffer instead of NumPy array, because the latter supports fewer platforms than SimSIMD, so we can’t always rely on NumPy types. The provided output, however, must be safely convertible to any tensor type in NumPy, PyTorch, TensorFlow, or any other numeric library.

I’m sorry for the inconvenience it may have caused, I didn’t realize many depended on the exact type. I can probably added to the README. Feel free to a documentation patch if you have a minute 🤗

@maiqingqiang
Copy link

Hi, @hsm207! Have you tried wrapping via np.array?

How to wrap it with np.array? Is there a reference example?

@ashvardanian
Copy link
Owner

Have you tried simply passing the output into the np.array function?

@ashvardanian
Copy link
Owner

Commit c09d895 explicitly describes conversion rules. Hope this helps 🤗

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants