PyTorch eager
PyTorch · python · MIT
Kernel source · 33 lines ↓holds 2 records
Use it
Vendorable · source mirrored · MITView source →
No package. Vendor the mirrored source: 33 lines, MIT.
5_Matrix_scalar_multiplication.py
curl "https://kernelindex.com/api/v1/implementations/kernelbench-l1-5-matrix-scalar-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:8b7e16fda93471e42b4d94b914c64cb1085e5581111dac2944d4716da3cba10b
license declaredMIT
license concludedMIT
imported2026-08-26
Kernel source
5_Matrix_scalar_multiplication.py33 lines
import torch
import torch.nn as nn
class Model(nn.Module):
"""
Simple model that performs a matrix-scalar multiplication (C = A * s)
"""
def __init__(self):
super(Model, self).__init__()
def forward(self, A: torch.Tensor, s: float) -> torch.Tensor:
"""
Performs matrix-scalar multiplication.
Args:
A: Input matrix of shape (M, N)
s: Scalar value
Returns:
C: Resulting matrix of shape (M, N)
"""
return A * s
M = 16384 * 4
N = 4096 * 4
def get_inputs():
A = torch.rand(M, N)
s = 3.14
return [A, s]
def get_init_inputs():
return [] # No special initialization inputs neededscrolls · 33 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