PyTorch eager
PyTorch · python · MIT
Kernel source · 44 lines ↓holds 2 records
Use it
Vendorable · source mirrored · MITView source →
No package. Vendor the mirrored source: 44 lines, MIT.
14_Matmul_for_upper_triangular_matrices.py
curl "https://kernelindex.com/api/v1/implementations/kernelbench-l1-14-matmul-for-upper-triangular-matrices-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:051f7d46834f13c1e7ac69222a2eb74690bd51efe876874ca53293ce5b75fdfb
license declaredMIT
license concludedMIT
imported2026-08-26
Kernel source
14_Matmul_for_upper_triangular_matrices.py44 lines
import torch
import torch.nn as nn
class Model(nn.Module):
"""
Simple model that performs matrix multiplication (C = A * B) for upper triangular matrices.
"""
def __init__(self):
super(Model, self).__init__()
def forward(self, A, B):
"""
Performs matrix multiplication for upper triangular matrices.
Args:
A (torch.Tensor): Upper triangular matrix of shape (N, N).
B (torch.Tensor): Upper triangular matrix of shape (N, N).
Returns:
torch.Tensor: The product of A and B, also an upper triangular matrix of shape (N, N).
"""
return torch.triu(torch.matmul(A, B))
N = 4096
def get_inputs():
"""
Generates upper triangular matrices for testing.
Returns:
list: A list containing two upper triangular matrices of shape (N, N).
"""
A = torch.triu(torch.rand(N, N))
B = torch.triu(torch.rand(N, N))
return [A, B]
def get_init_inputs():
"""
No specific initialization inputs are needed for this model.
Returns:
list: An empty list.
"""
return []scrolls · 44 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