GPUCodeForces/S1/25/prompt.txt

26 lines
769 B
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

Write a custom CUDA kernel for optimized matrix multiplication (GEMM).
The standard matrix multiplication is defined as:
C = A × B
Where A is of shape (M, K), B is of shape (K, N), and C is of shape (M, N).
You should optimize the matrix multiplication using:
1. Shared memory tiling for better memory access patterns
2. Coalesced memory access
3. Thread block tiling to maximize parallelism
4. Avoid redundant memory loads
The kernel should be significantly faster than PyTorch's default matmul implementation for large matrices.
You are given the following architecture:
import torch
import torch.nn as nn
class Model(nn.Module):
def __init__(self):
super(Model, self).__init__()
def forward(self, A, B):
return torch.matmul(A, B)