Skip to content
KernelIndex
Search⌘K

submission 571245

Pouya Hamadanian · python · License unknown

Use it

Vendorable · source mirrored · license unknownView source →

No package. Vendor the mirrored source: 45 lines, June 9 Researcher Reciprocity License v1.0.

submission.py
curl "https://kernelindex.com/api/v1/implementations/kernelbot-grayscale-v2-571245?include=source"
interfacepython
Compatibility
measured onNVIDIA H100
declared hardwareNVIDIA H100
architecturessm_90
dtypesfp32

Benchmark evidence

1 measurement across 1 GPU, fastest first.

Operation / workload
Hardware
Latency
Rank
Observed
RGB to grayscalesuite of 6 cases
NVIDIA H100
1.37ms
#7 of 36
2026-03-16

Reported · How evidence levels are derived →

Source and license

sourceavailable
revision digestsha256:3ea4e94f4e7357006f5017c805708f422d584b0d3c29591f5b2e4e8a5b109368
license declaredunknown
license concludedunknown
authorsPouya Hamadanian
imported2026-08-15

Techniques

Extracted from the mirrored source by pattern, never inferred. Each row cites its line.

autotune@triton.autotune(
stages = 1triton.Config({"BLOCK_SIZE": block_size}, num_warps=num_warps, num_stages=1)

Kernel source

submission.py45 lines
import triton
import triton.language as tl

from task import input_t, output_t


@triton.autotune(
    configs=[
        triton.Config({"BLOCK_SIZE": block_size}, num_warps=num_warps, num_stages=1)
        for block_size in (256, 512, 1024, 2048)
        for num_warps in (4, 8)
    ],
    key=["n"],
)
@triton.jit
def _rgb_to_grayscale_kernel(
    x_ptr,
    out_ptr,
    n,
    BLOCK_SIZE: tl.constexpr,
):
    pid = tl.program_id(0)
    offs = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)
    mask = offs < n

    base = offs * 3
    r = tl.load(x_ptr + base, mask=mask, other=0.0)
    g = tl.load(x_ptr + base + 1, mask=mask, other=0.0)
    b = tl.load(x_ptr + base + 2, mask=mask, other=0.0)

    y = 0.2989 * r + 0.5870 * g + 0.1140 * b
    tl.store(out_ptr + offs, y, mask=mask)


# Keep a module-local alias to minimize attribute lookups in the timed path.
_launch_kernel = _rgb_to_grayscale_kernel
_cdiv = triton.cdiv


def custom_kernel(data: input_t) -> output_t:
    x, output = data
    n = output.numel()
    grid = lambda meta: (_cdiv(n, meta["BLOCK_SIZE"]),)
    _launch_kernel[grid](x, output, n)
    return output
scrolls · 45 lines total

Source code from GPU Mode and the KernelBot dataset · June 9 Researcher Reciprocity License v1.0

Best evidence level for this revision: reported

JSON