File size: 408 Bytes
5fed0fc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import torch

def bmm(A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:
    """
    Baseline batched matrix multiplication using PyTorch.
    
    Args:
        A: Input tensor of shape (B, M, K)
        B: Input tensor of shape (B, K, N)
    
    Returns:
        Output tensor of shape (B, M, N)
    """
    # A:[B,M,K], B:[B,K,N] -> [B,M,N]
    return torch.bmm(A.float(), B.float()).to(torch.float16)