input stringlengths 14.7k 17.7k | output stringlengths 3.39k 39.3k | torch_module stringlengths 241 3.29k | cuda_code stringlengths 1.75k 34.3k | speedup float64 0 4.25k | operators listlengths 1 8 | source_stage stringclasses 2
values | source_index int64 1 80.9k |
|---|---|---|---|---|---|---|---|
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension to accelerate forward: first torch.triu(x, diagonal=self.diagonal) then torch.unbind(x, dim=2). Input shape: (64,128,1024). triu along last two dimensions? torch.triu works on 2D matrices; for batched, it applies to last two dims. Here x shape (64,128,1024): treat each 2D... | import torch
class Model(torch.nn.Module):
def __init__(self, input_size, diagonal):
super(Model, self).__init__()
self.diagonal = diagonal
def forward(self, x):
x = torch.triu(x, diagonal=self.diagonal)
x = torch.unbind(x, dim=2)
return x
def get_inputs():
retur... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# ------------------- CUDA kernel source -------------------
cuda_source = r"""
#include <torch/extension.h>
#include <cuda_runtime.h>
#include <ATen/cuda/CUDAContext.h>
#ifndef CHECK_CUDA
#define CHECK_CUDA(x) TORCH_CHECK(x.is_cuda(... | 0.42 | [
"torch.triu",
"torch.unbind"
] | stage1 | 6 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension to replace forward: one-hot encoding then two minimum operations with constants. The model has no parameters (just constants). So we need to implement a kernel that takes input tensor of shape (input_size,) of integer indices, produces output tensor of shape (input_size, ... | import torch
import torch.nn as nn
import torch.nn.functional as F
class Model(nn.Module):
def __init__(self, num_classes, input_size, on_value, off_value):
super().__init__()
self.num_classes = num_classes
self.input_size = input_size
self.on_value = on_value
self.off_valu... | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.utils.cpp_extension import load_inline
# --------------------- CUDA kernel source ---------------------
cuda_source = r'''
#include <torch/extension.h>
#include <cuda_runtime.h>
#include <ATen/cuda/CUDAContext.h>
template <typename scalar_t... | 3.79 | [
"F.one_hot",
"torch.minimum"
] | stage1 | 1 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension to accelerate the forward of Model. Model forward: input = torch.repeat_interleave(input, self.repeats, self.dim); then return F.mse_loss(input, target). So we need to implement repeat_interleave and MSE loss (mean squared error) in CUDA kernel, without calling torch func... | import torch
import torch.nn as nn
import torch.nn.functional as F
class Model(nn.Module):
def __init__(self, repeats, dim):
super().__init__()
self.repeats = repeats
self.dim = dim
def forward(self, input, target):
input = torch.repeat_interleave(input, self.repeats, self.dim... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# ------------------- CUDA kernel source -------------------
cuda_source = r"""
#include <torch/extension.h>
#include <cuda_runtime.h>
#include <ATen/cuda/CUDAContext.h>
#define WARP_SIZE 32
// Warp‑level reduction (sum)
__inline__ ... | 1.39 | [
"torch.repeat_interleave",
"F.mse_loss"
] | stage1 | 3 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension to accelerate forward of Model, which does two ConvTranspose1d operations with same weight/bias then logical_and of their boolean values and cast to float.
Constraints: No extra tensor parameters during init. Keep submodule names unchanged. So ModelNew should have same _... | import torch
import torch.nn as nn
import torch.nn.functional as F
class Model(nn.Module):
def __init__(self, in_channels, out_channels, kernel_size, stride, padding, output_padding, bias):
super().__init__()
self.conv_transpose1d = nn.ConvTranspose1d(
in_channels,
out_chan... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# ------------------- CUDA source -------------------
cuda_source = r'''
#include <torch/extension.h>
#include <cuda_runtime.h>
#include <ATen/cuda/CUDAContext.h>
#ifndef CHECK_CUDA
#define CHECK_CUDA(x) TORCH_CHECK(x.is_cuda(), #x "... | 5.34 | [
"torch.logical_and",
"F.conv_transpose1d"
] | stage1 | 10 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension to accelerate Model forward: apply SiLU activation then masked_select. Constraints: can't call torch functions except allocate/init tensors. Can't call torch.nn.functional. Must use parameters and attributes of submodule. Here submodule is nn.SiLU which has no parameters ... | import torch
import torch.nn as nn
class Model(nn.Module):
def __init__(self):
super().__init__()
self.silu = nn.SiLU()
def forward(self, x: torch.Tensor, mask: torch.Tensor) -> torch.Tensor:
x = self.silu(x)
x = torch.masked_select(x, mask)
return x
def get_inputs()... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# ----------------------------------------------------------------------
# CUDA source: SiLU activation + masked_select (atomic‑based implementation)
# ----------------------------------------------------------------------
cuda_source... | 1.26 | [
"nn.SiLU",
"torch.masked_select"
] | stage1 | 22 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension to accelerate the forward function.
Model forward steps:
1. x = torch.addcmul(x, self.weight1, self.weight2, value=1)
addcmul: out = x + value * weight1 * weight2 elementwise? Actually torch.addcmul(input, tensor1, tensor2, value=1) returns input + value * tensor1 * ... | import torch
import torch.nn as nn
import torch.nn.functional as F
class Model(nn.Module):
def __init__(self, in_features, out_features, alpha, beta, scalar):
super().__init__()
self.weight1 = nn.Parameter(torch.randn(out_features, in_features))
self.weight2 = nn.Parameter(torch.randn(out_... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# ---------- CUDA source ----------
cuda_source = r"""
#include <torch/extension.h>
#include <cuda_runtime.h>
#define THREADS_PER_BLOCK 256
// ------------------------------------------------------------------
// Kernel 1: count non... | 1.87 | [
"torch.addcmul",
"torch.count_nonzero"
] | stage1 | 9 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension to replace forward: clamp then tan. Must not call torch functions except allocation. Must use parameters (none). So kernel will read input, apply clamp (min/max) and tan (tanh? Actually torch.tan is elementwise tangent). Use tanf. Use tiling? Simple elementwise operation,... | import torch
import torch.nn as nn
import torch.nn.functional as F
class Model(nn.Module):
def __init__(self, min_value, max_value):
super().__init__()
self.min_value = min_value
self.max_value = max_value
def forward(self, x):
x = torch.clamp(x, min=self.min_value, max=self.m... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# ------------------- CUDA kernel source -------------------
cuda_source = r"""
#include <torch/extension.h>
#include <cuda_runtime.h>
#include <math.h>
template <typename scalar_t>
__global__ void tan_clamp_kernel(const scalar_t* __... | 1.36 | [
"torch.clamp",
"torch.tan"
] | stage1 | 57 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension that implements forward of Model: repeat_interleave along dim, then abs, then mask where x > abs_value: replace with mask_value, and then masked_fill (same operation). Actually code:
x = repeat_interleave
x = torch.abs(x)
mask = torch.where(x > self.abs_value, torch.tens... | import torch
class Model(torch.nn.Module):
def __init__(self, repeats, dim, mask_value, abs_value):
super().__init__()
self.repeats = repeats
self.dim = dim
self.mask_value = mask_value
self.abs_value = abs_value
def forward(self, x):
x = torch.repeat_interleav... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# ------------------- CUDA extension source -------------------
cuda_source = r"""
#include <torch/extension.h>
#include <cuda_runtime.h>
#include <ATen/ATen.h>
#include <cmath>
template <typename scalar_t>
__global__ void repeat_abs... | 7.14 | [
"torch.repeat_interleave",
"torch.abs",
"torch.masked_fill"
] | stage1 | 30 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension to accelerate forward of Model. The forward does:
1. linear: y = x @ weight.T (+ bias if present). weight shape (out_features, in_features). bias none.
2. silu activation: silu(z) = z * sigmoid(z). Equivalent to z * 1/(1+exp(-z)). We'll implement directly.
3. torch.nan... | import torch
import torch.nn as nn
import torch.nn.functional as F
class Model(nn.Module):
def __init__(self, in_features: int, out_features: int, bias: bool = False):
super().__init__()
self.linear = nn.Linear(in_features, out_features, bias=bias)
def forward(self, x: torch.Tensor) -> torch.... | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.utils.cpp_extension import load_inline
# ----------------------------------------------------------------------
# CUDA source: three kernels (linear+SiLU, nansum+nan‑check, final cosine)
# ----------------------------------------------------... | 1.58 | [
"F.silu",
"torch.nansum",
"torch.all",
"torch.cos"
] | stage1 | 31 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension that replicates the forward of Model: batch_norm, hardswish, reflection pad, gelu.
We cannot call torch.nn functional. Must implement each op manually using parameters.
BatchNorm2d: need weight (gamma) and bias (beta) if affine, plus running_mean, running_var, eps. In f... | import torch
import torch.nn as nn
class Model(nn.Module):
def __init__(self, num_features, eps, momentum, affine, track_running_stats):
super().__init__()
self.batch_norm = nn.BatchNorm2d(num_features, eps, momentum, affine, track_running_stats)
self.hardswish = nn.Hardswish()
sel... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# ------------------- CUDA kernel source -------------------
cuda_source = r"""
#include <torch/extension.h>
#include <cuda_runtime.h>
#include <math.h>
#define BLOCK_SIZE 256
// -----------------------------------------------------... | 2.68 | [
"nn.BatchNorm2d",
"nn.Hardswish",
"nn.ReflectionPad2d",
"nn.GELU"
] | stage1 | 18 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension that implements forward: linear (matrix multiplication) plus elementwise minimum with bias (vector). Must not use torch.nn.functional or torch functions inside kernel; cannot call cublas. Must implement matmul manually using tiling, shared memory. Also bias is a parameter... | import torch
import torch.nn as nn
class Model(nn.Module):
def __init__(self, in_features, out_features, bias_shape):
super().__init__()
self.linear = nn.Linear(in_features, out_features)
self.bias = nn.Parameter(torch.randn(bias_shape))
def forward(self, x):
x = self.linear(x... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# ------------------- CUDA kernel & wrapper -------------------
cuda_source = r"""
#include <torch/extension.h>
#include <cuda_runtime.h>
#include <ATen/cuda/CUDAContext.h>
#ifndef TILE_M
#define TILE_M 32
#endif
#ifndef TILE_N
#defi... | 0.75 | [
"torch.minimum",
"nn.Linear"
] | stage1 | 24 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension to accelerate the model forward: einsum, sigmoid, linear, bias addition. Must not use torch functions inside kernel, only raw operations. Must pass parameters: self.linear.weight, self.linear.bias, self.bias. Also need to handle einsum equation "ij->ij" which is identity;... | import torch
import torch.nn as nn
class Model(nn.Module):
def __init__(self, einsum_equation, in_features, bias_shape, out_features):
super().__init__()
self.einsum_equation = einsum_equation
self.sigmoid = nn.Sigmoid()
self.linear = nn.Linear(in_features, out_features)
se... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# ------------------- CUDA kernel source -------------------
cuda_source = r"""
#include <torch/extension.h>
#include <cuda_runtime.h>
#include <math.h>
#define TILE_SIZE 256 // threads per block
// fused kernel: (sigmoid ∘ einsum)... | 4.62 | [
"torch.einsum",
"nn.Sigmoid"
] | stage1 | 36 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension to accelerate the forward function of Model. The forward does:
x = torch.isin(x, other) # returns bool tensor same shape as x: elementwise check if each element of x is in other (1D tensor). torch.isin is like numpy isin, uses broadcasting.
x = torch.bitwise_xor(x, to... | import torch
import torch.nn as nn
import torch.nn.functional as F
class Model(nn.Module):
def __init__(self, input_shape, other_shape):
super().__init__()
self.input_shape = input_shape
self.other_shape = other_shape
def forward(self, x, other, complex_view_shape):
x = torch.... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# ----------------------------------------------------------------------
# CUDA source: implements the three operations of the original forward:
# 1) element‑wise “isin” between a flat int tensor x and a 1‑D tensor other
# 2) logi... | 16.75 | [
"torch.isin",
"torch.bitwise_xor",
"torch.view_as_complex"
] | stage1 | 14 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension to accelerate Model.forward, without using torch functions except allocation. Need to keep submodules same names. Model has attributes: upscale_factor (int), padding (nn.ConstantPad2d). In forward: x = nn.PixelShuffle(self.upscale_factor)(x); then tanh; then padding; then... | import torch
import torch.nn as nn
import torch.nn.functional as F
class Model(nn.Module):
def __init__(self, upscale_factor, padding_values):
super().__init__()
self.upscale_factor = upscale_factor
self.padding = nn.ConstantPad2d(padding_values, 0)
def forward(self, x):
x = n... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# ------------------- CUDA source -------------------
cuda_source = r'''
#include <torch/extension.h>
#include <cuda_runtime.h>
#include <math.h>
#define TILE_SIZE 256 // threads per block
// ---------------------------------------... | 2.57 | [
"nn.PixelShuffle",
"torch.tanh",
"torch.bitwise_xor",
"nn.ConstantPad2d"
] | stage1 | 47 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension to accelerate the forward of Model. The forward does three ops:
1. median along channel dim (dim=1) of shape (B, C=3, H, W) -> result shape (B, H, W). Since C=3, median is simple: for each pixel across channels, median of 3 values (i.e., the middle after sorting). For 3 ... | import torch
import torch.nn as nn
import torch.nn.functional as F
class Model(nn.Module):
def __init__(self):
super().__init__()
# Median operation doesn't require any parameters, as it operates directly on tensors.
def forward(self, x):
x = torch.median(x, dim=1)[0] # Compute media... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# ---------- CUDA source ----------
cuda_source = r'''
#include <torch/extension.h>
#include <cuda_runtime.h>
#include <ATen/cuda/CUDAContext.h>
#include <math.h>
#define WARP_SIZE 32
#define INF_POS 1e20f
#define INF_NEG -1e20f
// ... | 3.79 | [
"torch.median",
"F.kl_div",
"torch.sinc"
] | stage1 | 44 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension to accelerate the forward of Model, which computes log_softmax then cross_entropy loss. The forward takes input x (batch_size, num_classes) and target (batch_size). Compute log_softmax(x, dim=1) then cross_entropy(x, target). The cross_entropy with log_softmax input expec... | import torch
import torch.nn as nn
import torch.nn.functional as F
class Model(nn.Module):
def __init__(self, num_classes):
super().__init__()
self.num_classes = num_classes
def forward(self, x, target):
x = F.log_softmax(x, dim=1)
loss = F.cross_entropy(x, target)
ret... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# ---------- CUDA source ----------
cuda_source = r"""
#include <torch/extension.h>
#include <cuda_runtime.h>
#include <math.h>
#include <ATen/cuda/CUDAContext.h>
#define WARP_SIZE 32
// ---------- warp / block reduction helpers ---... | 0.94 | [
"F.cross_entropy",
"F.log_softmax"
] | stage1 | 48 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension to accelerate the model forward function. The model's forward does:
- x = self.mul(x, 2) # elementwise multiplication by scalar 2
- x = self.dict["conv1d"](x) # conv1d
- return x
Note: there are also linear1 and linear2 modules defined but not used in forward. So we o... | import torch
import torch.nn as nn
class Model(nn.Module):
def __init__(self, input_size, hidden_size, num_layers, kernel_size):
super(Model, self).__init__()
self.mul = torch.mul
self.dict = nn.ModuleDict(
{
"conv1d": nn.Conv1d(input_size, hidden_size, kernel_s... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# -------------------- CUDA source --------------------
cuda_source = r"""
#include <torch/extension.h>
#include <cuda_runtime.h>
#include <ATen/cuda/CUDAContext.h>
#define TILE 128
// -----------------------------------------------... | 4.03 | [
"torch.mul",
"nn.ModuleDict",
"nn.Conv1d"
] | stage1 | 58 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension to accelerate the forward function.
The model's forward does: x = torch.unbind(x, dim=self.dim); x = [torch.detach(t) for t in x]; return x.
So input shape (batch_size, channels, height, width). dim=1, so unbind along channel dimension, producing a list of tensors each ... | import torch
import torch.nn as nn
import torch.nn.functional as F
class Model(nn.Module):
def __init__(self, dim):
super().__init__()
self.dim = dim
def forward(self, x):
x = torch.unbind(x, dim=self.dim)
x = [torch.detach(t) for t in x]
return x
batch_size = 128
ch... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# ------------------- CUDA kernel source -------------------
cuda_source = r"""
#include <torch/extension.h>
#include <cuda_runtime.h>
#define TILE_SIZE 256 // number of threads per block
// Kernel that transposes the first two dim... | 0.4 | [
"torch.unbind",
"torch.detach"
] | stage1 | 79 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension to accelerate the forward function of Model. The forward does:
1. x = self.conv_transpose(x) # ConvTranspose2d
2. x = torch.cumsum(x, dim=0) # cumulative sum across batch dimension (dim 0)
3. x = self.avg_pool(x) # AvgPool2d kernel=2 stride=2
4. x = self.conv(... | import torch
import torch.nn as nn
class Model(nn.Module):
def __init__(self, in_channels, out_channels, kernel_size, stride, padding, output_padding, bias_shape):
super().__init__()
self.conv_transpose = nn.ConvTranspose2d(
in_channels, out_channels, kernel_size, stride=stride, paddin... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# ==================== CUDA source ====================
cuda_source = r"""
#include <torch/extension.h>
#include <cuda_runtime.h>
#include <ATen/cuda/CUDAContext.h>
#define CHECK_CUDA(x) TORCH_CHECK(x.is_cuda(), #x " must be a CUDA t... | 0.42 | [
"nn.ConvTranspose1d",
"torch.cumsum",
"nn.AvgPool2d",
"nn.Conv2d"
] | stage1 | 20 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension that implements the forward: compute cos(x) then elementwise maximum with y. Must not use torch functions except allocation. Must pass parameters (none). So we just need a kernel that reads two input tensors, computes cos and max.
We need ModelNew with same __init__ sign... | import torch
import torch.nn as nn
import torch.nn.functional as F
class Model(nn.Module):
def __init__(self, in_features):
super().__init__()
self.in_features = in_features
def forward(self, x, y):
x = torch.cos(x)
x = torch.maximum(x, y)
return x
def get_inputs():
... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# ----------------------------------------------------------------------
# CUDA source implementing element‑wise max(cos(x), y)
# ----------------------------------------------------------------------
cuda_source = r'''
#include <torc... | 1.44 | [
"torch.cos",
"torch.maximum"
] | stage1 | 98 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension to accelerate the forward of Model. The forward does:
x = torch.square(x) # elementwise square
x = self.conv1d(x) # Conv1d (no bias? default bias True? By default Conv1d has bias=True. But they also have separate bias param, but they also have self.bias Parameter. T... | import torch
import torch.nn as nn
import torch.nn.functional as F
class Model(nn.Module):
def __init__(self, in_channels, out_channels, kernel_size, bias_shape):
super().__init__()
self.conv1d = nn.Conv1d(in_channels, out_channels, kernel_size)
self.bias = nn.Parameter(torch.randn(bias_sh... | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.utils.cpp_extension import load_inline
# ------------------- CUDA source -------------------
cuda_source = r'''
#include <torch/extension.h>
#include <cuda_runtime.h>
#include <ATen/cuda/CUDAContext.h>
#include <math.h>
#define BLOCK_SIZE 2... | 0.18 | [
"torch.square",
"nn.Conv1d",
"F.binary_cross_entropy_with_logits"
] | stage1 | 64 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension to accelerate Model forward. The forward does:
- upper_tri_matrix = torch.triu(upper_tri_matrix)
- loss = self.loss_fn(input, target)
- return loss
So we need to implement torch.triu and CrossEntropyLoss in CUDA manually, without using torch functions.
We must keep mod... | import torch
import torch.nn as nn
import torch.nn.functional as F
class Model(nn.Module):
def __init__(self, num_classes, matrix_size):
super().__init__()
self.loss_fn = nn.CrossEntropyLoss()
self.matrix_size = matrix_size
self.num_classes = num_classes
def forward(self, inpu... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# ----------------------------------------------------------------------
# CUDA source implementing triu and cross‑entropy (mean reduction)
# ----------------------------------------------------------------------
cuda_source = r"""
#i... | 0.98 | [
"torch.triu",
"nn.CrossEntropyLoss"
] | stage1 | 80 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension to accelerate the forward function: interpolate (bilinear upsample) then mean across channel dim (dim=1) keepdim.
Original model: input shape (batch,1,H,W). Interpolate scale_factor=2.0 bilinear -> output shape (batch,1,2H,2W). Then mean over channel dim (only 1 channel)... | import torch
import torch.nn as nn
import torch.nn.functional as F
class Model(nn.Module):
def __init__(self):
super().__init__()
self.interpolation = 2
self.scale_factor = 2.0
def forward(self, x):
x = F.interpolate(x, scale_factor=self.scale_factor, mode="bilinear", align_co... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# ------------------- CUDA kernel source -------------------
cuda_source = r'''
#include <torch/extension.h>
#include <cuda_runtime.h>
#include <math.h>
#define TILE_H 16
#define TILE_W 16
// Bilinear upsample by a factor of 2 (alig... | 1.9 | [
"F.interpolate",
"torch.mean"
] | stage1 | 94 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension to accelerate the forward of Model: compute median along a dimension (reduce_dim), then unbind (split) the resulting tensor along same dimension, returning a tuple of tensors (list). Input shape: (64,10,128,128). reduce_dim is -1 (i.e., last dimension). So median over dim... | import numpy as np
import torch
class Model(torch.nn.Module):
def __init__(self, input_size, reduce_dim):
super(Model, self).__init__()
self.input_size = input_size
self.reduce_dim = reduce_dim
def forward(self, x):
median_values = torch.median(x, dim=self.reduce_dim)[0]
... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# ------------------------------------------------------------------
# CUDA source: median reduction (no torch calls, no cuBLAS/cuDNN)
# ------------------------------------------------------------------
cuda_source = r'''
#include <t... | 0.33 | [
"torch.median",
"torch.unbind"
] | stage1 | 68 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to create a custom CUDA extension to accelerate forward: index_select then sub. Model has no parameters; just performs indexing and subtraction.
We must keep __init__ signature same: takes input_dim, index_dim, sub_dim. No extra parameters.
We need ModelNew with same submodules (none). Must keep state ... | import torch
class Model(torch.nn.Module):
def __init__(self, input_dim, index_dim, sub_dim):
super(Model, self).__init__()
self.index_dim = index_dim
self.sub_dim = sub_dim
def forward(self, x, indices, subtrahend):
x_indexed = torch.index_select(x, 0, indices)
x_subt... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# -------------------- CUDA kernel source --------------------
cuda_source = r"""
#include <torch/extension.h>
#include <cuda_runtime.h>
#include <ATen/cuda/CUDAContext.h>
template <typename scalar_t, typename index_t>
__global__ voi... | 1.38 | [
"torch.index_select",
"torch.sub"
] | stage1 | 106 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write custom CUDA extension to accelerate forward of Model: reshape, split, transpose each sub tensor, then cat. Let's understand operation.
Input x shape: (batch_size, input_features) = (128, 512). reshape_size = (batch_size*4, input_features//4) = (512, 128). So reshape to (512,128). Then split alo... | import torch
import torch.nn as nn
import torch.nn.functional as F
class Model(nn.Module):
def __init__(self, reshape_size, split_size_or_sections):
super().__init__()
self.reshape_size = reshape_size
self.split_size_or_sections = split_size_or_sections
def forward(self, x):
x... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# -------------------- CUDA kernel source --------------------
cuda_source = r'''
#include <torch/extension.h>
#include <cuda_runtime.h>
#define TILE_X 32
#define TILE_Y 8
// ---------------------------------------------------------... | 2.44 | [
"torch.reshape",
"torch.split",
"torch.t"
] | stage1 | 91 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension to accelerate Model.forward: it does x = torch.bernoulli(x * self.prob_tensor); then x = torch.min(x, dim=1).values; return x.
We need to create ModelNew with same __init__ and forward signatures, keep submodule names unchanged (here only prob_tensor is a tensor attribut... | import torch
import torch.nn as nn
class Model(nn.Module):
def __init__(self, prob_tensor):
super().__init__()
self.prob_tensor = prob_tensor
def forward(self, x):
x = torch.bernoulli(x * self.prob_tensor)
x = torch.min(x, dim=1).values
return x
prob_tensor = torch.t... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# ------------------------------------------------------------------
# CUDA source: implements Bernoulli sampling (x * prob) and per‑row min
# ------------------------------------------------------------------
cuda_source = r'''
#incl... | 0.85 | [
"torch.bernoulli",
"torch.min"
] | stage1 | 105 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension to replace forward: first convert degrees to radians: torch.deg2rad(x) * self.deg2rad. torch.deg2rad converts from degrees to radians: deg2rad = x * pi/180. Actually torch.deg2rad(x) returns x * pi/180. Then multiplied by self.deg2rad which is math.radians(degrees) i.e., ... | import math
import torch
import torch.nn as nn
class Model(nn.Module):
def __init__(self, degrees, pool_size, stride=None, padding=0, ceil_mode=False, count_include_pad=True):
super(Model, self).__init__()
self.deg2rad = math.radians(degrees)
self.pool = nn.AvgPool2d(
kernel_s... | import math
import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# ----------------------- CUDA kernel source -----------------------
cuda_source = r'''
#include <torch/extension.h>
#include <cuda_runtime.h>
#include <ATen/cuda/CUDAContext.h>
#ifndef TILE_H
#define TILE_H 16
#endif
#if... | 3.02 | [
"torch.deg2rad",
"nn.AvgPool2d"
] | stage1 | 108 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension to accelerate the forward: tanh then log1p. Must not call torch.nn.functional functions; must use parameters. Here tanh is a module with no parameters. But we need to keep submodule names unchanged: self.tanh. No extra parameters. So we need to implement a kernel that doe... | import torch
import torch.nn as nn
import torch.nn.functional as F
class Model(nn.Module):
def __init__(self):
super().__init__()
self.tanh = nn.Tanh()
def forward(self, x):
x = self.tanh(x)
x = torch.log1p(x)
return x
batch_size = 128
input_features = 256
def get_... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# ------------------- CUDA source -------------------
cuda_source = r'''
#include <torch/extension.h>
#include <cuda_runtime.h>
#include <math.h>
#include <ATen/cuda/CUDAContext.h>
#define BLOCK_SIZE 256
// Element‑wise fused tanh +... | 1.7 | [
"nn.Tanh",
"torch.log1p"
] | stage1 | 139 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write ModelNew that replicates forward: compute complex_tensor = torch.polar(magnitude, angle) => returns complex numbers (torch.complex?). torch.polar returns complex tensor with real = magnitude * cos(angle), imag = magnitude * sin(angle). Then elu_output = self.elu(complex_tensor.real) i.e., apply ... | import torch
import torch.nn as nn
import torch.nn.functional as F
class Model(nn.Module):
def __init__(self, hidden_dim):
super().__init__()
self.elu = nn.ELU()
self.hidden_dim = hidden_dim
def forward(self, magnitude, angle, x):
complex_tensor = torch.polar(magnitude, angle)... | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.utils.cpp_extension import load_inline
# ----------------------------------------------------------------------
# CUDA source: fused polar -> ELU -> GELU
# ----------------------------------------------------------------------
cuda_source = ... | 2.72 | [
"nn.ELU",
"torch.polar",
"F.gelu"
] | stage1 | 138 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to create a custom CUDA extension that implements adaptive average pooling followed by ELU activation.
We must not use torch.nn.functional etc. Must implement using parameters of submodule. AdaptiveAvgPool2d has no parameters. But we need to compute output size (target H_out, W_out). For each input (N, ... | import torch
import torch.nn as nn
import torch.nn.functional as F
class Model(nn.Module):
def __init__(self, in_channels, output_size):
super().__init__()
self.adaptive_avg_pool2d = nn.AdaptiveAvgPool2d(output_size)
def forward(self, x):
x = self.adaptive_avg_pool2d(x)
x = F.... | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.utils.cpp_extension import load_inline
# ----------------------------------------------------------------------
# CUDA kernel that fuses AdaptiveAvgPool2d + ELU (alpha=1.0)
# ------------------------------------------------------------------... | 1.39 | [
"F.adaptive_avg_pool2d",
"F.elu"
] | stage1 | 132 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension to accelerate the forward of Model: linear -> relu -> elementwise square (mul) -> linear.
Constraints: keep same __init__ signature, same submodule names, same state dict keys. No extra parameters. We must not call torch functions inside kernel except allocate/initialize... | import torch
import torch.nn as nn
import torch.nn.functional as F
class Model(nn.Module):
def __init__(self, input_size, hidden_size, output_size):
super().__init__()
self.linear = nn.Linear(input_size, hidden_size)
self.relu = nn.ReLU()
self.output = nn.Linear(hidden_size, output... | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.utils.cpp_extension import load_inline
# -------------------- CUDA source --------------------
cuda_source = r"""
#include <torch/extension.h>
#include <cuda_runtime.h>
#include <ATen/cuda/CUDAContext.h>
#include <math.h>
#ifndef TILE_M
#de... | 0.68 | [
"torch.mul",
"F.relu",
"nn.Linear"
] | stage1 | 126 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension to accelerate the forward: apply torch.tril (lower triangular) and torch.round. Both are elementwise but tril masks upper triangle to zero? Actually torch.tril returns lower triangular part of matrix, setting upper part to zero. Then torch.round rounds each element to nea... | import torch
import torch.nn as nn
class Model(nn.Module):
def __init__(self):
super().__init__()
def forward(self, x: torch.Tensor) -> torch.Tensor:
x = torch.tril(x)
x = torch.round(x)
return x
def get_inputs():
# Generate a 3x3 tensor for demonstration
x = torch.t... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# ------------------- CUDA source -------------------
cuda_source = r"""
#include <torch/extension.h>
#include <cuda_runtime.h>
#include <math.h>
template <typename scalar_t>
__global__ void tril_round_kernel(const scalar_t* __restri... | 1.27 | [
"torch.tril",
"torch.round"
] | stage1 | 152 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension to accelerate the model forward which consists of two ReLU operations: one using nn.ReLU() module (which has weightless, just functional) and then F.relu. Both are elementwise max(0, x). So we can fuse them into a single kernel that does max(0, x) (i.e., same as one ReLU)... | import torch
import torch.nn as nn
import torch.nn.functional as F
class Model(nn.Module):
def __init__(self):
super().__init__()
def forward(self, x):
x = nn.ReLU()(x) # nn.ReLU
x = F.relu(x) # F.relu
return x
def get_inputs():
return [torch.randn(1, 1, 4, 4)] # Inpu... | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.utils.cpp_extension import load_inline
# ------------------- CUDA kernel source -------------------
cuda_source = r'''
#include <torch/extension.h>
#include <cuda_runtime.h>
// Simple element‑wise ReLU (max(0, x)) fused for two consecutive ... | 2.31 | [
"nn.ReLU",
"F.relu"
] | stage1 | 157 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to create ModelNew with same __init__ (input_size, reduction_dim) and forward signature. The original model has a Linear layer but forward doesn't use it! Actually forward just negates x and nansum over dim=1. The Linear is unused. So we must keep submodule unchanged (self.neg) but not use it. The state ... | import torch
import torch.nn as nn
import torch.nn.functional as F
class Model(nn.Module):
def __init__(self, input_size, reduction_dim):
super().__init__()
self.neg = nn.Linear(input_size, reduction_dim)
def forward(self, x):
x = torch.neg(x) # Negate the input tensor element-wise.
... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# -------------------------- CUDA source --------------------------
cuda_source = r"""
#include <torch/extension.h>
#include <cuda_runtime.h>
#include <ATen/cuda/CUDAContext.h>
#define WARP_SIZE 32
// ----------- warp and block redu... | 1.76 | [
"torch.neg",
"torch.nansum"
] | stage1 | 150 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write custom CUDA extension to replace forward of Model with fused operations: conv2d, softplus, rsqrt, multiply with bias.
Constraints: cannot call torch.nn.functional or submodule forward. Must pass parameters like weight, bias, etc to kernel.
We must keep submodule names unchanged: conv, softplus... | import torch
import torch.nn as nn
import torch.nn.functional as F
class Model(nn.Module):
def __init__(self, input_channels, output_channels, kernel_size, stride, padding, bias_shape):
super().__init__()
self.conv = nn.Conv2d(input_channels, output_channels, kernel_size, stride=stride, padding=pa... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# ----------------------------------------------------------------------
# CUDA source: fused convolution (3×3) + Softplus + rsqrt + channel‑wise mul
# ----------------------------------------------------------------------
cuda_source... | 1.22 | [
"nn.Softplus",
"torch.rsqrt",
"torch.multiply"
] | stage1 | 136 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension to replace forward of Model: steps:
1. Generate a range tensor same shape as x (original x). In forward they do x = torch.arange(0, x.numel(), dtype=x.dtype, device=x.device).view_as(x). That creates a tensor with sequential values from 0 to N-1.
2. Then conv3d on that ... | import torch
import torch.nn as nn
import torch.nn.functional as F
class Model(nn.Module):
def __init__(
self, in_channels, out_channels, kernel_size, stride, padding, dilation, addcmul_tensor_shape, scale, bias
):
super().__init__()
self.conv3d = nn.Conv3d(
in_channels, ou... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# ------------------- CUDA source -------------------
cuda_source = r"""
#include <torch/extension.h>
#include <cuda_runtime.h>
#include <ATen/cuda/CUDAContext.h>
template <typename scalar_t>
__global__ void conv_addcmul_kernel(
... | 0.18 | [
"torch.arange",
"torch.addcmul",
"nn.Conv3d"
] | stage1 | 144 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension to accelerate the forward function of Model. The forward does:
mask = torch.ge(x, threshold) # bool mask where x >= threshold
x_nan = torch.where(mask, x, torch.tensor(float("nan"))) # replace values where mask False (i.e., x < threshold) with NaN
x_finite = torch.nan_... | import torch
import torch.nn as nn
class Model(nn.Module):
def __init__(self, threshold: float):
super().__init__()
self.threshold = threshold
def forward(self, x: torch.Tensor) -> torch.Tensor:
# Use torch.ge to create a mask of values greater than or equal to the threshold
m... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# ------------------- CUDA kernel source -------------------
cuda_source = r"""
#include <torch/extension.h>
#include <cuda_runtime.h>
// Simple threshold kernel: out = (x >= thresh) ? x : 0
extern "C" __global__
void threshold_kerne... | 4.15 | [
"torch.ge",
"torch.nan_to_num"
] | stage1 | 169 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension that replicates forward: clip, GELU, topk (select top k per row? Actually input shape (batch, height, width). torch.topk applied on default dimension -1 (last dim). So per each (batch, height) row we take topk across width dimension, returning values (size topk_k). So out... | import torch
import torch.nn as nn
import torch.nn.functional as F
class Model(nn.Module):
def __init__(self, clip_value, topk_k):
super().__init__()
self.clip_value = clip_value
self.topk_k = topk_k
def forward(self, x):
x = torch.clip(x, min=-self.clip_value, max=self.clip_v... | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.utils.cpp_extension import load_inline
# ------------------- CUDA source -------------------
cuda_source = r"""
#include <torch/extension.h>
#include <cuda_runtime.h>
#include <math.h>
#include <ATen/cuda/CUDAContext.h>
#ifndef M_SQRT2
#def... | 1.18 | [
"torch.clip",
"F.gelu",
"torch.topk"
] | stage1 | 161 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write custom CUDA extension to accelerate the model forward. The model does:
- self.log_softmax = nn.LogSoftmax(dim=1)
- x = self.log_softmax(logits) -> compute log softmax over dim=1 (num_classes)
- x = torch.nansum(x, dim=1, keepdim=True) -> sum over classes ignoring NaNs, keep dim -> shape (batch,... | import torch
import torch.nn as nn
import torch.nn.functional as F
class Model(nn.Module):
def __init__(self, num_classes, ignore_index):
super().__init__()
self.log_softmax = nn.LogSoftmax(dim=1)
self.ignore_index = ignore_index
self.num_classes = num_classes
def forward(self... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# ------------------- CUDA source -------------------
cuda_source = r'''
#include <torch/extension.h>
#include <cuda_runtime.h>
#include <ATen/cuda/CUDAContext.h>
#include <cmath>
#ifndef INFINITY
#define INFINITY __int_as_float(0x7f... | 0.2 | [
"nn.LogSoftmax",
"torch.nansum",
"torch.tril",
"F.cross_entropy"
] | stage1 | 156 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write custom CUDA extension for forward: softplus then transpose. Softplus = log(1+exp(x)). Could implement elementwise. Then transpose two dimensions. We can fuse: compute softplus and write to output with transposed indices directly, avoiding intermediate tensor. Input shape: (batch, input_dim, heig... | import torch
import torch.nn as nn
import torch.nn.functional as F
class Model(nn.Module):
def __init__(self, input_dim, dim0, dim1):
super().__init__()
self.input_dim = input_dim
self.dim0 = dim0
self.dim1 = dim1
def forward(self, x):
x = F.softplus(x)
x = tor... | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.utils.cpp_extension import load_inline
# ---------- CUDA kernel source ----------
cuda_source = r"""
#include <torch/extension.h>
#include <cuda_runtime.h>
#include <math.h>
template <typename scalar_t>
__global__ void softplus_transpose_ke... | 0.45 | [
"F.softplus",
"torch.transpose"
] | stage1 | 171 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension that implements forward: conv_transpose3d, add bias, cumsum along dim=0 (batch dimension). Must not call torch functions except for allocation. Must not call submodule forward; we need to use conv_transpose3d weight and bias parameters directly.
We have ConvTranspose3d p... | import torch
import torch.nn as nn
class Model(nn.Module):
def __init__(self, in_channels, out_channels, kernel_size, stride, padding, output_padding, bias_shape):
super(Model, self).__init__()
self.conv_transpose3d = nn.ConvTranspose3d(
in_channels, out_channels, kernel_size, stride=s... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# ----------------------------------------------------------------------
# CUDA source: implements transposed 3‑D convolution, adds both biases,
# and performs a cumulative sum over the batch dimension.
# -----------------------------... | 0.09 | [
"nn.ConvTranspose3d",
"torch.cumsum"
] | stage1 | 140 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to create ModelNew that replicates forward: compute product across dim, then logical_or of (x>0) or (x<1). Input shape: (16,3,32,32). dim=1, so product across channel dimension -> result shape (16,32,32). Then logical_or of conditions yields bool tensor same shape.
We need to implement custom CUDA kerne... | import torch
import torch.nn as nn
import torch.nn.functional as F
class Model(nn.Module):
def __init__(self, dim):
super().__init__()
self.dim = dim
def forward(self, x):
# Apply torch.prod across the specified dimension
x = torch.prod(x, dim=self.dim)
# Apply torch.l... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# ------------------- CUDA kernel source -------------------
cuda_source = r'''
#include <torch/extension.h>
#include <cuda_runtime.h>
#include <cstdint>
// -----------------------------------------------------------
// Kernel: produ... | 3.17 | [
"torch.prod",
"torch.logical_or"
] | stage1 | 184 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension to replace forward of Model. Steps:
Model forward does:
1. x = torch.log(x) elementwise log.
2. x = conv2d(x) using weight and bias.
3. loss = L1Loss(x, target) (no reduction specified, default reduction='mean'? default is 'mean'. Actually nn.L1Loss default reduction='me... | import torch
import torch.nn as nn
import torch.nn.functional as F
class Model(nn.Module):
def __init__(self, in_channels, out_channels, kernel_size, stride, padding, bias, target_shape):
super().__init__()
self.conv2d = nn.Conv2d(in_channels, out_channels, kernel_size, stride=stride, padding=padd... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# -------------------------- CUDA source --------------------------
cuda_source = r"""
#include <torch/extension.h>
#include <ATen/cuda/CUDAContext.h>
#include <cuda_runtime.h>
#include <float.h>
#include <math.h>
// ----------------... | 0.75 | [
"torch.log",
"nn.L1Loss",
"nn.Conv2d",
"torch.max"
] | stage1 | 153 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension that implements forward: cumsum along dim (cumsum_dim) then interpolate (nearest) with scale_factor.
We must not use torch functions inside kernel; we need to implement cumsum and nearest neighbor interpolation manually using raw pointers.
ModelNew must keep same __init... | import torch
import torch.nn as nn
import torch.nn.functional as F
class Model(nn.Module):
def __init__(self, input_dim, interp_scale_factor, interp_mode, cumsum_dim):
super().__init__()
self.cumsum_dim = cumsum_dim
def forward(self, x):
x = torch.cumsum(x, dim=self.cumsum_dim)
... | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.utils.cpp_extension import load_inline
# ---------- CUDA kernel source ----------
cuda_source = r"""
#include <torch/extension.h>
#include <cuda_runtime.h>
#define WARP_SIZE 32
// Inclusive scan within a warp (C <= 32)
__device__ __forcein... | 0.3 | [
"torch.cumsum",
"F.interpolate"
] | stage1 | 179 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension to accelerate the model forward. Model does logical_or of two boolean tensors then torch.tan on resulting boolean (converted to float?). In PyTorch, torch.tan on boolean will cast to float? Actually torch.tan expects floating type; boolean will be upcast to float (0/1). S... | import torch
class Model(torch.nn.Module):
def __init__(self, in_features):
super().__init__()
self.in_features = in_features
def forward(self, x, y):
x = torch.logical_or(x, y)
x = torch.tan(x)
return x
def get_inputs():
x = torch.tensor([True, False, False, Tru... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# -------------------- CUDA kernel --------------------
cuda_source = r"""
#include <torch/extension.h>
#include <cuda_runtime.h>
#include <ATen/cuda/CUDAContext.h>
#include <math.h>
__global__ void logical_or_tan_kernel(const uint8_... | 1.43 | [
"torch.logical_or",
"torch.tan"
] | stage1 | 186 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension to accelerate forward: compute log2(x) elementwise then batch matrix multiplication bmm (batch matmul) of shape (batch, dim1, dim2) * (batch, dim2, dim3) -> (batch, dim1, dim3). Must not use torch functions inside kernel except allocate tensors. Must not call torch.nn.fun... | import torch
import torch.nn as nn
import torch.nn.functional as F
class Model(nn.Module):
def __init__(self):
super().__init__()
def forward(self, x, y):
x = torch.log2(x)
x = torch.bmm(x, y)
return x
batch_size = 128
dim1 = 256
dim2 = 512
dim3 = 128
def get_inputs():
... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# ----------------------------------------------------------------------
# CUDA source implementing fused log2 + batched GEMM (bmm)
# ----------------------------------------------------------------------
cuda_source = r"""
#include <... | 0.45 | [
"torch.log2",
"torch.bmm"
] | stage1 | 194 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write custom CUDA extension to accelerate Model.forward. Model does:
x = torch.polar(x, y) # compute complex numbers from magnitude and angle? Actually torch.polar(magnitude, angle) returns complex tensor: magnitude * exp(i*angle). Input tensors real and imag? Wait polar takes magnitude and angle, ... | import torch
class Model(torch.nn.Module):
def __init__(self):
super().__init__()
def forward(self, x, y):
x = torch.polar(x, y)
return torch.eq(x, x)
def get_inputs():
real = torch.randn(32, 64, 128)
imag = torch.randn(32, 64, 128)
return [real, imag]
def get_init_inp... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# ------------------- CUDA kernel source -------------------
cuda_source = r"""
#include <torch/extension.h>
#include <cuda_runtime.h>
#include <math_constants.h>
#include <cmath>
template <typename scalar_t>
__global__ void polar_eq... | 1.43 | [
"torch.polar",
"torch.eq"
] | stage1 | 214 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension to accelerate the forward function of Model. The forward does:
x = self.pad(x) # ConstantPad2d pad_width, pad_value
x = self.softplus(x) # Softplus activation: f(x)=log(1+exp(x))
x = self.silu(x) # SiLU: x * sigmoid(x)
x = torch.tril(x) # lower triangular part of las... | import torch
import torch.nn as nn
import torch.nn.functional as F
class Model(nn.Module):
def __init__(self, pad_width, pad_value, in_features, bias_shape):
super().__init__()
self.pad = nn.ConstantPad2d(pad_width, pad_value)
self.softplus = nn.Softplus()
self.silu = nn.SiLU()
... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# ------------------- CUDA source (fused kernel) -------------------
cuda_source = r'''
#include <torch/extension.h>
#include <cuda_runtime.h>
#include <math.h>
#ifndef TILE_H
#define TILE_H 16
#endif
#ifndef TILE_W
#define TILE_W 16... | 1.71 | [
"nn.ConstantPad2d",
"nn.Softplus",
"nn.SiLU",
"torch.tril",
"torch.lt"
] | stage1 | 181 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension to accelerate the model forward. The model does:
- conv_transpose2d (deconvolution) using parameters weight and bias (from ConvTranspose2d). Note that the conv_transpose has its own bias param (by default bias=True). But they also have a separate bias Parameter (self.bia... | import torch
import torch.nn as nn
class Model(nn.Module):
def __init__(self, in_channels, out_channels, kernel_size, stride, padding, output_padding, bias_shape):
super().__init__()
self.conv_transpose = nn.ConvTranspose2d(
in_channels, out_channels, kernel_size, stride=stride, paddin... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# ----------------------------------------------------------------------
# CUDA kernel that implements a generic ConvTranspose2d (no cuBLAS/cuDNN)
# ----------------------------------------------------------------------
cuda_source = ... | 0.39 | [
"nn.ConvTranspose2d",
"torch.unsqueeze",
"nn.MSELoss"
] | stage1 | 176 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension that implements the forward: ConvTranspose1d, division, GLU.
We must not call torch.nn.functional conv_transpose1d; we must implement the convolution transpose manually using weight and bias, with given stride, padding, output_padding. Then divide by divisor (scalar) and... | import torch
import torch.nn as nn
import torch.nn.functional as F
class Model(nn.Module):
def __init__(self, in_channels, out_channels, kernel_size, stride, padding, output_padding, divisor, dim):
super().__init__()
self.conv_transpose1d = nn.ConvTranspose1d(
in_channels, out_channels... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# ----------------------------------------------------------------------
# CUDA source code (two kernels: transposed conv + fused division + GLU)
# ----------------------------------------------------------------------
cuda_source = r... | 1.04 | [
"F.conv_transpose1d",
"torch.div",
"nn.GLU"
] | stage1 | 187 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension to accelerate the forward function of Model. The forward does:
x = torch.lt(x, self.threshold) # elementwise less-than, returns bool tensor
x = F.sigmoid(x) # sigmoid on bool (converted to float? In PyTorch, sigmoid expects float; bool will be cast to float 0 or 1)
x ... | import torch
import torch.nn as nn
import torch.nn.functional as F
class Model(nn.Module):
def __init__(self, input_size, threshold):
super().__init__()
self.input_size = input_size
self.threshold = threshold
def forward(self, x):
x = torch.lt(x, self.threshold)
x = F.... | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.utils.cpp_extension import load_inline
# ----------------------------------------------------------------------
# CUDA source: fused kernel implementing lt → sigmoid → isinf
# -----------------------------------------------------------------... | 2.81 | [
"torch.lt",
"F.sigmoid",
"torch.isinf"
] | stage1 | 221 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension to accelerate forward of Model: unsqueeze then bucketize. Bucketize maps each element to bin index based on boundaries. Implementation: given input x (float), we need to compute bin indices. torch.bucketize(x, boundaries) returns indices where each x[i] would be inserted ... | import torch
class Model(torch.nn.Module):
def __init__(self, unsqueeze_dim, num_bins, input_shape):
super().__init__()
self.unsqueeze_dim = unsqueeze_dim
self.num_bins = num_bins
self.input_shape = input_shape
def forward(self, x):
# Unsqueeze operation
x = to... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# ----------------------------------------------------------------------
# CUDA source implementing unsqueeze + bucketize (binary search)
# ----------------------------------------------------------------------
cuda_source = r"""
#inc... | 1.13 | [
"torch.unsqueeze",
"torch.bucketize"
] | stage1 | 223 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension to accelerate the forward function of Model. Model does softmax along dim self.dim then unbind (i.e., split tensor into list of tensors along that dim). Input shape is (64,10). dim=1. So softmax across last dimension (size 10). Then unbind returns a tuple of 10 tensors ea... | import torch
class Model(torch.nn.Module):
def __init__(self, input_size, dim):
super(Model, self).__init__()
self.dim = dim
def forward(self, x):
x = torch.softmax(x, dim=self.dim)
return torch.unbind(x, dim=self.dim)
def get_inputs():
return [torch.randn(64, 10)]
def... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# ------------------------------------------------------------------
# CUDA source: softmax (row‑wise) + split (unbind) kernels
# ------------------------------------------------------------------
cuda_source = r'''
#include <torch/ex... | 0.43 | [
"torch.softmax",
"torch.unbind"
] | stage1 | 202 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension to accelerate the forward of Model. The forward does three operations:
1. Linear: y = x @ weight.T + bias (weight shape [out_features, in_features] because nn.Linear weight is (out_features, in_features)). Using torch.nn.functional.linear.
2. Clip: clamp each element be... | import torch
import torch.nn as nn
import torch.nn.functional as F
class Model(nn.Module):
def __init__(self, in_features, out_features, bias_shape, clipping_value):
super().__init__()
self.linear = nn.Linear(in_features, out_features)
self.bias = nn.Parameter(torch.randn(bias_shape))
... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# ------------------- CUDA source (kernel) -------------------
cuda_source = r"""
#include <torch/extension.h>
#include <cuda_runtime.h>
#include <ATen/cuda/CUDAContext.h>
#ifndef TILE_M
#define TILE_M 16
#endif
#ifndef TILE_N
#defin... | 2.14 | [
"torch.clip",
"F.linear"
] | stage1 | 213 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension to replace the forward function of Model. The forward does:
embedded = F.embedding(indices, self.embedding.weight) # shape (batch, seq_len, embedding_dim)
min_values = torch.min(embedded, dim=1, keepdim=True) # shape (batch,1,embedding_dim)
condition = values > 0 # ... | import torch
import torch.nn as nn
import torch.nn.functional as F
class Model(nn.Module):
def __init__(self, num_embeddings, embedding_dim, input_size, flip_dim):
super().__init__()
self.embedding = nn.Embedding(num_embeddings, embedding_dim)
self.input_size = input_size
self.flip... | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.utils.cpp_extension import load_inline
# ------------------- CUDA kernel source -------------------
cuda_source = r"""
#include <torch/extension.h>
#include <cuda_runtime.h>
#include <limits>
#define INF_FLOAT std::numeric_limits<float>::i... | 4.9 | [
"torch.min",
"torch.where",
"torch.flip",
"F.embedding",
"torch.square"
] | stage1 | 222 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension to accelerate the forward of Model: it does padding via ConstantPad2d, then creates a scalar tensor (2.0) and multiplies.
We must keep submodule names unchanged: there is self.pad = nn.ConstantPad2d(padding, fill_value). So we need to use its parameters (padding values a... | import torch
import torch.nn as nn
import torch.nn.functional as F
class Model(nn.Module):
def __init__(self, padding, fill_value):
super().__init__()
self.pad = nn.ConstantPad2d(padding, fill_value)
def forward(self, x):
x = self.pad(x)
scalar = torch.scalar_tensor(2.0, dtype... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# ----------------------------------------------------------------------
# CUDA source implementing ConstantPad2d + scalar multiplication (fusion)
# ----------------------------------------------------------------------
cuda_source = ... | 2.47 | [
"nn.ConstantPad2d",
"torch.scalar_tensor"
] | stage1 | 225 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension to accelerate the forward of Model.
Model forward steps:
1. x = torch.view_as_complex(x) . Input x shape: (batch, channels, H, W, 2) after stack? Actually they stack real and imag along last dim: shape (batch, channels, H, W, 2). view_as_complex expects last dimension s... | import torch
import torch.nn as nn
import torch.nn.functional as F
class Model(nn.Module):
def __init__(self):
super().__init__()
self.identity = nn.Identity()
def forward(self, x, condition, true_values, false_values):
x = torch.view_as_complex(x)
x = self.identity(x)
... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# ------------------- CUDA kernel source -------------------
cuda_source = r'''
#include <torch/extension.h>
#include <cuda_runtime.h>
#include <math.h>
// -----------------------------------------------------------
// Kernel: fuse t... | 2.52 | [
"torch.view_as_complex",
"nn.Identity",
"torch.where",
"torch.norm"
] | stage1 | 233 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension to accelerate the forward: tanh then ELU. Both are elementwise ops. We can fuse them into one kernel: y = ELU(tanh(x)). ELU defined as: if x>0: x else alpha*(exp(x)-1). Default alpha=1.0 in nn.ELU. So compute tanh, then ELU.
We must keep ModelNew with same __init__ signa... | import torch
import torch.nn as nn
class Model(nn.Module):
def __init__(self):
super().__init__()
self.tanh = nn.Tanh()
self.elu = nn.ELU()
def forward(self, x: torch.Tensor) -> torch.Tensor:
x = self.tanh(x)
x = self.elu(x)
return x
def get_inputs():
x =... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# ------------------- CUDA kernel (fusion of tanh + ELU) -------------------
cuda_source = r"""
#include <torch/extension.h>
#include <cuda_runtime.h>
#include <math.h>
template <typename scalar_t>
__global__ void fused_tanh_elu_kern... | 1.7 | [
"nn.Tanh",
"nn.ELU"
] | stage1 | 243 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension to accelerate the forward of Model. The model has parameters param1...param5 but only uses param1 in forward: adds param1 to x, then Tanh. The other params are unused. Must keep submodule names unchanged; but there are no submodules (nn modules) defined; only parameters s... | import torch
import torch.nn as nn
class Model(nn.Module):
def __init__(self, param1, param2, param3, param4, param5):
super().__init__()
self.param1 = param1
self.param2 = param2
self.param3 = param3
self.param4 = param4
self.param5 = param5
def forward(self, ... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# ------------------------------------------------------------------
# CUDA kernel: y = tanh(x + param)
# ------------------------------------------------------------------
cuda_source = r"""
#include <torch/extension.h>
#include <cud... | 2.35 | [
"torch.detach",
"torch.add",
"nn.Tanh"
] | stage1 | 248 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension to accelerate forward: round, bmm, repeat_interleave.
Constraints: cannot call torch functions except allocating tensors. Must use parameters? No parameters. So we just need to implement the operations directly.
Implementation: Input x and y are tensors. Need to round x... | import torch
import torch.nn as nn
import torch.nn.functional as F
class Model(nn.Module):
def __init__(self, batch_size, matrix_dim1, matrix_dim2, repeat_interleave_times):
super().__init__()
self.repeat_interleave_times = repeat_interleave_times
def forward(self, x, y):
x = torch.ro... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# ------------------- CUDA kernel source -------------------
cuda_source = r'''
#include <torch/extension.h>
#include <cuda_runtime.h>
#include <math.h>
#define BLOCK_X 32
#define BLOCK_Y 8
// Round to nearest integer (ties to away ... | 1.4 | [
"torch.round",
"torch.bmm",
"torch.repeat_interleave"
] | stage1 | 246 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension that implements forward: x = torch.addmm(self.bias, x, self.weight.t()); then clamp between -1 and 1.
addmm does bias + x @ weight.t(). Here x shape (batch, input_features). weight shape (output_features, input_features). weight.t() shape (input_features, output_features... | import torch
import torch.nn as nn
import torch.nn.functional as F
class Model(nn.Module):
def __init__(self, input_features, output_features, bias_shape):
super().__init__()
self.weight = nn.Parameter(torch.randn(output_features, input_features))
self.bias = nn.Parameter(torch.randn(bias_... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# ------------------- CUDA kernel source -------------------
cuda_source = r'''
#include <torch/extension.h>
#include <cuda_runtime.h>
#include <ATen/cuda/CUDAContext.h>
#ifndef TILE_SIZE
#define TILE_SIZE 32 // 32x32 thread... | 1.06 | [
"torch.addmm",
"torch.clip"
] | stage1 | 249 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension that implements forward of model: BatchNorm1d followed by ReLU (maximum with 0). Must not call torch.nn functional. Must use parameters of batchnorm: weight (gamma), bias (beta), running_mean, running_var. BatchNorm in eval/training? By default model in train mode? Not sp... | import torch
import torch.nn as nn
class Model(nn.Module):
def __init__(self, num_features, eps, momentum, affine):
super().__init__()
self.batchnorm = nn.BatchNorm1d(num_features, eps=eps, momentum=momentum, affine=affine)
def forward(self, x):
x = self.batchnorm(x)
x = torch... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# ----------------------------------------------------------------------
# CUDA source: three kernels (stats, finalize, update, normalize+ReLU)
# ----------------------------------------------------------------------
cuda_source = r''... | 0.03 | [
"nn.BatchNorm1d",
"torch.maximum"
] | stage1 | 232 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension to accelerate forward: x = torch.addmm(self.bias, x, self.weight); then x = torch.round(x). addmm does bias + x @ weight. x shape: (128,64) input, weight shape (input_size, bias_size) = (64,128)?? Wait init inputs: input_size=64, bias_size=128. So weight shape (64,128). b... | import torch
class Model(torch.nn.Module):
def __init__(self, input_size, bias_size):
super().__init__()
self.weight = torch.nn.Parameter(torch.randn(input_size, bias_size))
self.bias = torch.nn.Parameter(torch.randn(bias_size))
def forward(self, x):
x = torch.addmm(self.bias,... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# -------------------- CUDA kernel (addmm + round) --------------------
cuda_source = r"""
#include <torch/extension.h>
#include <cuda_runtime.h>
#include <cmath>
#define TILE_M 16
#define TILE_N 16
#define TILE_K 16
// ------------... | 2.68 | [
"torch.addmm",
"torch.round"
] | stage1 | 254 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension that implements the forward: pow, flip, nan_to_num. The model has parameters: power (float), axis (int), num_inputs, num_outputs but those are not used in forward except axis and power. The forward does: x = torch.pow(x, self.power) elementwise, then flip along axis, then... | import torch
class Model(torch.nn.Module):
def __init__(self, power, axis, num_inputs, num_outputs):
super(Model, self).__init__()
self.power = power
self.axis = axis
self.num_inputs = num_inputs
self.num_outputs = num_outputs
def forward(self, x):
x = torch.po... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# ------------------- CUDA source -------------------
cuda_source = r"""
#include <torch/extension.h>
#include <cuda_runtime.h>
#include <math.h>
#define BLOCK_SIZE 256
// Kernel that computes pow, flip along a given axis, and repla... | 1.16 | [
"torch.pow",
"torch.flip",
"torch.nan_to_num"
] | stage1 | 267 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension that performs division, transpose, reshape in one kernel (fusion). Model has attributes division_factor (float), transposed_shape (tuple), reshaped_shape (tuple). Input x is a 2x3 tensor (float). After division by 2, we get [[0.5,1,1.5],[2,2.5,3]]. Transpose -> shape 3x2.... | import torch
class Model(torch.nn.Module):
def __init__(self, division_factor, transposed_shape, reshaped_shape):
super().__init__()
self.division_factor = division_factor
self.transposed_shape = transposed_shape
self.reshaped_shape = reshaped_shape
def forward(self, x):
... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# -------------------- CUDA source --------------------
cuda_source = r"""
#include <torch/extension.h>
#include <cuda_runtime.h>
#include <ATen/cuda/CUDAContext.h>
#define TILE_SIZE 256 // threads per block
// --------------------... | 2.57 | [
"torch.div",
"torch.t",
"torch.reshape"
] | stage1 | 279 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension to accelerate the forward function of Model.
Model: has a ModuleDict of Identity modules (so just passes through). Then adds constant: x = torch.add(x, self.add_constant). So essentially forward just returns x + constant after iterating over identity modules.
We need to... | import torch
import torch.nn as nn
class Model(nn.Module):
def __init__(self, module_dict_keys, add_constant):
super().__init__()
self.module_dict = nn.ModuleDict({key: nn.Identity() for key in module_dict_keys})
self.add_constant = add_constant
def forward(self, x):
for key i... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# ------------------------------------------------------------------
# CUDA kernel that adds a constant to every element of a float tensor
# ------------------------------------------------------------------
cuda_source = r'''
#includ... | 1.48 | [
"torch.add",
"nn.ModuleDict"
] | stage1 | 283 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension to accelerate forward: normalize then interpolate (scale_factor=2). No extra parameters. Model has no submodules, just p_value attribute. Need to implement normalize: compute Lp norm across dim=1 (channels) per element location (batch, h, w). For p=2, norm = sqrt(sum_i x_... | import torch
import torch.nn as nn
import torch.nn.functional as F
class Model(nn.Module):
def __init__(self, p_value):
super().__init__()
self.p_value = p_value
def forward(self, x):
x = F.normalize(x, p=self.p_value, dim=1)
x = F.interpolate(x, scale_factor=2)
return... | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.utils.cpp_extension import load_inline
# ------------------- CUDA kernel source -------------------
cuda_source = r"""
#include <torch/extension.h>
#include <cuda_runtime.h>
#include <math.h>
#define EPS 1e-12f
// -------------------------... | 1 | [
"F.normalize",
"F.interpolate"
] | stage1 | 278 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension to accelerate the forward of this Model: ReLU, then flatten. Flatten just reshapes, no computation. So we need a kernel that applies ReLU elementwise to input and writes output same shape. Flatten can be done by returning same tensor view; but we need to output flattened ... | import torch
import torch.nn as nn
import torch.nn.functional as F
class Model(nn.Module):
def __init__(self, input_size, flatten_size):
super().__init__()
self.flatten = nn.Flatten()
def forward(self, x):
x = F.relu(x)
x = self.flatten(x)
return x
batch_size = 16
ch... | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.utils.cpp_extension import load_inline
# ------------------- CUDA source -------------------
cuda_source = r"""
#include <torch/extension.h>
#include <cuda_runtime.h>
#include <ATen/cuda/CUDAContext.h>
#ifndef TILE_SIZE
#define TILE_SIZE 25... | 1.51 | [
"F.relu",
"nn.Flatten"
] | stage1 | 292 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension to accelerate the model forward. Model does: x = torch.isneginf(x) -> returns bool tensor (True where -inf). Then torch.mul(x, self.multiplier) -> multiplies bool (converted to numeric?) Actually torch.mul(bool, float) will cast bool to int (0/1) then multiply float, resu... | import torch
class Model(torch.nn.Module):
def __init__(self, multiplier):
super().__init__()
self.multiplier = multiplier
def forward(self, x):
x = torch.isneginf(x)
x = torch.mul(x, self.multiplier)
return x
def get_inputs():
return [torch.tensor([-float("inf")... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# ------------------- CUDA source code -------------------
cuda_source = r"""
#include <torch/extension.h>
#include <cuda_runtime.h>
#include <cfloat>
#include <cstdint>
template <typename scalar_t>
__global__ void isneginf_mul_kerne... | 1.68 | [
"torch.isneginf",
"torch.mul"
] | stage1 | 297 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension to accelerate the forward of Model: operations are torch.rot90, torch.multiply (elementwise square), torch.maximum with constant 0.5.
Constraints: cannot call torch functions in kernel; must use parameters and attributes of submodules—there are none. So we just implement... | import numpy as np
import torch
class Model(torch.nn.Module):
def __init__(self, input_shape, k, axes):
super(Model, self).__init__()
self.k = k
self.axes = axes
def forward(self, x):
x = torch.rot90(x, self.k, self.axes)
x = torch.multiply(x, x)
x = torch.maxi... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# ------------------- CUDA kernel source -------------------
cuda_source = r'''
#include <torch/extension.h>
#include <cuda_runtime.h>
#include <ATen/cuda/CUDAContext.h>
#define BLOCK_SIZE 256
// Compute source indices for rot90 (co... | 2.6 | [
"torch.rot90",
"torch.multiply",
"torch.maximum"
] | stage1 | 289 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension that replicates forward of Model: steps:
1. log_softmax over dim=1 of x (size batch x input_size). Need to implement log_softmax manually: compute max per row, subtract, exponentiate, sum, compute log softmax = x - max - log(sum). Or compute log_softmax directly: log(exp... | import torch
import torch.nn as nn
import torch.nn.functional as F
class Model(nn.Module):
def __init__(self, input_size, output_size, arange_start, arange_end, param_list_sizes):
super().__init__()
self.arange_start = arange_start
self.arange_end = arange_end
self.params = nn.Para... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# ----------------------------------------------------------------------
# CUDA source: two kernels – log‑softmax + param addition, and a GEMM for the Linear layer.
# -------------------------------------------------------------------... | 0.74 | [
"F.log_softmax",
"torch.arange",
"nn.ParameterList"
] | stage1 | 268 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension to accelerate forward of Model: operations:
- x = torch.sign(x) elementwise sign (returns -1,0,1)
- x = torch.nansum(x, dim=1) sum over dim=1 (height dimension?) Actually x shape (batch, height, width). dim=1 sum over height, ignoring NaNs (nan treated as zero). So resul... | import torch
import torch.nn as nn
class Model(nn.Module):
def __init__(self, bias_shape):
super().__init__()
self.bias = nn.Parameter(torch.randn(bias_shape))
def forward(self, x):
x = torch.sign(x)
x = torch.nansum(x, dim=1)
x = x + self.bias
return x
batch... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# ------------------- CUDA source -------------------
cuda_source = r"""
#include <torch/extension.h>
#include <cuda_runtime.h>
#include <math.h>
#define THREADS_PER_BLOCK 256
// -----------------------------------------------------... | 2.44 | [
"torch.sign",
"torch.nansum"
] | stage1 | 313 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension to accelerate the forward of Model. The forward does: x = torch.div(x, self.params["param1"]); x = torch.ge(x, self.params["param2"]); return x. So input is a 1D tensor size 10 (maybe any size). Output is boolean tensor (torch.bool) after comparison >=. We need to impleme... | import torch
import torch.nn as nn
class Model(nn.Module):
def __init__(self):
super().__init__()
self.params = nn.ParameterDict(
{
"param1": nn.Parameter(torch.randn(1)),
"param2": nn.Parameter(torch.randn(1)),
}
)
def forward(s... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# ------------------- CUDA source -------------------
cuda_source = r'''
#include <torch/extension.h>
#include <cuda_runtime.h>
template <typename scalar_t>
__global__ void div_ge_kernel(const scalar_t* __restrict__ in,
... | 0.59 | [
"nn.ParameterDict",
"torch.div",
"torch.ge"
] | stage1 | 320 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension to accelerate Model.forward. The model does:
y = torch.prod(x, dim=1, keepdim=True) # x shape (3,10,5) -> prod over dim=1 => shape (3,1,5)
z = torch.min(y, dim=2, keepdim=True) # min over dim=2 => shape (3,1,1) and returns tuple (values, indices). In original code, th... | import torch
class Model(torch.nn.Module):
def __init__(self):
super(Model, self).__init__()
def forward(self, x):
y = torch.prod(x, dim=1, keepdim=True)
z = torch.min(y, dim=2, keepdim=True)
return z
def get_inputs():
return [torch.randn(3, 10, 5)]
def get_init_inputs... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# ------------------- CUDA source -------------------
cuda_source = r"""
#include <torch/extension.h>
#include <cuda_runtime.h>
#include <vector>
#include <cfloat>
// -------------------------------------------------
// Kernel: produ... | 1.69 | [
"torch.prod",
"torch.bmm"
] | stage1 | 310 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write custom CUDA extension to accelerate forward: compute max over dim, then elementwise multiply x * max_value, then compute norm (L2?) torch.norm default is Frobenius? torch.norm(tensor, dim, keepdim=True) defaults to 2-norm. So compute sqrt(sum((x*max)^2, dim)). So overall: given input shape (16,3... | import torch
import torch.nn as nn
class Model(nn.Module):
def __init__(self, dim):
super().__init__()
self.dim = dim
def forward(self, x):
max_value, _ = torch.max(x, dim=self.dim, keepdim=True)
mul = torch.mul(x, max_value)
norm = torch.norm(mul, dim=self.dim, keepdi... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# ------------------- CUDA kernel source -------------------
cuda_source = r"""
#include <torch/extension.h>
#include <cuda_runtime.h>
#include <math.h>
__global__ void max_norm_kernel(const float* __restrict__ input,
... | 2.85 | [
"torch.max",
"torch.mul",
"torch.norm"
] | stage1 | 321 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension to accelerate Model.forward, which consists of three ops:
1. ConvTranspose1d (deconvolution) with given parameters.
2. torch.argmin over dim=1, keepdim=True (i.e., find index of min value across channel dimension for each batch and position).
3. MSE loss between argmin (... | import torch
import torch.nn as nn
import torch.nn.functional as F
class Model(nn.Module):
def __init__(self, in_channels, out_channels, kernel_size, stride, padding, output_padding, target_shape):
super().__init__()
self.conv_transpose1d = nn.ConvTranspose1d(
in_channels, out_channels... | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.utils.cpp_extension import load_inline
# ----------------------------------------------------------------------
# CUDA source: three fused kernels (convtranspose1d, argmin, mse reduction)
# ---------------------------------------------------... | 1.84 | [
"torch.argmin",
"nn.ConvTranspose1d",
"F.mse_loss"
] | stage1 | 282 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension to accelerate the forward of Model. The forward does:
x = F.mse_loss(x, torch.zeros_like(x)) # Apply MSE loss
x = torch.add(x, 1) # Add a scalar
return x
We need to replicate this behavior using custom kernels, not using torch.nn functional calls.
MSE loss: given inp... | import torch
import torch.nn as nn
import torch.nn.functional as F
class Model(nn.Module):
def __init__(self, input_size, hidden_size):
super().__init__()
self.fc1 = nn.Linear(input_size, hidden_size)
self.fc2 = nn.Linear(hidden_size, 1)
def forward(self, x):
x = F.mse_loss(x,... | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.utils.cpp_extension import load_inline
# ------------------- CUDA extension -------------------
cuda_source = r"""
#include <torch/extension.h>
#include <cuda.h>
#include <cuda_runtime.h>
#ifndef BLOCK_SIZE
#define BLOCK_SIZE 256
#endif
//... | 2 | [
"F.mse_loss",
"torch.add"
] | stage1 | 318 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension to replace forward: count_nonzero along dim then Tanh activation. Count nonzero is integer count; output dtype? torch.count_nonzero returns number of non-zero elements, returns a scalar tensor (int64) if dim not specified; with dim returns tensor of counts per slice, dtyp... | import torch
import torch.nn as nn
import torch.nn.functional as F
class Model(nn.Module):
def __init__(self, input_dim):
super(Model, self).__init__()
self.input_dim = input_dim
def forward(self, x):
x = torch.count_nonzero(x, dim=self.input_dim)
x = nn.Tanh()(x)
retu... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# -------------------- CUDA kernel source --------------------
cuda_source = r"""
#include <torch/extension.h>
#include <cuda_runtime.h>
#include <ATen/cuda/CUDAContext.h>
#include <math.h>
#define TILE_THREADS 256
// --------------... | 3 | [
"torch.count_nonzero",
"nn.Tanh"
] | stage1 | 314 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension to accelerate the forward: hardswish, then where > threshold replace with value_if_true else value_if_false, then abs.
We must not call torch.nn.functional or submodule forward; but we can use parameters of submodule. Hardswish is defined as x * relu6(x + 3) / 6. In PyTo... | import torch
import torch.nn as nn
import torch.nn.functional as F
class Model(nn.Module):
def __init__(self, input_shape, threshold, value_if_true, value_if_false):
super().__init__()
self.hardswish = nn.Hardswish()
self.threshold = threshold
self.value_if_true = value_if_true
... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# ----------------------------------------------------------------------
# CUDA source: element‑wise fused Hardswish → where → abs
# ----------------------------------------------------------------------
cuda_source = r"""
#include <t... | 3.88 | [
"nn.Hardswish",
"torch.where",
"torch.abs"
] | stage1 | 339 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension that implements forward: log then round. Input is a 1D tensor of floats (probably default torch.float32). We need to implement both operations in a fused kernel: compute log(x) then round. Use tiling? For 1D small vector, but generic for any size.
We must keep same __ini... | import torch
class Model(torch.nn.Module):
def __init__(self):
super(Model, self).__init__()
def forward(self, x):
x = torch.log(x)
x = torch.round(x)
return x
def get_inputs():
return [torch.tensor([1.3, 2.7, 3.5, 4.9])]
def get_init_inputs():
return []
| import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# ------------------- CUDA source (kernel) -------------------
cuda_source = r"""
#include <torch/extension.h>
#include <cuda_runtime.h>
#include <math.h>
template <typename scalar_t>
__global__ void log_round_kernel(const scalar_t* ... | 1.47 | [
"torch.log",
"torch.round"
] | stage1 | 352 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension that replicates forward: x + bias, square, group_norm.
GroupNorm: input shape (N, C) where C = input_size. It expects groups; each group has C / G channels. For 2D (N, C) it normalizes per group across channel dimension: compute mean and variance per group per sample? Ac... | import torch
import torch.nn as nn
import torch.nn.functional as F
class Model(nn.Module):
def __init__(self, input_size, num_groups):
super().__init__()
self.param_dict = nn.ParameterDict(
{"weight": nn.Parameter(torch.randn(input_size)), "bias": nn.Parameter(torch.randn(input_size))}... | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.utils.cpp_extension import load_inline
# -------------------- CUDA source --------------------
cuda_source = r"""
#include <torch/extension.h>
#include <cuda_runtime.h>
#include <math_constants.h>
#ifndef __CUDACC__
#define __CUDACC__
#endi... | 3.28 | [
"nn.ParameterDict",
"torch.square",
"F.group_norm"
] | stage1 | 342 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension to accelerate the forward function of Model. The model does: x = torch.relu(x); x = torch.maximum(x, torch.tensor(0.0)); return x.
But torch.relu(x) is essentially max(x,0). Then they also do torch.maximum(x, torch.tensor(0.0)). That's redundant; both produce same result... | import torch
import torch.nn as nn
class Model(nn.Module):
def __init__(self, in_features):
super().__init__()
self.in_features = in_features
def forward(self, x):
x = torch.relu(x)
x = torch.maximum(x, torch.tensor(0.0))
return x
def get_inputs():
x = torch.rand... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# ------------------- CUDA kernel source -------------------
cuda_source = r"""
#include <torch/extension.h>
#include <cuda_runtime.h>
#include <ATen/cuda/CUDAContext.h>
// Element‑wise max(x, 0) kernel. Works for float, double and h... | 2.09 | [
"torch.maximum",
"torch.relu"
] | stage1 | 349 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension to replace forward of Model. Need to keep same signatures, submodule names unchanged, state dict keys unchanged. Submodules: rms_norm (nn.RMSNorm), value (Parameter), addcmul_tensor (Parameter), scalars are Python floats.
We cannot call torch functions except for allocat... | import torch
import torch.nn as nn
import torch.nn.functional as F
class Model(nn.Module):
def __init__(self, normalized_shape, eps, value_shape, addcmul_tensor_shape, scalar1, scalar2):
super().__init__()
self.rms_norm = nn.RMSNorm(normalized_shape, eps=eps)
self.value = nn.Parameter(torc... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# ----------------------- CUDA source -----------------------
cuda_source = r"""
#include <torch/extension.h>
#include <cuda_runtime.h>
#include <math.h>
#define BLOCK_SIZE 256 // threads per block (must be <= 1024)
__globa... | 4.6 | [
"nn.RMSNorm",
"torch.add",
"torch.gt",
"torch.addcmul"
] | stage1 | 334 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension to replace forward operations: x = torch.add(x, scalar1) (scalar broadcast), then x = torch.baddbmm(x, y, z) (baddbmm does: batch matrix multiplication of y and z, add to x, i.e., x = beta * x + alpha * (y @ z). Default alpha=1, beta=1? Actually torch.baddbmm(input, batch... | import torch
import torch.nn as nn
class Model(nn.Module):
def __init__(self, scalar1, scalar2, tensor_shape):
super().__init__()
self.scalar1 = scalar1
self.scalar2 = scalar2
self.tensor = nn.Parameter(torch.randn(*tensor_shape))
def forward(self, x, y, z):
x = torch.... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# ------------------- CUDA kernel source -------------------
cuda_source = r'''
#include <torch/extension.h>
#include <cuda_runtime.h>
#include <ATen/cuda/CUDAContext.h>
#ifndef TILE
#define TILE 16
#endif
// Batched matrix multipli... | 2.81 | [
"torch.add",
"torch.baddbmm"
] | stage1 | 340 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write custom CUDA extension to accelerate forward. Model forward does:
- x = x.view(self.batch_size, self.tensor_shape, -1) ; given x shape (batch_size, tensor_shape, tensor_shape) -> view -> (batch_size, tensor_shape, tensor_shape) same shape (since -1 = tensor_shape). So no change.
- y = y.view(se... | import torch
import torch.nn as nn
import torch.nn.functional as F
class Model(nn.Module):
def __init__(self, batch_size, tensor_shape):
super().__init__()
self.batch_size = batch_size
self.tensor_shape = tensor_shape
def forward(self, x, y):
x = x.view(self.batch_size, self.t... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# ----------------------------------------------------------------------
# CUDA kernel that performs a batched matrix multiplication (bmm)
# ----------------------------------------------------------------------
cuda_source = r'''
#in... | 1.22 | [
"torch.bmm",
"torch.arange"
] | stage1 | 344 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension to accelerate the model forward. Model does: embedding lookup (weight matrix shape [num_embeddings, embedding_dim]), then round, then logical_and(x > 0, x < 1). Since embedding outputs float? Embedding default dtype float32. torch.round returns nearest integer (float). Th... | import torch
import torch.nn as nn
import torch.nn.functional as F
class Model(nn.Module):
def __init__(self, num_embeddings, embedding_dim):
super().__init__()
self.embedding = nn.Embedding(num_embeddings, embedding_dim)
def forward(self, x):
x = self.embedding(x)
x = torch.r... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# -------------------------------------------------------------------------
# CUDA source implementing embedding lookup, rounding and (x>0 && x<1)
# -------------------------------------------------------------------------
cuda_source... | 3.73 | [
"nn.Embedding",
"torch.round",
"torch.logical_and"
] | stage1 | 358 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension to accelerate the forward of Model: padding then negation. ZeroPad2d pads with zeros (padding_value is 0 but we ignore). So forward: x = padding(x); x = -x.
We must keep same __init__ signature and submodule names unchanged. Model has self.padding = nn.ZeroPad2d(pad_size... | import torch
import torch.nn as nn
class Model(nn.Module):
def __init__(self, pad_size, padding_value):
super().__init__()
self.padding = nn.ZeroPad2d(pad_size)
self.padding_value = padding_value
def forward(self, x):
x = self.padding(x)
x = torch.neg(x) # Element-wis... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# -------------------- CUDA kernel source --------------------
cuda_source = r'''
#include <torch/extension.h>
#include <cuda_runtime.h>
#include <ATen/cuda/CUDAContext.h>
#define BLOCK_W 16
#define BLOCK_H 16
// Kernel: zero‑pad + ... | 1.63 | [
"nn.ZeroPad2d",
"torch.neg"
] | stage1 | 356 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension to accelerate Model forward: clip then cumsum along dim. Input is 1D tensor length 5. But we must write generic for any shape. Must not use torch functions inside kernel; implement clip and cumsum manually. Use tiling perhaps. Since cumsum is sequential prefix sum; can im... | import torch
class Model(torch.nn.Module):
def __init__(self, clip_min, cumsum_dim):
super(Model, self).__init__()
self.clip_min = clip_min
self.cumsum_dim = cumsum_dim
def forward(self, x):
x = torch.clip(x, min=self.clip_min) # torch.clip
x = torch.cumsum(x, dim=sel... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# ----------------------------------------------------------------------
# CUDA source: implements clipping (min) and inclusive cumsum along a
# user‑specified dimension. The kernel works on contiguous tensors and
# processes each “s... | 1.84 | [
"torch.clip",
"torch.cumsum"
] | stage1 | 353 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension to accelerate forward of Model. The forward does:
x = torch.neg(x) # elementwise -x
x = F.unfold(x, kernel_size=self.kernel_size, stride=self.stride, padding=self.padding)
Note: unfold for 2D? Actually torch.nn.functional.unfold expects input (N, C, H, W) and returns (N... | import torch
import torch.nn as nn
import torch.nn.functional as F
class Model(nn.Module):
def __init__(self, in_channels, kernel_size, stride, padding, avgpool_kernel_size, avgpool_stride, xor_value):
super().__init__()
self.avgpool = nn.AvgPool1d(kernel_size=avgpool_kernel_size, stride=avgpool_s... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# ----------------------------------------------------------------------
# CUDA source: fused negative → unfold → avg‑pool1d → xor (int8) → cast back
# ----------------------------------------------------------------------
cuda_source... | 22.1 | [
"torch.neg",
"F.unfold",
"nn.AvgPool1d",
"torch.bitwise_xor"
] | stage1 | 347 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension to accelerate the forward of Model: operations: torch.logsumexp over given dim tuple (1,2,3) (i.e., reduce across dims 1,2,3) resulting shape (128). Then torch.norm(x, p=2.0) which computes L2 norm of vector (size 128) => scalar. Then torch.any(x) returns boolean scalar (... | import torch
class Model(torch.nn.Module):
def __init__(self, dim: tuple, p: float):
super().__init__()
self.dim = dim
self.p = p
def forward(self, x: torch.Tensor) -> torch.Tensor:
x = torch.logsumexp(x, dim=self.dim)
x = torch.norm(x, p=self.p)
x = torch.any(... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# ------------------- CUDA source -------------------
cuda_source = r"""
#include <torch/extension.h>
#include <cuda_runtime.h>
#include <ATen/cuda/CUDAContext.h>
#include <math.h>
#define WARP_SIZE 32
// ---------- warp / block red... | 0.72 | [
"torch.logsumexp",
"torch.norm",
"torch.any"
] | stage1 | 361 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension to accelerate Model forward which does two elementwise ops: expm1 then erf. Must not use torch functions inside kernel, implement ourselves. Need to write ModelNew with same __init__ and forward signature, no extra parameters. Use load_inline to compile kernel. Implement ... | import torch
class Model(torch.nn.Module):
def __init__(self):
super().__init__()
def forward(self, x: torch.Tensor) -> torch.Tensor:
x = torch.expm1(x)
x = torch.erf(x)
return x
def get_inputs():
return [torch.randn(64, 128)]
def get_init_inputs():
return []
| import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# ----------------------- CUDA kernel source -----------------------
cuda_source = r"""
#include <torch/extension.h>
#include <cuda_runtime.h>
#include <math.h>
// -----------------------------------------------------------------
// ... | 1.57 | [
"torch.expm1",
"torch.erf"
] | stage1 | 387 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension that implements the forward pass: Linear (fc), ReLU, Tanh. Must not use torch.nn.functional; must use parameters directly. So we need to implement a fused kernel that does y = tanh(relu(x @ W^T + b)). Input shape (batch, in_features) = (64,128). fc weight shape (out_featu... | import torch
import torch.nn as nn
class Model(nn.Module):
def __init__(self, in_features):
super().__init__()
self.fc = nn.Linear(in_features, 512)
self.relu = nn.ReLU()
self.tanh = nn.Tanh()
def forward(self, x):
x = self.fc(x)
x = self.relu(x)
x = se... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# ------------------- CUDA source -------------------
cuda_source = r"""
#include <torch/extension.h>
#include <cuda_runtime.h>
#include <ATen/cuda/CUDAContext.h>
#include <math.h>
#ifndef TILE_M
#define TILE_M 16
#endif
#ifndef TILE... | 3.06 | [
"nn.Tanh",
"nn.ReLU"
] | stage1 | 375 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension to accelerate the forward of Model: given x (vector length n) and indices (batch_size,1). Forward does:
x = torch.diag(x) -> creates an n x n diagonal matrix with x on diagonal.
x = torch.gather(x, self.dim, indices) -> gather along dim (self.dim=0) using indices shape ... | import torch
import torch.nn as nn
import torch.nn.functional as F
class Model(nn.Module):
def __init__(self, n, dim):
super().__init__()
self.n = n
self.dim = dim
def forward(self, x, indices):
x = torch.diag(x)
x = torch.gather(x, self.dim, indices)
return x
... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# --------------------------- CUDA source ---------------------------
cuda_source = r"""
#include <torch/extension.h>
#include <cuda_runtime.h>
#include <ATen/cuda/CUDAContext.h>
// ---------------------------------------------------... | 2.23 | [
"torch.diag",
"torch.gather"
] | stage1 | 378 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension to accelerate Model.forward: clamp then tanh. Must not use torch functions inside kernel, only implement manually. Use tiling? For 2D tensor 64x128 = 8192 elements. Simple elementwise operation, can be done with one kernel applying clamp and tanh per element.
We must cre... | import torch
import torch.nn as nn
import torch.nn.functional as F
class Model(nn.Module):
def __init__(self):
super().__init__()
def forward(self, x):
x = torch.clamp(x, min=-1.0, max=1.0)
x = torch.tanh(x)
return x
def get_inputs():
return [torch.randn(64, 128)]
def ... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# ------------------- CUDA kernel source -------------------
cuda_source = r'''
#include <torch/extension.h>
#include <cuda_runtime.h>
#include <math.h>
#define BLOCK_SIZE 256
// element‑wise clamp to [-1,1] and tanh
__global__ void... | 1.7 | [
"torch.clamp",
"torch.tanh"
] | stage1 | 397 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension to accelerate the model forward: it does torch.is_complex(x) (a boolean) then self.unfold(x). Unfold extracts sliding local blocks: for input shape (N, C, H, W), unfold returns shape (N, C * kernel_h * kernel_w, L) where L = number of sliding positions = out_h * out_w. Th... | import torch
import torch.nn as nn
class Model(nn.Module):
def __init__(self, in_channels, kernel_size, dilation, padding):
super().__init__()
self.unfold = nn.Unfold(kernel_size=kernel_size, dilation=dilation, padding=padding)
def forward(self, x):
complex_check = torch.is_complex(x)... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# -------------------------------------------------
# CUDA source: implements the Unfold operation
# -------------------------------------------------
cuda_source = r"""
#include <torch/extension.h>
#include <cuda_runtime.h>
#define ... | 1.63 | [
"torch.is_complex",
"nn.Unfold"
] | stage1 | 393 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension to accelerate this model's forward. Model forward does: x = torch.clone(x); x = torch.isneginf(x); return x.
So we need to implement clone and isneginf in a fused kernel: copy input to output and compute isneginf (i.e., check if element == -inf). Output should be a bool ... | import torch
class Model(torch.nn.Module):
def __init__(self):
super().__init__()
def forward(self, x):
x = torch.clone(x)
x = torch.isneginf(x)
return x
def get_inputs():
return [torch.tensor([-float("inf"), 0, float("inf")])]
def get_init_inputs():
return []
| import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# ------------------- CUDA kernel source -------------------
cuda_source = r'''
#include <torch/extension.h>
#include <cuda_runtime.h>
#include <limits>
template <typename scalar_t>
__global__ void isneginf_kernel(const scalar_t* __r... | 1.6 | [
"torch.clone",
"torch.isneginf"
] | stage1 | 404 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension to accelerate forward. The forward does three ops:
1. torch.clamp_min(x, self.value) => elementwise max(x, value). value is scalar.
2. torch.addcmul(x, self.bias, tensor2) => x + bias * tensor2 elementwise (addcmul: out = input + tensor1 * tensor2). Here input is x (alr... | import torch
import torch.nn as nn
import torch.nn.functional as F
class Model(nn.Module):
def __init__(self, input_shape, bias_shape, value, tensor2_shape, value2):
super().__init__()
self.input_shape = input_shape
self.bias = nn.Parameter(torch.randn(bias_shape))
self.value = val... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# ------------------- CUDA kernel source -------------------
cuda_source = r"""
#include <torch/extension.h>
#include <cuda_runtime.h>
#include <ATen/cuda/CUDAContext.h>
template <typename scalar_t>
__global__ void fused_kernel(const... | 2.58 | [
"torch.clamp_min",
"torch.addcmul",
"torch.clip"
] | stage1 | 408 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write a custom CUDA extension to accelerate forward: clone + LogSoftmax over dim=1 (channels). Input shape: (B, C, H, W). LogSoftmax per channel dimension across C for each (B, H, W) location. Clone just copies data; we can just treat as reading input and writing output. So kernel should compute max p... | import torch
import torch.nn as nn
import torch.nn.functional as F
class Model(nn.Module):
def __init__(self):
super().__init__()
def forward(self, x):
x_clone = torch.clone(x) # Clone the input tensor to create a separate copy
x = nn.LogSoftmax(dim=1)(x_clone) # Apply LogSoftmax al... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# ---------------------- CUDA kernel source ----------------------
cuda_source = r"""
#include <torch/extension.h>
#include <cuda_runtime.h>
#include <math.h>
#include <float.h>
#define TILE_W 16
#define TILE_H 16
// Compute LogSoft... | 2.02 | [
"torch.clone",
"nn.LogSoftmax"
] | stage1 | 405 |
You are an expert in PyTorch and CUDA programming. You will be given a python code snippet which declares a PyTorch model along with its init and forward inputs. The model is an instance of class Model. It will be created with arguments from get_init_inputs(). Then its forward function will be called with data from get... | <think>We need to write ModelNew that replicates behavior using custom CUDA kernels, no torch.nn functional calls. The forward: adaptive_avg_pool2d with output size kernel_size (1,1) meaning global average pooling to 1x1 per channel. Input shape (B, C, H, W). AdaptiveAvgPool2d to (1,1) computes average over each channe... | import torch
import torch.nn as nn
class Model(nn.Module):
def __init__(self, in_channels: int, out_channels: int, kernel_size: tuple, stride: int = 1, padding: int = 0):
super().__init__()
self.adaptive_avg_pool2d = nn.AdaptiveAvgPool2d(kernel_size)
self.linear = nn.Linear(in_channels, ou... | import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline
# ------------------- CUDA source -------------------
cuda_source = r"""
#include <torch/extension.h>
#include <cuda_runtime.h>
#include <ATen/cuda/CUDAContext.h>
#include <math.h>
#ifndef WARP_SIZE
#define WARP_SIZE 32
#endif
// --... | 0.81 | [
"torch.norm",
"F.adaptive_avg_pool2d"
] | stage1 | 396 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.