Skip to content
KernelIndex
Search⌘K

submission 779820

shivbhatia · python · License unknown

Use it

Vendorable · source mirrored · license unknownView source →

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

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

Benchmark evidence

1 measurement across 1 GPU, fastest first.

Operation / workload
Hardware
Latency
Rank
Observed
RGB to grayscalesuite of 6 cases
NVIDIA A100
3.67ms
#40 of 137
2026-04-23

Reported · How evidence levels are derived →

Source and license

sourceavailable
revision digestsha256:fda584396d046f19d5cc79c77ca4afbb28a0f0ac62b01882f391102af5078d90
license declaredunknown
license concludedunknown
authorsshivbhatia
imported2026-08-15

Kernel source

submission.py18 lines
from task import input_t, output_t
import torch

_weights: torch.Tensor | None = None

@torch.compile
def _grayscale(data: torch.Tensor, weights: torch.Tensor) -> torch.Tensor:
    return data @ weights

def custom_kernel(data: input_t) -> output_t:
    global _weights
    data, output = data
    if _weights is None or _weights.device != data.device or _weights.dtype != data.dtype:
        _weights = torch.tensor([0.2989, 0.5870, 0.1140],
                                device=data.device, dtype=data.dtype)
    output[...] = _grayscale(data, _weights)
    return output

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 779814.

from task import input_t, output_t
import torch
+ _weights: torch.Tensor | None = None
+
+ @torch.compile
+ def _grayscale(data: torch.Tensor, weights: torch.Tensor) -> torch.Tensor:
+ return data @ weights
+
def custom_kernel(data: input_t) -> output_t:
+ global _weights
data, output = data
- weights = torch.tensor([0.2989, 0.5870, 0.1140],
- device=data.device,
- dtype=data.dtype)
- output[...] = torch.sum(data * weights, dim=-1)
+ if _weights is None or _weights.device != data.device or _weights.dtype != data.dtype:
+ _weights = torch.tensor([0.2989, 0.5870, 0.1140],
+ device=data.device, dtype=data.dtype)
+ output[...] = _grayscale(data, _weights)
return output

Best evidence level for this revision: reported

JSON