submission 779875
shivbhatia · python · License unknown
Use it
Vendorable · source mirrored · license unknownView source →
No package. Vendor the mirrored source: 55 lines, June 9 Researcher Reciprocity License v1.0.
submission.py
curl "https://kernelindex.com/api/v1/implementations/kernelbot-grayscale-v2-779875?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
Reported · How evidence levels are derived →
Source and license
sourceavailable
revision digestsha256:7f2b0f92289937290154bd12d821c6436bc646fd37ef8ed96e56e6eacdd4fb43
license declaredunknown
license concludedunknown
authorsshivbhatia
imported2026-08-15
Techniques
Extracted from the mirrored source by pattern, never inferred. Each row cites its line.
vector-width = float4
float4 a = __ldg((const float4*)&data[base * 3 + 0]); // R0 G0 B0 R1Kernel source
submission.py55 lines
from task import input_t, output_t
from torch.utils.cpp_extension import load_inline
cuda_source = """
#include <cuda_runtime.h>
__global__ void grayscale_kernel(
const float* __restrict__ data,
float* __restrict__ output
) {
// each thread handles 4 pixels = 12 floats = 3 x float4 loads
int base = (blockIdx.x * blockDim.x + threadIdx.x) * 4;
float4 a = __ldg((const float4*)&data[base * 3 + 0]); // R0 G0 B0 R1
float4 b = __ldg((const float4*)&data[base * 3 + 4]); // G1 B1 R2 G2
float4 c = __ldg((const float4*)&data[base * 3 + 8]); // B2 R3 G3 B3
float v0 = a.x * 0.2989f + a.y * 0.5870f + a.z * 0.1140f;
float v1 = a.w * 0.2989f + b.x * 0.5870f + b.y * 0.1140f;
float v2 = b.z * 0.2989f + b.w * 0.5870f + c.x * 0.1140f;
float v3 = c.y * 0.2989f + c.z * 0.5870f + c.w * 0.1140f;
// single 128-bit write-through store for all 4 output pixels
asm("st.global.wt.v4.f32 [%0], {%1, %2, %3, %4};"
:: "l"(&output[base]), "f"(v0), "f"(v1), "f"(v2), "f"(v3));
}
torch::Tensor grayscale_cuda(torch::Tensor data, torch::Tensor output) {
int n_pixels = output.numel();
const int BLOCK_SIZE = 256;
int grid = n_pixels / (BLOCK_SIZE * 4);
grayscale_kernel<<<grid, BLOCK_SIZE>>>(
data.data_ptr<float>(),
output.data_ptr<float>()
);
return output;
}
"""
cpp_source = "torch::Tensor grayscale_cuda(torch::Tensor data, torch::Tensor output);"
_ext = load_inline(
name="grayscale_float4_wt_v4",
cpp_sources=cpp_source,
cuda_sources=cuda_source,
functions=["grayscale_cuda"],
verbose=False,
)
def custom_kernel(data: input_t) -> output_t:
data, output = data
_ext.grayscale_cuda(data, output)
return output
scrolls · 55 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 779864.
⋯ 14 unchanged linesfloat4 b = __ldg((const float4*)&data[base * 3 + 4]); // G1 B1 R2 G2float4 c = __ldg((const float4*)&data[base * 3 + 8]); // B2 R3 G3 B3- output[base + 0] = a.x * 0.2989f + a.y * 0.5870f + a.z * 0.1140f;- output[base + 1] = a.w * 0.2989f + b.x * 0.5870f + b.y * 0.1140f;- output[base + 2] = b.z * 0.2989f + b.w * 0.5870f + c.x * 0.1140f;- output[base + 3] = c.y * 0.2989f + c.z * 0.5870f + c.w * 0.1140f;+ float v0 = a.x * 0.2989f + a.y * 0.5870f + a.z * 0.1140f;+ float v1 = a.w * 0.2989f + b.x * 0.5870f + b.y * 0.1140f;+ float v2 = b.z * 0.2989f + b.w * 0.5870f + c.x * 0.1140f;+ float v3 = c.y * 0.2989f + c.z * 0.5870f + c.w * 0.1140f;++ // single 128-bit write-through store for all 4 output pixels+ asm("st.global.wt.v4.f32 [%0], {%1, %2, %3, %4};"+ :: "l"(&output[base]), "f"(v0), "f"(v1), "f"(v2), "f"(v3));}torch::Tensor grayscale_cuda(torch::Tensor data, torch::Tensor output) {⋯ 11 unchanged linescpp_source = "torch::Tensor grayscale_cuda(torch::Tensor data, torch::Tensor output);"_ext = load_inline(- name="grayscale_float4",+ name="grayscale_float4_wt_v4",cpp_sources=cpp_source,cuda_sources=cuda_source,functions=["grayscale_cuda"],
scrolls · 28 diff lines total
Best evidence level for this revision: reported
JSON