Skip to content

🐍 Geometric Computer Vision Library for Spatial AI

630 B
Raw Blame

On MPS, match_snn and match_smnn find the nearest and second-nearest distance of each descriptor with two row reductions instead of torch.topk, with the same matches and ratios, nan and infinite distances included. On an Apple M1, given 2048 x 2048 to 8000 x 8000 distance matrices, match_snn is 2.3x faster and match_smnn 1.5-1.8x faster; with the distance computation, both are 1.2-1.7x faster. The reductions take a transient copy of the distance matrix, 2.25 times its size for match_smnn. CPU and CUDA keep torch.topk, which is faster there: the reductions were 2-5x slower on an x86 CPU and no faster on CUDA.