Skip to content
Discussion options

You must be logged in to vote

It doesn't but you could implement it manually via the following, though it wouldn't be very efficient.

let x1 = x1.unsqueeze(1)?;
let x2 = x2.unsqueeze(2)?;
let cdist = x1.broadcast_sub(&x2)?.sqr()?.sum(D::Minus1)?.sqrt()?;

If this ends up being an issue performance wise, you could also write a custom op for it, e.g. in encodec we have such a custom kernel here though it applies both a cdist and an argmin in the same kernel.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by vishpat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants