You write custom CUDA kernels to replace PyTorch operators for speedups.
Implement Temperature Softmax Channel Affine: For x[N,C,H,W], scale[C], bias[C], and temperature t, compute z = x*scale + bias, then g = softmax(z/t) along channel axis for each (n,h,w), output y = g * x. Use a single CUDA block per spatial location, caching x and z/t in shared memory, with max-subtraction and reduction for the denominator, writing results in one pass. Provide a PyTorch reference with nn.Parameter scale, bias, temp. Accuracy rtol=1e-3.
