PyTorch eager
PyTorch · python · MIT
Kernel source · 35 lines ↓holds 2 records
Use it
Vendorable · source mirrored · MITView source →
No package. Vendor the mirrored source: 35 lines, MIT.
10_3D_tensor_matrix_multiplication.py
curl "https://kernelindex.com/api/v1/implementations/kernelbench-l1-10-3d-tensor-matrix-multiplication-torch?include=source"interfacepython · torch_eager
symbolModel.forward
Compatibility
measured onNVIDIA H100
declared hardwaredeclared only
architectures—
dtypes
Benchmark evidence
2 measurements across 1 GPU, fastest first.
Operation / workload
Hardware
Latency
Rank
Observed
Reported · How evidence levels are derived →
Source and license
sourceavailable
revision digestsha256:271540eaaee40be8a6e862b9ca8a6fdd1f525505aefbc1ab4918a1ff6ed437f5
license declaredMIT
license concludedMIT
imported2026-08-26
Kernel source
10_3D_tensor_matrix_multiplication.py35 lines
import torch
import torch.nn as nn
class Model(nn.Module):
"""
Performs 3D tensor-matrix multiplication.
"""
def __init__(self):
super(Model, self).__init__()
def forward(self, A, B):
"""
Performs 3D tensor-matrix multiplication.
Args:
A (torch.Tensor): Input 3D tensor of shape (N, M, K).
B (torch.Tensor): Input matrix of shape (K, L).
Returns:
torch.Tensor: Output tensor of shape (N, M, L), resulting from the multiplication of A and B along the last dimension of A.
"""
return torch.matmul(A, B)
N = 16
M = 1024
K = 2048
L = 768
def get_inputs():
A = torch.rand(N, M, K)
B = torch.rand(K, L)
return [A, B]
def get_init_inputs():
return [] # No special initialization inputs neededscrolls · 35 lines total
Source code from KernelBench, © 2023 Anne Ouyang, Simon Guo, Azalia Mirhoseini (Scaling Intelligence Lab, Stanford University), MIT License · MIT
Best evidence level for this revision: reported
JSON