Question
You are reviewing a numerical module and need to explain the computational cost of its core operations before proposing a cleaner design. Implement `op_complexity(op, n, d=64, k=3, c=16)`. Return a dictionary with `time` and `space` complexity strings for the requested operation: - `matmul`: multiplying two square `n × n` matrices - `attention`: self-attention over a sequence of length `n` and hidden width `d` - `conv`: a spatial convolution over an `n × n` feature map with kernel width `k` and `c` channels Be prepared to explain how you would split a large PyTorch module into testable components, isolate configuration, and make edge cases explicit. ## Follow-ups 1. Add batch dimensions and state the resulting complexity. 2. Identify which operator becomes the memory bottleneck as sequence length grows. 3. Propose tests that make a behavior-preserving refactor safe.