submission 170671
Nader · python · License unknown
Kernel source · 56 lines ↓holds 1 record
Use it
Vendorable · source mirrored · license unknownView source →
No package. Vendor the mirrored source: 56 lines, June 9 Researcher Reciprocity License v1.0.
grayscale_v2.py
curl "https://kernelindex.com/api/v1/implementations/kernelbot-grayscale-v2-170671?include=source"interfacepython
Compatibility
measured onNVIDIA L4
declared hardwareNVIDIA L4
architecturessm_89
dtypesfp32
Benchmark evidence
1 measurement across 1 GPU, fastest first.
Operation / workload
Hardware
Latency
Rank
Observed
Reported · How evidence levels are derived →
Source and license
sourceavailable
revision digestsha256:1ce58bd8f5109b554b7dd065330809d054dfbff688a6fb9c88ee26f749a317a2
license declaredunknown
license concludedunknown
authorsNader
imported2026-08-15
Kernel source
grayscale_v2.py56 lines
#!POPCORN leaderboard grayscale_v2
# This is a submission template for popcorn leaderboard 'grayscale_v2'.
# Your task is as follows:
# > Implement an RGB to grayscale conversion kernel that matches the reference implementation.
# > The kernel should convert square RGB images with even sizes to grayscale using the standard coefficients:
# > Y = 0.2989 R + 0.5870 G + 0.1140 B
# >
# > Input: RGB tensor of shape (H, W, 3) with values in [0, 1]
# > Output: Grayscale tensor of shape (H, W) with values in [0, 1]
# The deadline for this leaderboard is 2025-12-30 00:00:00+00:00
# You can automatically route this file to specific GPUs by adding a line
# `#!POPCORN gpus <GPUs>` to the header of this file.
# Happy hacking!
import subprocess
subprocess.run(["pip", "install", "cuda-cccl[cu12]==0.4.3"])
subprocess.run(["pip", "install", "cupy-cuda12x"])
from task import input_t, output_t
import cuda.compute
from cuda.compute import gpu_struct
import cupy as cp
import numpy as np
import torch
@gpu_struct
class Pixel:
r: np.float32
g: np.float32
b: np.float32
def as_grayscale(p: Pixel) -> np.float32:
return (
np.float32(0.2989) * p.r +
np.float32(0.587) * p.g +
np.float32(0.114) * p.b
)
build_in = cp.empty(1, dtype=Pixel)
build_out = torch.empty(1, dtype=torch.float32, device="cuda")
transformer = cuda.compute.make_unary_transform(build_in, build_out, as_grayscale)
def custom_kernel(data: input_t) -> output_t:
d_in, d_out = data
size = len(d_in)
transformer(d_in, d_out, size * size)
return d_out
scrolls · 56 lines total
Source code from GPU Mode and the KernelBot dataset · June 9 Researcher Reciprocity License v1.0
Changes from previous submission
Against this author's previous submission submission 170670.
Best evidence level for this revision: reported
JSON