Implement one-head scaled dot-product attention as a single fused CUDA kernel. You are given stored row-major and must write where
Softmax is row-wise and must be numerically stable (subtract the row max before expf). There is no causal mask and no batch or head dimension — one sequence, one head.
Suggested launch: one block per query row. That block computes the scores against every key, softmaxes them, and contracts with . and are small enough that the score row fits in shared memory.
Complete:
__global__ kernel that computes .void solve(const float* Q, const float* K, const float* V, float* O, int S, int D) where every pointer is a host pointer of length S * D. Allocate, copy in, launch, copy out, and free.Constraints: 1 <= S <= 16, 1 <= D <= 16. Do not write a main() in your solution.