PyTorch eager
PyTorch · python · MIT
Use it
Vendorable · source mirrored · MITView source →
No package. Vendor the mirrored source: 25 lines, MIT.
100_HingeLoss.py
curl "https://kernelindex.com/api/v1/implementations/kernelbench-l1-100-hingeloss-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.
Reported · How evidence levels are derived →
Source and license
sourceavailable
revision digestsha256:b05982e94da5ecc61e45d3a439b9a995d527496fbfc3cd823ffac3cbaae6604a
license declaredMIT
license concludedMIT
imported2026-08-26
Kernel source
100_HingeLoss.py25 lines
import torch
import torch.nn as nn
class Model(nn.Module):
"""
A model that computes Hinge Loss for binary classification tasks.
Parameters:
None
"""
def __init__(self):
super(Model, self).__init__()
def forward(self, predictions, targets):
return torch.mean(torch.clamp(1 - predictions * targets, min=0))
batch_size = 32768
input_shape = (32768,)
dim = 1
def get_inputs():
return [torch.rand(batch_size, *input_shape), torch.randint(0, 2, (batch_size,)).float() * 2 - 1]
def get_init_inputs():
return []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