nnf_pdist function

Pdist

Pdist

Computes the p-norm distance between every pair of row vectors in the input. This is identical to the upper triangular portion, excluding the diagonal, of torch_norm(input[:, None] - input, dim=2, p=p). This function will be faster if the rows are contiguous.

nnf_pdist(input, p = 2)

Arguments

  • input: input tensor of shape N×MN \times M.
  • p: p value for the p-norm distance to calculate between each vector pair [0,]\in [0, \infty].

Details

If input has shape N×MN \times M then the output will have shape 12N(N1)\frac{1}{2} N (N - 1).

  • Maintainer: Daniel Falbel
  • License: MIT + file LICENSE
  • Last published: 2025-02-14