Skip to content

🐍 Geometric Computer Vision Library for Spatial AI

622 B
Raw Blame

The DINOv2 attention of the DeDoDe G descriptor uses torch.nn.functional.scaled_dot_product_attention instead of materialising the attention weights of every head; only training mode with a non-zero attn_drop, which no kornia builder sets, still materialises them. On an Apple M1 the attention layer is about 2x faster on the CPU, and the whole 24-block ViT-L backbone 1.3x faster on the CPU at 476 x 644 and 1.1 to 1.2x faster on MPS at 476 x 644 and 784 x 784. The extra CPU memory of one attention layer at 784 x 784 falls from 1.3 GB to 73 MB, and the outputs agree with the previous ones to float32 rounding.