Loading...
The self-attention mechanism is a critical component of the Transformer architecture. It processes a sequence of N input vectors (tokens or patches), each with embedding dimension D.
The computation requires calculating pairwise affinities between every element (query q) and every other element (key k) in the sequence, typically followed by scaling and multiplying by the value matrix V.
Given:
Task: Determine the asymptotic time complexity for:
Return a tuple of strings representing both complexities.
N=100, D=512, K=3
("O(N^2*D)", "O(N*D^2*K^2)")Self-attention computes QK^T V where complexity is dominated by N×N attention matrix computation: O(N²D). Convolution operates on N spatial locations with D² channel interactions and K² kernel elements.