Skip to content
KernelIndex
Search⌘K

submission 443709

Ethan Boneh · python · License unknown

Use it

Vendorable · source mirrored · license unknownView source →

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

sample_kernel.py
curl "https://kernelindex.com/api/v1/implementations/kernelbot-grayscale-v2-443709?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
RGB to grayscalesuite of 6 cases
NVIDIA L4
17.1ms
#3 of 12
2026-02-03

Reported · How evidence levels are derived →

Source and license

sourceavailable
revision digestsha256:e7af7e0546eb2fadeb65b2203f18515098441c80249787c4db573586edab62b2
license declaredunknown
license concludedunknown
authorsEthan Boneh
imported2026-08-15

Techniques

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

num-warps = 8num_warps=8,
stages = 4num_stages=4

Kernel source

sample_kernel.py36 lines
import torch                                                                                                                                                                                   
import triton                                                                                                                                                                                  
import triton.language as tl                                                                                                                                                                   
                                                                                                                                                                                                
@triton.jit                                                                                                                                                                                    
def _rgb_to_gray_kernel(in_ptr, out_ptr, n_pixels, BLOCK_SIZE: tl.constexpr):                                                                                                                  
    pid = tl.program_id(0)                                                                                                                                                                     
    idx = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)                                                                                                                                          
    mask = idx < n_pixels                                                                                                                                                                      
                                                                                                                                                                                                
    base = idx * 3                                                                                                                                                                             
                                                                                                                                                                                                
    r = tl.load(in_ptr + base, mask=mask, eviction_policy='evict_first')                                                                                                                       
    g = tl.load(in_ptr + base + 1, mask=mask, eviction_policy='evict_first')                                                                                                                   
    b = tl.load(in_ptr + base + 2, mask=mask, eviction_policy='evict_first')                                                                                                                   
                                                                                                                                                                                                
    gray = r * 0.2989 + g * 0.5870 + b * 0.1140                                                                                                                                                
                                                                                                                                                                                                
    tl.store(out_ptr + idx, gray, mask=mask, eviction_policy='evict_first')                                                                                                                    
                                                                                                                                                                                                
def custom_kernel(data):                                                                                                                                                                       
    rgb, output = data                                                                                                                                                                         
    n_pixels = output.numel()                                                                                                                                                                  
    rgb_c = rgb.contiguous()                                                                                                                                                                   
                                                                                                                                                                                                
    grid = (triton.cdiv(n_pixels, 1024),)                                                                                                                                                      
    _rgb_to_gray_kernel[grid](                                                                                                                                                                 
        rgb_c,                                                                                                                                                                                 
        output,                                                                                                                                                                                
        n_pixels,                                                                                                                                                                              
        BLOCK_SIZE=1024,                                                                                                                                                                       
        num_warps=8,                                                                                                                                                                           
        num_stages=4                                                                                                                                                                           
    )                                                                                                                                                                                          
                                                                                                                                                                                                
    return output
scrolls · 36 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