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

feat: make L2 generic to work with all float numbers #1532

Merged
merged 14 commits into from
Nov 7, 2023
Merged

Conversation

eddyxu
Copy link
Contributor

@eddyxu eddyxu commented Nov 6, 2023

No description provided.

@eddyxu eddyxu requested review from wjones127, westonpace and chebbyChefNEQ and removed request for wjones127 and westonpace November 6, 2023 23:10
@eddyxu eddyxu marked this pull request as ready for review November 6, 2023 23:11
@eddyxu eddyxu requested a review from rok November 7, 2023 17:07
y.chunks_exact(dimension)
.map(move |v| l2_once::<f32x16, 16>(x, v)),
),
_ => Box::new(y.chunks_exact(dimension).map(|v| Self::l2(x, v))),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this always resolve correctly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We let the caller to make sure y is a batch of centroids. Even the dimension is odd number, y.len() % dimension == 0. We could prob add a debug_assert here.

Copy link
Contributor

@rok rok left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!
A minor question about dimension matching in l2_batch.

@eddyxu eddyxu merged commit 011e119 into main Nov 7, 2023
15 checks passed
@eddyxu eddyxu deleted the lei/l2_improve branch November 7, 2023 17:39
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

Successfully merging this pull request may close these issues.

2 participants