kernel-train-problems / train_problems.jsonl
K1ta141k's picture
Upload 140 train problems and 140 Verifier-v2-verified clean teacher traces
3e697eb verified
Raw History Blame Contribute Delete
297 kB
{"problem_id": "kb1_002_standard_matrix_multiplication", "source_kb_id": 2, "category": "matmul", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_002_standard_matrix_multiplication (KernelBench Level 1 #2, split=train, category=matmul, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_002_standard_matrix_multiplication\"\nSOURCE_KB_ID = 2\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B)\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs matrix multiplication.\n\n Args:\n A: Input tensor of shape (M, K).\n B: Input tensor of shape (K, N).\n\n Returns:\n Output tensor of shape (M, N).\n \"\"\"\n return torch.matmul(A, B)\n\nM = 1024 * 2\nK = 4096 * 2\nN = 2048 * 2\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 1024\nK = 2048\nN = 1024\n\ndef get_inputs():\n A = torch.rand(M, K)\n B = torch.rand(K, N)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_004_matrix_vector_multiplication", "source_kb_id": 4, "category": "matmul", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_004_matrix_vector_multiplication (KernelBench Level 1 #4, split=train, category=matmul, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_004_matrix_vector_multiplication\"\nSOURCE_KB_ID = 4\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs matrix-vector multiplication (C = A * B).\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs matrix-vector multiplication.\n\n Args:\n A: Input matrix of shape (M, K).\n B: Input vector of shape (K, 1).\n\n Returns:\n Output vector of shape (M, 1).\n \"\"\"\n return torch.matmul(A, B)\n\nM = 256 * 8 # 2048\nK = 131072 * 8 # 1048576\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 1024\nK = 16384\n\ndef get_inputs():\n A = torch.rand(M, K)\n B = torch.rand(K, 1)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_005_matrix_scalar_multiplication", "source_kb_id": 5, "category": "matmul", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_005_matrix_scalar_multiplication (KernelBench Level 1 #5, split=train, category=matmul, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_005_matrix_scalar_multiplication\"\nSOURCE_KB_ID = 5\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a matrix-scalar multiplication (C = A * s)\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, s: float) -> torch.Tensor:\n \"\"\"\n Performs matrix-scalar multiplication.\n\n Args:\n A: Input matrix of shape (M, N)\n s: Scalar value\n\n Returns:\n C: Resulting matrix of shape (M, N)\n \"\"\"\n return A * s\n\nM = 16384 * 4\nN = 4096 * 4\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 4096\nN = 4096\n\ndef get_inputs():\n A = torch.rand(M, N)\n s = 3.14\n return [A, s]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_006_matmul_with_large_k_dimension", "source_kb_id": 6, "category": "matmul", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_006_matmul_with_large_k_dimension (KernelBench Level 1 #6, split=train, category=matmul, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_006_matmul_with_large_k_dimension\"\nSOURCE_KB_ID = 6\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B) with a large K dimension\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs matrix multiplication of A and B.\n\n Args:\n A: Input tensor of shape (M, K)\n B: Input tensor of shape (K, N)\n\n Returns:\n Output tensor of shape (M, N)\n \"\"\"\n return torch.matmul(A, B)\n\nM = 256\nN = 256\nK = 131072 * 4\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 256\nN = 256\nK = 32768\n\ndef get_inputs():\n A = torch.rand(M, K)\n B = torch.rand(K, N)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_007_matmul_with_small_k_dimension", "source_kb_id": 7, "category": "matmul", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_007_matmul_with_small_k_dimension (KernelBench Level 1 #7, split=train, category=matmul, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_007_matmul_with_small_k_dimension\"\nSOURCE_KB_ID = 7\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B) with a small K dimension\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs matrix multiplication.\n\n Args:\n A: Input tensor of shape (M, K).\n B: Input tensor of shape (K, N).\n\n Returns:\n Output tensor of shape (M, N).\n \"\"\"\n return torch.matmul(A, B)\n\nM = 16384 * 2\nN = 16384 * 2\nK = 32 * 2\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 4096\nN = 4096\nK = 64\n\ndef get_inputs():\n A = torch.rand(M, K)\n B = torch.rand(K, N)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_008_matmul_with_irregular_shapes", "source_kb_id": 8, "category": "matmul", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_008_matmul_with_irregular_shapes (KernelBench Level 1 #8, split=train, category=matmul, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_008_matmul_with_irregular_shapes\"\nSOURCE_KB_ID = 8\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B) with irregular shapes\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs matrix multiplication of A and B.\n\n Args:\n A: Input tensor with shape (M, K).\n B: Input tensor with shape (K, N).\n\n Returns:\n C: Output tensor with shape (M, N).\n \"\"\"\n return torch.matmul(A, B)\n\nM = 8205\nK = 2949\nN = 5921\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 2051\nK = 1473\nN = 1973\n\ndef get_inputs():\n A = torch.rand(M, K)\n B = torch.rand(K, N)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_009_tall_skinny_matrix_multiplication", "source_kb_id": 9, "category": "matmul", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_009_tall_skinny_matrix_multiplication (KernelBench Level 1 #9, split=train, category=matmul, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_009_tall_skinny_matrix_multiplication\"\nSOURCE_KB_ID = 9\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B) where one of the matrices is tall and skinny (M >> N or N >> M)\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A, B):\n \"\"\"\n Performs the matrix multiplication.\n\n Args:\n A (torch.Tensor): Input matrix of shape (M, K) or (K, M) where M >> N or N >> M.\n B (torch.Tensor): Input matrix of shape (K, N) or (N, K) where M >> N or N >> M.\n\n Returns:\n torch.Tensor: Output matrix of shape (M, N) or (N, M)\n \"\"\"\n return torch.matmul(A, B)\n\nM = 16384 * 2\nN = 16 * 2\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 8192\nN = 64\n\ndef get_inputs():\n A = torch.rand(M, N)\n B = torch.rand(N, M)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_010_3d_tensor_matrix_multiplication", "source_kb_id": 10, "category": "matmul", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_010_3d_tensor_matrix_multiplication (KernelBench Level 1 #10, split=train, category=matmul, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_010_3d_tensor_matrix_multiplication\"\nSOURCE_KB_ID = 10\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs 3D tensor-matrix multiplication.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A, B):\n \"\"\"\n Performs 3D tensor-matrix multiplication.\n\n Args:\n A (torch.Tensor): Input 3D tensor of shape (N, M, K).\n B (torch.Tensor): Input matrix of shape (K, L).\n\n Returns:\n torch.Tensor: Output tensor of shape (N, M, L), resulting from the multiplication of A and B along the last dimension of A.\n \"\"\"\n return torch.matmul(A, B)\n\nN = 16\nM = 1024\nK = 2048\nL = 768\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nN = 16\nM = 512\nK = 1024\nL = 512\n\ndef get_inputs():\n A = torch.rand(N, M, K)\n B = torch.rand(K, L)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_011_4d_tensor_matrix_multiplication", "source_kb_id": 11, "category": "matmul", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_011_4d_tensor_matrix_multiplication (KernelBench Level 1 #11, split=train, category=matmul, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_011_4d_tensor_matrix_multiplication\"\nSOURCE_KB_ID = 11\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs 4D tensor-matrix multiplication: \n C[b, i, j, k] = sum_l A[b, i, j, l] * B[l, k]\n\n Args:\n A (torch.Tensor): Input 4D tensor of shape (b, i, j, l)\n B (torch.Tensor): Input matrix of shape (l, k)\n\n Returns:\n torch.Tensor: Output 4D tensor of shape (b, i, j, k)\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n\n def forward(self, A, B):\n \"\"\"\n Performs the 4D tensor-matrix multiplication.\n\n Args:\n A (torch.Tensor): Input 4D tensor of shape (b, i, j, l)\n B (torch.Tensor): Input matrix of shape (l, k)\n\n Returns:\n torch.Tensor: Output 4D tensor of shape (b, i, j, k)\n \"\"\"\n return torch.einsum(\"bijl,lk->bijk\", A, B)\n\n# Test code\nb = 8\ni = 256\nj = 512\nl = 256\nk = 768\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nb = 4\ni = 128\nj = 256\nl = 128\nk = 256\n\ndef get_inputs():\n A = torch.rand(b, i, j, l)\n B = torch.rand(l, k)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_012_matmul_with_diagonal_matrices", "source_kb_id": 12, "category": "matmul", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_012_matmul_with_diagonal_matrices (KernelBench Level 1 #12, split=train, category=matmul, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_012_matmul_with_diagonal_matrices\"\nSOURCE_KB_ID = 12\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a matrix multiplication of a diagonal matrix with another matrix.\n C = diag(A) * B\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A, B):\n \"\"\"\n Performs the matrix multiplication.\n\n Args:\n A (torch.Tensor): A 1D tensor representing the diagonal of the diagonal matrix. Shape: (N,).\n B (torch.Tensor): A 2D tensor representing the second matrix. Shape: (N, M).\n\n Returns:\n torch.Tensor: The result of the matrix multiplication. Shape: (N, M).\n \"\"\"\n # Logically equivalent to torch.diag(A) @ B \n # more efficient as no need to materialize a full N\u00d7N matrix\n return A.unsqueeze(1) * B\n\nM = 4096\nN = 4096\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 2048\nN = 2048\n\ndef get_inputs():\n A = torch.rand(N)\n B = torch.rand(N, M)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_013_matmul_for_symmetric_matrices", "source_kb_id": 13, "category": "matmul", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_013_matmul_for_symmetric_matrices (KernelBench Level 1 #13, split=train, category=matmul, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_013_matmul_for_symmetric_matrices\"\nSOURCE_KB_ID = 13\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B) with A and B being symmetric matrices.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A, B):\n \"\"\"\n Performs matrix multiplication of two symmetric matrices.\n\n Args:\n A (torch.Tensor): Input matrix A, shape (N, N), symmetric.\n B (torch.Tensor): Input matrix B, shape (N, N), symmetric.\n\n Returns:\n torch.Tensor: Output matrix C, shape (N, N).\n \"\"\"\n return torch.matmul(A, B)\n\nN = 4096\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nN = 1024\n\ndef get_inputs():\n \"\"\"\n Generates a pair of random symmetric matrices for testing.\n\n Returns:\n list: List containing two symmetric tensors A and B.\n \"\"\"\n A = torch.rand(N, N)\n A = (A + A.T) / 2 # Ensure symmetry\n B = torch.rand(N, N)\n B = (B + B.T) / 2 # Ensure symmetry\n return [A, B]\n\ndef get_init_inputs():\n \"\"\"\n No specific initialization inputs needed for this model.\n\n Returns:\n list: Empty list.\n \"\"\"\n return []\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_014_matmul_for_upper_triangular_matrices", "source_kb_id": 14, "category": "matmul", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_014_matmul_for_upper_triangular_matrices (KernelBench Level 1 #14, split=train, category=matmul, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_014_matmul_for_upper_triangular_matrices\"\nSOURCE_KB_ID = 14\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs matrix multiplication (C = A * B) for upper triangular matrices.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A, B):\n \"\"\"\n Performs matrix multiplication for upper triangular matrices.\n\n Args:\n A (torch.Tensor): Upper triangular matrix of shape (N, N).\n B (torch.Tensor): Upper triangular matrix of shape (N, N).\n\n Returns:\n torch.Tensor: The product of A and B, also an upper triangular matrix of shape (N, N).\n \"\"\"\n return torch.triu(torch.matmul(A, B))\n\nN = 4096\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nN = 1024\n\ndef get_inputs():\n \"\"\"\n Generates upper triangular matrices for testing.\n\n Returns:\n list: A list containing two upper triangular matrices of shape (N, N).\n \"\"\"\n A = torch.triu(torch.rand(N, N))\n B = torch.triu(torch.rand(N, N))\n return [A, B]\n\ndef get_init_inputs():\n \"\"\"\n No specific initialization inputs are needed for this model.\n\n Returns:\n list: An empty list.\n \"\"\"\n return []\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_015_matmul_for_lower_triangular_matrices", "source_kb_id": 15, "category": "matmul", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_015_matmul_for_lower_triangular_matrices (KernelBench Level 1 #15, split=train, category=matmul, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_015_matmul_for_lower_triangular_matrices\"\nSOURCE_KB_ID = 15\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a matrix multiplication (C = A * B) where A and B are lower triangular matrices. \n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A, B):\n \"\"\"\n Performs matrix multiplication of lower triangular matrices A and B.\n\n Args:\n A (torch.Tensor): Lower triangular matrix of shape (N, N).\n B (torch.Tensor): Lower triangular matrix of shape (N, N).\n\n Returns:\n torch.Tensor: The result of matrix multiplication C of shape (N, N).\n \"\"\"\n return torch.tril(torch.matmul(A, B))\n\nM = 4096\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 1024\n\ndef get_inputs():\n A = torch.rand(M, M)\n B = torch.rand(M, M)\n A = torch.tril(A)\n B = torch.tril(B)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_016_matmul_with_transposed_a", "source_kb_id": 16, "category": "matmul", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_016_matmul_with_transposed_a (KernelBench Level 1 #16, split=train, category=matmul, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_016_matmul_with_transposed_a\"\nSOURCE_KB_ID = 16\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B)\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs matrix multiplication.\n\n Args:\n A: Input tensor of shape (M, K).\n B: Input tensor of shape (K, N).\n\n Returns:\n Output tensor of shape (M, N).\n \"\"\"\n return torch.matmul(A.T, B)\n\nM = 1024 * 2\nK = 4096 * 2\nN = 2048 * 2\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 1024\nK = 2048\nN = 1024\n\ndef get_inputs():\n A = torch.rand(K, M)\n B = torch.rand(K, N)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_018_matmul_with_transposed_both", "source_kb_id": 18, "category": "matmul", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_018_matmul_with_transposed_both (KernelBench Level 1 #18, split=train, category=matmul, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_018_matmul_with_transposed_both\"\nSOURCE_KB_ID = 18\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B)\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs matrix multiplication.\n\n Args:\n A: Input tensor of shape (M, K).\n B: Input tensor of shape (K, N).\n\n Returns:\n Output tensor of shape (M, N).\n \"\"\"\n return torch.matmul(A.T, B.T)\n\nM = 1024 * 2\nK = 4096 * 2\nN = 2048 * 2\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 1024\nK = 2048\nN = 1024\n\ndef get_inputs():\n A = torch.rand(K, M)\n B = torch.rand(N, K)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_020_leakyrelu", "source_kb_id": 20, "category": "activation", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_020_leakyrelu (KernelBench Level 1 #20, split=train, category=activation, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_020_leakyrelu\"\nSOURCE_KB_ID = 20\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a LeakyReLU activation.\n \"\"\"\n def __init__(self, negative_slope: float = 0.01):\n \"\"\"\n Initializes the LeakyReLU module.\n\n Args:\n negative_slope (float, optional): The negative slope of the activation function. Defaults to 0.01.\n \"\"\"\n super(Model, self).__init__()\n self.negative_slope = negative_slope\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies LeakyReLU activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with LeakyReLU applied, same shape as input.\n \"\"\"\n return torch.nn.functional.leaky_relu(x, negative_slope=self.negative_slope)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_021_sigmoid", "source_kb_id": 21, "category": "activation", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_021_sigmoid (KernelBench Level 1 #21, split=train, category=activation, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_021_sigmoid\"\nSOURCE_KB_ID = 21\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a Sigmoid activation.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Sigmoid activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with Sigmoid applied, same shape as input.\n \"\"\"\n return torch.sigmoid(x)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_022_tanh", "source_kb_id": 22, "category": "activation", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_022_tanh (KernelBench Level 1 #22, split=train, category=activation, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_022_tanh\"\nSOURCE_KB_ID = 22\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a Tanh activation.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Tanh activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with Tanh applied, same shape as input.\n \"\"\"\n return torch.tanh(x)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_024_logsoftmax", "source_kb_id": 24, "category": "activation", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_024_logsoftmax (KernelBench Level 1 #24, split=train, category=activation, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_024_logsoftmax\"\nSOURCE_KB_ID = 24\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a LogSoftmax activation.\n \"\"\"\n def __init__(self, dim: int = 1):\n super(Model, self).__init__()\n self.dim = dim\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies LogSoftmax activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, dim).\n\n Returns:\n torch.Tensor: Output tensor with LogSoftmax applied, same shape as input.\n \"\"\"\n return torch.log_softmax(x, dim=self.dim)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_027_selu", "source_kb_id": 27, "category": "activation", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_027_selu (KernelBench Level 1 #27, split=train, category=activation, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_027_selu\"\nSOURCE_KB_ID = 27\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a SELU activation.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies SELU activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with SELU applied, same shape as input.\n \"\"\"\n return torch.selu(x)\n \nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_028_hardsigmoid", "source_kb_id": 28, "category": "activation", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_028_hardsigmoid (KernelBench Level 1 #28, split=train, category=activation, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_028_hardsigmoid\"\nSOURCE_KB_ID = 28\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a HardSigmoid activation.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies HardSigmoid activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with HardSigmoid applied, same shape as input.\n \"\"\"\n return torch.nn.functional.hardsigmoid(x)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_029_softplus", "source_kb_id": 29, "category": "activation", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_029_softplus (KernelBench Level 1 #29, split=train, category=activation, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_029_softplus\"\nSOURCE_KB_ID = 29\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a Softplus activation.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Softplus activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with Softplus applied, same shape as input.\n \"\"\"\n return torch.nn.functional.softplus(x)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_030_softsign", "source_kb_id": 30, "category": "activation", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_030_softsign (KernelBench Level 1 #30, split=train, category=activation, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_030_softsign\"\nSOURCE_KB_ID = 30\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a Softsign activation.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Softsign activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with Softsign applied, same shape as input.\n \"\"\"\n return x / (1 + torch.abs(x))\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_031_elu", "source_kb_id": 31, "category": "activation", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_031_elu (KernelBench Level 1 #31, split=train, category=activation, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_031_elu\"\nSOURCE_KB_ID = 31\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\nimport torch.nn.functional as F\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs an ELU activation.\n \"\"\"\n def __init__(self, alpha: float = 1.0):\n \"\"\"\n Initializes the ELU model.\n\n Args:\n alpha (float, optional): The alpha parameter for the ELU function. Defaults to 1.0.\n \"\"\"\n super(Model, self).__init__()\n self.alpha = alpha\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies ELU activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with ELU applied, same shape as input.\n \"\"\"\n return F.elu(x, alpha=self.alpha)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [1.0] # Provide alpha value for initialization\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_032_hardtanh", "source_kb_id": 32, "category": "activation", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_032_hardtanh (KernelBench Level 1 #32, split=train, category=activation, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_032_hardtanh\"\nSOURCE_KB_ID = 32\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\nimport torch.nn.functional as F\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a HardTanh activation.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies HardTanh activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with HardTanh applied, same shape as input.\n \"\"\"\n return F.hardtanh(x, min_val=-1., max_val=1.)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_033_batchnorm", "source_kb_id": 33, "category": "normalization", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_033_batchnorm (KernelBench Level 1 #33, split=train, category=normalization, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_033_batchnorm\"\nSOURCE_KB_ID = 33\nCATEGORY = \"normalization\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs Batch Normalization.\n \"\"\"\n def __init__(self, num_features: int):\n \"\"\"\n Initializes the BatchNorm layer.\n\n Args:\n num_features (int): Number of features in the input tensor.\n \"\"\"\n super(Model, self).__init__()\n self.bn = nn.BatchNorm2d(num_features=num_features)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Batch Normalization to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, num_features, *).\n\n Returns:\n torch.Tensor: Output tensor with Batch Normalization applied, same shape as input.\n \"\"\"\n return self.bn(x)\n\nbatch_size = 64\nfeatures = 64\ndim1 = 512\ndim2 = 512\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 16\nfeatures = 64\ndim1 = 128\ndim2 = 128\n\ndef get_inputs():\n x = torch.randn(batch_size, features, dim1, dim2)\n return [x]\n\ndef get_init_inputs():\n return [features]\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_034_instancenorm", "source_kb_id": 34, "category": "normalization", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_034_instancenorm (KernelBench Level 1 #34, split=train, category=normalization, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_034_instancenorm\"\nSOURCE_KB_ID = 34\nCATEGORY = \"normalization\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs Instance Normalization.\n \"\"\"\n def __init__(self, num_features: int):\n \"\"\"\n Initializes the InstanceNorm layer.\n\n Args:\n num_features (int): Number of features in the input tensor.\n \"\"\"\n super(Model, self).__init__()\n self.inorm = nn.InstanceNorm2d(num_features=num_features)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Instance Normalization to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, num_features, height, width).\n\n Returns:\n torch.Tensor: Output tensor with Instance Normalization applied, same shape as input.\n \"\"\"\n return self.inorm(x)\n\nbatch_size = 112 # heavier workload\nfeatures = 64\ndim1 = 512\ndim2 = 512\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 16\nfeatures = 64\ndim1 = 128\ndim2 = 128\n\ndef get_inputs():\n x = torch.randn(batch_size, features, dim1, dim2)\n return [x]\n\ndef get_init_inputs():\n return [features]\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_035_groupnorm", "source_kb_id": 35, "category": "normalization", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_035_groupnorm (KernelBench Level 1 #35, split=train, category=normalization, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_035_groupnorm\"\nSOURCE_KB_ID = 35\nCATEGORY = \"normalization\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs Group Normalization.\n \"\"\"\n def __init__(self, num_features: int, num_groups: int):\n \"\"\"\n Initializes the GroupNorm layer.\n\n Args:\n num_features (int): Number of features in the input tensor.\n num_groups (int): Number of groups to divide the channels into.\n \"\"\"\n super(Model, self).__init__()\n self.gn = nn.GroupNorm(num_groups=num_groups, num_channels=num_features)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Group Normalization to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, num_features, *).\n\n Returns:\n torch.Tensor: Output tensor with Group Normalization applied, same shape as input.\n \"\"\"\n return self.gn(x)\n\nbatch_size = 112 # scaled up\nfeatures = 64\nnum_groups = 8\ndim1 = 512\ndim2 = 512\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 16\nfeatures = 64\nnum_groups = 8\ndim1 = 128\ndim2 = 128\n\ndef get_inputs():\n x = torch.randn(batch_size, features, dim1, dim2)\n return [x]\n\ndef get_init_inputs():\n return [features, num_groups] # num_features\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_037_frobeniusnorm", "source_kb_id": 37, "category": "normalization", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_037_frobeniusnorm (KernelBench Level 1 #37, split=train, category=normalization, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_037_frobeniusnorm\"\nSOURCE_KB_ID = 37\nCATEGORY = \"normalization\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs Frobenius norm normalization.\n \"\"\"\n def __init__(self):\n \"\"\"\n Initializes the Frobenius norm normalization layer.\n \"\"\"\n super(Model, self).__init__()\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Frobenius norm normalization to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of arbitrary shape.\n\n Returns:\n torch.Tensor: Output tensor with Frobenius norm normalization applied, same shape as input.\n \"\"\"\n norm = torch.norm(x, p='fro')\n return x / norm\n\nbatch_size = 112\nfeatures = 64\ndim1 = 512\ndim2 = 512\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 16\nfeatures = 64\ndim1 = 128\ndim2 = 128\n\ndef get_inputs():\n x = torch.randn(batch_size, features, dim1, dim2)\n return [x]\n\ndef get_init_inputs():\n return []\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_038_l1norm", "source_kb_id": 38, "category": "normalization", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_038_l1norm (KernelBench Level 1 #38, split=train, category=normalization, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_038_l1norm\"\nSOURCE_KB_ID = 38\nCATEGORY = \"normalization\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs L1 normalization.\n \"\"\"\n def __init__(self):\n \"\"\"\n Initializes the L1 normalization layer.\n \"\"\"\n super(Model, self).__init__()\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies L1 normalization to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (..., dim, ...).\n\n Returns:\n torch.Tensor: Output tensor with L1 normalization applied, same shape as input.\n \"\"\"\n return x / torch.mean(torch.abs(x), dim=1, keepdim=True)\n\nbatch_size = 32768\n# choose dim so total <2^31\ndim = 65535\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return []\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_039_l2norm", "source_kb_id": 39, "category": "normalization", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_039_l2norm (KernelBench Level 1 #39, split=train, category=normalization, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_039_l2norm\"\nSOURCE_KB_ID = 39\nCATEGORY = \"normalization\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs L2 normalization.\n \"\"\"\n def __init__(self):\n \"\"\"\n Initializes the L2Norm layer.\n\n Args:\n dim (int): Dimension along which to normalize.\n \"\"\"\n super(Model, self).__init__()\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies L2 normalization to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (*, dim, *).\n\n Returns:\n torch.Tensor: Output tensor with L2 normalization applied, same shape as input.\n \"\"\"\n return x / torch.norm(x, p=2, dim=1, keepdim=True)\n\nbatch_size = 32768\n# choose dim so total <2^31\ndim = 65535\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return []\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_041_max_pooling_1d", "source_kb_id": 41, "category": "pooling", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_041_max_pooling_1d (KernelBench Level 1 #41, split=train, category=pooling, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_041_max_pooling_1d\"\nSOURCE_KB_ID = 41\nCATEGORY = \"pooling\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs Max Pooling 1D.\n \"\"\"\n def __init__(self, kernel_size: int, stride: int = None, padding: int = 0, dilation: int = 1, return_indices: bool = False):\n \"\"\"\n Initializes the Max Pooling 1D layer.\n\n Args:\n kernel_size (int): Size of the window to take a max over.\n stride (int, optional): Stride of the window. Defaults to None (same as kernel_size).\n padding (int, optional): Implicit zero padding to be added on both sides. Defaults to 0.\n dilation (int, optional): Spacing between kernel elements. Defaults to 1.\n return_indices (bool, optional): Whether to return the indices of the maximum values. Defaults to False.\n \"\"\"\n super(Model, self).__init__()\n self.maxpool = nn.MaxPool1d(kernel_size=kernel_size, stride=stride, padding=padding, dilation=dilation, return_indices=return_indices)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Max Pooling 1D to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, num_features, sequence_length).\n\n Returns:\n torch.Tensor: Output tensor with Max Pooling 1D applied, shape (batch_size, num_features, output_sequence_length).\n \"\"\"\n return self.maxpool(x)\n\nbatch_size = 64\nfeatures = 192\nsequence_length = 65536\n\nkernel_size = 8\nstride = 1\npadding = 4\ndilation = 3 \n\nreturn_indices = False\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 16\nfeatures = 64\nsequence_length = 8192\n\ndef get_inputs():\n x = torch.rand(batch_size, features, sequence_length)\n return [x]\n\ndef get_init_inputs():\n return [kernel_size, stride, padding, dilation, return_indices]\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_043_max_pooling_3d", "source_kb_id": 43, "category": "pooling", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_043_max_pooling_3d (KernelBench Level 1 #43, split=train, category=pooling, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_043_max_pooling_3d\"\nSOURCE_KB_ID = 43\nCATEGORY = \"pooling\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs Max Pooling 3D.\n \"\"\"\n def __init__(self, kernel_size: int, stride: int = None, padding: int = 0, dilation: int = 1, return_indices: bool = False, ceil_mode: bool = False):\n \"\"\"\n Initializes the Max Pooling 3D layer.\n\n Args:\n kernel_size (int): Size of the kernel for the max pooling operation.\n stride (int, optional): Stride of the pooling operation. Defaults to None, which means stride is equal to kernel_size.\n padding (int, optional): Padding applied to the input tensor. Defaults to 0.\n dilation (int, optional): Spacing between kernel elements. Defaults to 1.\n return_indices (bool, optional): Whether to return indices of the maximum values. Defaults to False.\n ceil_mode (bool, optional): When True, the output size is ceil(input_size / stride) instead of floor. Defaults to False.\n \"\"\"\n super(Model, self).__init__()\n self.maxpool = nn.MaxPool3d(kernel_size=kernel_size, stride=stride, padding=padding, dilation=dilation, return_indices=return_indices, ceil_mode=ceil_mode)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Max Pooling 3D to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, channels, dim1, dim2, dim3).\n\n Returns:\n torch.Tensor: Output tensor with Max Pooling 3D applied.\n \"\"\"\n return self.maxpool(x)\n\nbatch_size = 16\nchannels = 32\ndim1 = 128\ndim2 = 128\ndim3 = 128\nkernel_size = 3\nstride = 2\npadding = 1\ndilation = 3\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 4\nchannels = 16\ndim1 = 32\ndim2 = 32\ndim3 = 32\n\ndef get_inputs():\n x = torch.rand(batch_size, channels, dim1, dim2, dim3)\n return [x]\n\ndef get_init_inputs():\n return [kernel_size, stride, padding, dilation]\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_044_average_pooling_1d", "source_kb_id": 44, "category": "pooling", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_044_average_pooling_1d (KernelBench Level 1 #44, split=train, category=pooling, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_044_average_pooling_1d\"\nSOURCE_KB_ID = 44\nCATEGORY = \"pooling\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs 1D Average Pooling.\n \"\"\"\n def __init__(self, kernel_size: int, stride: int = 1, padding: int = 0):\n \"\"\"\n Initializes the 1D Average Pooling layer.\n\n Args:\n kernel_size (int): Size of the pooling window.\n stride (int, optional): Stride of the pooling operation. Defaults to 1.\n padding (int, optional): Padding applied to the input tensor. Defaults to 0.\n \"\"\"\n super(Model, self).__init__()\n self.avg_pool = nn.AvgPool1d(kernel_size=kernel_size, stride=stride, padding=padding)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies 1D Average Pooling to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, input_length).\n\n Returns:\n torch.Tensor: Output tensor with 1D Average Pooling applied, shape (batch_size, in_channels, output_length).\n \"\"\"\n return self.avg_pool(x)\n\nbatch_size = 64\nin_channels = 128\ninput_length = 65536\nkernel_size = 8\nstride = 1\npadding = 4\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 16\nin_channels = 64\ninput_length = 8192\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, input_length)\n return [x]\n\ndef get_init_inputs():\n return [kernel_size, stride, padding]\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_045_average_pooling_2d", "source_kb_id": 45, "category": "pooling", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_045_average_pooling_2d (KernelBench Level 1 #45, split=train, category=pooling, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_045_average_pooling_2d\"\nSOURCE_KB_ID = 45\nCATEGORY = \"pooling\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs 2D Average Pooling.\n \"\"\"\n def __init__(self, kernel_size: int, stride: int = None, padding: int = 0):\n \"\"\"\n Initializes the Average Pooling layer.\n\n Args:\n kernel_size (int): Size of the pooling window.\n stride (int, optional): Stride of the pooling operation. Defaults to None (same as kernel_size).\n padding (int, optional): Padding applied to the input tensor. Defaults to 0.\n \"\"\"\n super(Model, self).__init__()\n self.avg_pool = nn.AvgPool2d(kernel_size=kernel_size, stride=stride, padding=padding)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies 2D Average Pooling to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, channels, height, width).\n\n Returns:\n torch.Tensor: Output tensor with Average Pooling applied.\n \"\"\"\n return self.avg_pool(x)\n\nbatch_size = 16\nchannels = 64\nheight = 2048\nwidth = 2048\nkernel_size = 11\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 16\nchannels = 64\nheight = 256\nwidth = 256\n\ndef get_inputs():\n x = torch.rand(batch_size, channels, height, width)\n return [x]\n\ndef get_init_inputs():\n return [kernel_size]\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_046_average_pooling_3d", "source_kb_id": 46, "category": "pooling", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_046_average_pooling_3d (KernelBench Level 1 #46, split=train, category=pooling, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_046_average_pooling_3d\"\nSOURCE_KB_ID = 46\nCATEGORY = \"pooling\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs 3D Average Pooling.\n \"\"\"\n def __init__(self, kernel_size: int, stride: int = None, padding: int = 0):\n \"\"\"\n Initializes the Average Pooling layer.\n\n Args:\n kernel_size (int): Size of the kernel to apply pooling.\n stride (int, optional): Stride of the pooling operation. Defaults to None, which uses the kernel size.\n padding (int, optional): Padding to apply before pooling. Defaults to 0.\n \"\"\"\n super(Model, self).__init__()\n self.avg_pool = nn.AvgPool3d(kernel_size=kernel_size, stride=stride, padding=padding)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Average Pooling to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, channels, depth, height, width).\n\n Returns:\n torch.Tensor: Output tensor with Average Pooling applied, shape depends on kernel_size, stride and padding.\n \"\"\"\n return self.avg_pool(x)\n\nbatch_size = 16\nchannels = 32\ndepth = 128\nheight = 128\nwidth = 256\nkernel_size = 3\nstride = 2\npadding = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 4\nchannels = 16\ndepth = 32\nheight = 32\nwidth = 64\n\ndef get_inputs():\n x = torch.rand(batch_size, channels, depth, height, width)\n return [x]\n\ndef get_init_inputs():\n return [kernel_size, stride, padding]\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_048_mean_reduction_over_a_dimension", "source_kb_id": 48, "category": "reduction_scan", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_048_mean_reduction_over_a_dimension (KernelBench Level 1 #48, split=train, category=reduction_scan, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_048_mean_reduction_over_a_dimension\"\nSOURCE_KB_ID = 48\nCATEGORY = \"reduction_scan\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs mean reduction over a specific dimension.\n \"\"\"\n def __init__(self, dim: int):\n \"\"\"\n Initializes the model with the dimension to reduce over.\n\n Args:\n dim (int): The dimension to reduce over.\n \"\"\"\n super(Model, self).__init__()\n self.dim = dim\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Reduces the input tensor along the specified dimension by taking the mean.\n\n Args:\n x (torch.Tensor): Input tensor of arbitrary shape.\n\n Returns:\n torch.Tensor: Output tensor with reduced dimension. The shape of the output is the same as the input except for the reduced dimension which is removed.\n \"\"\"\n return torch.mean(x, dim=self.dim)\n\nbatch_size = 128\ndim1 = 4096\ndim2 = 4095\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 32\ndim1 = 512\ndim2 = 511\n\ndef get_inputs():\n x = torch.randn(batch_size, dim1, dim2)\n return [x]\n\ndef get_init_inputs():\n return [1]\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_049_max_reduction_over_a_dimension", "source_kb_id": 49, "category": "reduction_scan", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_049_max_reduction_over_a_dimension (KernelBench Level 1 #49, split=train, category=reduction_scan, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_049_max_reduction_over_a_dimension\"\nSOURCE_KB_ID = 49\nCATEGORY = \"reduction_scan\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs Max reduction over a specific dimension.\n \"\"\"\n def __init__(self, dim: int):\n \"\"\"\n Initializes the model with the dimension to reduce over.\n\n Args:\n dim (int): The dimension to reduce over.\n \"\"\"\n super(Model, self).__init__()\n self.dim = dim\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Max reduction over the specified dimension to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor.\n\n Returns:\n torch.Tensor: Output tensor after Max reduction over the specified dimension.\n \"\"\"\n return torch.max(x, dim=self.dim)[0]\n\nbatch_size = 128\ndim1 = 4096\ndim2 = 4095\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 32\ndim1 = 512\ndim2 = 511\n\ndef get_inputs():\n x = torch.randn(batch_size, dim1, dim2)\n return [x]\n\ndef get_init_inputs():\n return [1] # Example, change to desired dimension\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_050_conv_standard_2d_square_input_square_kernel", "source_kb_id": 50, "category": "convolution", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_050_conv_standard_2d_square_input_square_kernel (KernelBench Level 1 #50, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_050_conv_standard_2d_square_input_square_kernel\"\nSOURCE_KB_ID = 50\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\nimport torch.nn.functional as F\n\nclass Model(nn.Module):\n def __init__(self, num_classes=1000):\n super(Model, self).__init__()\n self.conv1 = nn.Conv2d(in_channels=3, out_channels=96, kernel_size=11, stride=4, padding=2)\n \n def forward(self, x):\n x = self.conv1(x)\n return x\n\n# Test code\nbatch_size = 256\nnum_classes = 1000\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 32\n\ndef get_inputs():\n return [torch.rand(batch_size, 3, 224, 224)]\n\ndef get_init_inputs():\n return [num_classes]\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_052_argmin_over_a_dimension", "source_kb_id": 52, "category": "reduction_scan", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_052_argmin_over_a_dimension (KernelBench Level 1 #52, split=train, category=reduction_scan, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_052_argmin_over_a_dimension\"\nSOURCE_KB_ID = 52\nCATEGORY = \"reduction_scan\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that finds the index of the minimum value along a specified dimension.\n \"\"\"\n def __init__(self, dim: int):\n \"\"\"\n Initializes the model with the dimension to perform argmin on.\n\n Args:\n dim (int): Dimension along which to find the minimum value.\n \"\"\"\n super(Model, self).__init__()\n self.dim = dim\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Finds the index of the minimum value along the specified dimension.\n\n Args:\n x (torch.Tensor): Input tensor.\n\n Returns:\n torch.Tensor: Tensor containing the indices of the minimum values along the specified dimension.\n \"\"\"\n return torch.argmin(x, dim=self.dim)\n\nbatch_size = 128\ndim1 = 4096\ndim2 = 4095\ndim = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 32\ndim1 = 512\ndim2 = 511\n\ndef get_inputs():\n x = torch.randn(batch_size, dim1, dim2)\n return [x]\n\ndef get_init_inputs():\n return [dim]\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_053_min_reduction_over_a_dimension", "source_kb_id": 53, "category": "reduction_scan", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_053_min_reduction_over_a_dimension (KernelBench Level 1 #53, split=train, category=reduction_scan, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_053_min_reduction_over_a_dimension\"\nSOURCE_KB_ID = 53\nCATEGORY = \"reduction_scan\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs min reduction over a specific dimension.\n \"\"\"\n def __init__(self, dim: int):\n \"\"\"\n Initializes the model with the dimension to reduce over.\n\n Args:\n dim (int): The dimension to reduce over.\n \"\"\"\n super(Model, self).__init__()\n self.dim = dim\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies min reduction over the specified dimension to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor.\n\n Returns:\n torch.Tensor: Output tensor after min reduction over the specified dimension.\n \"\"\"\n return torch.min(x, dim=self.dim)[0]\n\nbatch_size = 128\ndim1 = 4096\ndim2 = 4095\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 32\ndim1 = 512\ndim2 = 511\n\ndef get_inputs():\n x = torch.randn(batch_size, dim1, dim2)\n return [x]\n\ndef get_init_inputs():\n return [1] # Example, change to desired dimension\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_054_conv_standard_3d_square_input_square_kernel", "source_kb_id": 54, "category": "convolution", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_054_conv_standard_3d_square_input_square_kernel (KernelBench Level 1 #54, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_054_conv_standard_3d_square_input_square_kernel\"\nSOURCE_KB_ID = 54\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a standard 3D convolution operation with square input and square kernel.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (int): Size of the square convolution kernel.\n stride (int, optional): Stride of the convolution. Defaults to 1.\n padding (int, optional): Padding applied to the input. Defaults to 0.\n dilation (int, optional): Spacing between kernel elements. Defaults to 1.\n groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, dilation: int = 1, groups: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv3d = nn.Conv3d(in_channels, out_channels, (kernel_size, kernel_size, kernel_size), stride=stride, padding=padding, dilation=dilation, groups=groups, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the 3D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, depth, width, height).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, depth_out, width_out, height_out).\n \"\"\"\n return self.conv3d(x)\n\n# Test code\nbatch_size = 16\nin_channels = 3\nout_channels = 64\nkernel_size = 3\ndepth = 64\nwidth = 64\nheight = 64\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 4\ndepth = 32\nwidth = 32\nheight = 32\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, depth, width, height)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size] # Provide in_channels, out_channels, kernel_size for initialization\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_055_conv_standard_2d_asymmetric_input_square_kernel", "source_kb_id": 55, "category": "convolution", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_055_conv_standard_2d_asymmetric_input_square_kernel (KernelBench Level 1 #55, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_055_conv_standard_2d_asymmetric_input_square_kernel\"\nSOURCE_KB_ID = 55\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a standard 2D convolution operation with an asymmetric input and a square kernel.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (int): Size of the square convolution kernel.\n stride (int, optional): Stride of the convolution. Defaults to 1.\n padding (int, optional): Padding applied to the input. Defaults to 0.\n dilation (int, optional): Spacing between kernel elements. Defaults to 1.\n groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, dilation: int = 1, groups: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv2d = nn.Conv2d(in_channels, out_channels, (kernel_size, kernel_size), stride=stride, padding=padding, dilation=dilation, groups=groups, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the 2D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height, width).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, height_out, width_out).\n \"\"\"\n return self.conv2d(x)\n\n# Test code\nbatch_size = 8\n# smaller spatial dims\nheight = 512\nwidth = 1024\nin_channels = 64 # increased channels\nout_channels = 128\nkernel_size = 3\n# asymmetric input: make width considerably larger than height\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 4\nheight = 128\nwidth = 256\nin_channels = 32\nout_channels = 64\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, height, width)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size] # Provide in_channels, out_channels, kernel_size for initialization\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_056_conv_standard_2d_asymmetric_input_asymmetric_kernel", "source_kb_id": 56, "category": "convolution", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_056_conv_standard_2d_asymmetric_input_asymmetric_kernel (KernelBench Level 1 #56, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_056_conv_standard_2d_asymmetric_input_asymmetric_kernel\"\nSOURCE_KB_ID = 56\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a standard 2D convolution operation with asymmetric input and kernel sizes.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (tuple): Tuple of two integers representing the height and width of the convolution kernel.\n stride (tuple, optional): Tuple of two integers representing the stride in the height and width dimensions. Defaults to (1, 1).\n padding (tuple, optional): Tuple of two integers representing the padding in the height and width dimensions. Defaults to (0, 0).\n dilation (tuple, optional): Tuple of two integers representing the dilation in the height and width dimensions. Defaults to (1, 1).\n groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: tuple, stride: tuple = (1, 1), padding: tuple = (0, 0), dilation: tuple = (1, 1), groups: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv2d = nn.Conv2d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, dilation=dilation, groups=groups, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the 2D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height, width).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, height_out, width_out).\n \"\"\"\n return self.conv2d(x)\n\n# Test code\nbatch_size = 8\nin_channels = 64\nout_channels = 128\nkernel_size = (5, 7)\nheight = 512\nwidth = 256\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 4\nin_channels = 32\nout_channels = 64\nheight = 128\nwidth = 64\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, height, width)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size] # Provide in_channels, out_channels, kernel_size for initialization\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_057_conv_transposed_2d_square_input_square_kernel", "source_kb_id": 57, "category": "convolution", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_057_conv_transposed_2d_square_input_square_kernel (KernelBench Level 1 #57, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_057_conv_transposed_2d_square_input_square_kernel\"\nSOURCE_KB_ID = 57\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a transposed 2D convolution with square input and square kernel.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (int): Size of the square convolution kernel.\n stride (int, optional): Stride of the convolution. Defaults to 1.\n padding (int, optional): Padding applied to the input. Defaults to 0.\n output_padding (int, optional): Additional size added to one side of the output shape. Defaults to 0.\n groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, output_padding: int = 0, groups: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv_transpose2d = nn.ConvTranspose2d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, output_padding=output_padding, groups=groups, bias=bias)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the transposed 2D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height, width).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, height_out, width_out).\n \"\"\"\n return self.conv_transpose2d(x)\n\n# Test code\nbatch_size = 8\nin_channels = 64 # double channels for heavier compute\nout_channels = 64\nkernel_size = 3\n# larger square input\nheight = 1024\nwidth = 1024\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 4\nin_channels = 32\nout_channels = 32\nheight = 256\nwidth = 256\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, height, width)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size] # Provide in_channels, out_channels, kernel_size for initialization\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_058_conv_transposed_3d_asymmetric_input_asymmetric_kernel", "source_kb_id": 58, "category": "convolution", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_058_conv_transposed_3d_asymmetric_input_asymmetric_kernel (KernelBench Level 1 #58, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_058_conv_transposed_3d_asymmetric_input_asymmetric_kernel\"\nSOURCE_KB_ID = 58\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a transposed 3D convolution operation with asymmetric input and kernel sizes.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (tuple): Tuple of 3 integers representing the kernel size in the form (depth, height, width).\n stride (tuple, optional): Tuple of 3 integers representing the stride in the form (depth, height, width). Defaults to (1, 1, 1).\n padding (tuple, optional): Tuple of 3 integers representing the padding in the form (depth, height, width). Defaults to (0, 0, 0).\n output_padding (tuple, optional): Tuple of 3 integers representing the output padding in the form (depth, height, width). Defaults to (0, 0, 0).\n groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: tuple, stride: tuple = (1, 1, 1), padding: tuple = (0, 0, 0), output_padding: tuple = (0, 0, 0), groups: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv_transpose3d = nn.ConvTranspose3d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, output_padding=output_padding, groups=groups, bias=bias)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the transposed 3D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, depth_in, height_in, width_in).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, depth_out, height_out, width_out).\n \"\"\"\n return self.conv_transpose3d(x)\n\n# Test code\nbatch_size = 16\nin_channels = 32\nout_channels = 16\nkernel_size = (3, 5, 7) # Asymmetric kernel size\ndepth_in = 16\nheight_in = 32\nwidth_in = 64\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 4\nin_channels = 16\nout_channels = 16\ndepth_in = 8\nheight_in = 16\nwidth_in = 32\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, depth_in, height_in, width_in)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size] # Provide in_channels, out_channels, kernel_size for initialization\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_059_conv_standard_3d_asymmetric_input_square_kernel", "source_kb_id": 59, "category": "convolution", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_059_conv_standard_3d_asymmetric_input_square_kernel (KernelBench Level 1 #59, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_059_conv_standard_3d_asymmetric_input_square_kernel\"\nSOURCE_KB_ID = 59\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a standard 3D convolution operation with an asymmetric input and a square kernel.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (int): Size of the square convolution kernel (kernel_size x kernel_size).\n stride (int, optional): Stride of the convolution. Defaults to 1.\n padding (int, optional): Padding applied to the input. Defaults to 0.\n dilation (int, optional): Spacing between kernel elements. Defaults to 1.\n groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, dilation: int = 1, groups: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv3d = nn.Conv3d(in_channels, out_channels, (kernel_size, kernel_size, 1), stride=stride, padding=padding, dilation=dilation, groups=groups, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the 3D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height, width, depth).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, height_out, width_out, depth_out).\n \"\"\"\n return self.conv3d(x)\n\n# Test code\nbatch_size = 16\nin_channels = 3\nout_channels = 64\nkernel_size = 3\nwidth = 256\nheight = 256\ndepth = 10\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 4\nwidth = 64\nheight = 64\ndepth = 8\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, height, width, depth)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size] # Provide in_channels, out_channels, kernel_size for initialization\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_060_conv_standard_3d_square_input_asymmetric_kernel", "source_kb_id": 60, "category": "convolution", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_060_conv_standard_3d_square_input_asymmetric_kernel (KernelBench Level 1 #60, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_060_conv_standard_3d_square_input_asymmetric_kernel\"\nSOURCE_KB_ID = 60\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a standard 3D convolution operation with a square input and an asymmetric kernel.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (tuple): Size of the convolution kernel (kernel_width, kernel_height, kernel_depth).\n stride (int, optional): Stride of the convolution. Defaults to 1.\n padding (int or tuple, optional): Padding applied to the input. Defaults to 0.\n dilation (int or tuple, optional): Spacing between kernel elements. Defaults to 1.\n groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: tuple, stride: int = 1, padding: int = 0, dilation: int = 1, groups: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv3d = nn.Conv3d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, dilation=dilation, groups=groups, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the 3D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, width, height, depth).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, width_out, height_out, depth_out).\n \"\"\"\n return self.conv3d(x)\n\n# Test code\nbatch_size = 16\nin_channels = 3\nout_channels = 64\nkernel_size = (3, 5, 7) # Asymmetric kernel\nwidth = 64\nheight = 64\ndepth = 64\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 4\nwidth = 32\nheight = 32\ndepth = 32\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, width, height, depth)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size] # Provide in_channels, out_channels, kernel_size for initialization\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_061_conv_transposed_3d_square_input_square_kernel", "source_kb_id": 61, "category": "convolution", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_061_conv_transposed_3d_square_input_square_kernel (KernelBench Level 1 #61, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_061_conv_transposed_3d_square_input_square_kernel\"\nSOURCE_KB_ID = 61\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a transposed 3D convolution with square input and square kernel.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (int): Size of the square convolution kernel.\n stride (int, optional): Stride of the convolution. Defaults to 1.\n padding (int, optional): Padding applied to the input. Defaults to 0.\n output_padding (int, optional): Additional size added to one side of the output shape. Defaults to 0.\n groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, output_padding: int = 0, groups: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv_transpose3d = nn.ConvTranspose3d(in_channels, out_channels, kernel_size=(kernel_size, kernel_size, kernel_size), stride=stride, padding=padding, output_padding=output_padding, groups=groups, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the transposed 3D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, depth, height, width).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, depth_out, height_out, width_out).\n \"\"\"\n return self.conv_transpose3d(x)\n\n# Test code\nbatch_size = 8\nin_channels = 48\nout_channels = 48\nkernel_size = 3\ndepth = 64\nheight = 64\nwidth = 64\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2\nin_channels = 16\nout_channels = 16\ndepth = 16\nheight = 16\nwidth = 16\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, depth, height, width)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size] # Provide in_channels, out_channels, kernel_size for initialization\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_062_conv_standard_2d_square_input_asymmetric_kernel", "source_kb_id": 62, "category": "convolution", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_062_conv_standard_2d_square_input_asymmetric_kernel (KernelBench Level 1 #62, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_062_conv_standard_2d_square_input_asymmetric_kernel\"\nSOURCE_KB_ID = 62\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a standard 2D convolution operation with a square input and an asymmetric kernel.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (tuple): Size of the convolution kernel (height, width).\n stride (int, optional): Stride of the convolution. Defaults to 1.\n padding (int or tuple, optional): Padding applied to the input. Defaults to 0.\n dilation (int or tuple, optional): Spacing between kernel elements. Defaults to 1.\n groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: tuple, stride: int = 1, padding: int = 0, dilation: int = 1, groups: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv2d = nn.Conv2d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, dilation=dilation, groups=groups, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the 2D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height, width).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, height_out, width_out).\n \"\"\"\n return self.conv2d(x)\n\n# Test code\nbatch_size = 8\nin_channels = 32\nout_channels = 64\nkernel_size = (5, 9)\nwidth = 512\nheight = 512\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 4\nin_channels = 32\nout_channels = 64\nwidth = 128\nheight = 128\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, height, width)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size] # Provide in_channels, out_channels, kernel_size for initialization\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_064_conv_transposed_1d", "source_kb_id": 64, "category": "convolution", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_064_conv_transposed_1d (KernelBench Level 1 #64, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_064_conv_transposed_1d\"\nSOURCE_KB_ID = 64\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a transposed 1D convolution operation.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (int): Size of the convolution kernel.\n stride (int, optional): Stride of the convolution. Defaults to 1.\n padding (int, optional): Padding applied to the input. Defaults to 0.\n output_padding (int, optional): Additional size added to one side of the output shape. Defaults to 0.\n groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, output_padding: int = 0, groups: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv1d_transpose = nn.ConvTranspose1d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, output_padding=output_padding, groups=groups, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the transposed 1D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, length).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, length_out).\n \"\"\"\n return self.conv1d_transpose(x)\n\n# Test code\nbatch_size = 64\nin_channels = 128\nout_channels = 128\nkernel_size = 3\n# much larger signal length for heavier workload\nlength = 65536\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 16\nin_channels = 64\nout_channels = 64\nlength = 8192\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, length)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size] # Provide in_channels, out_channels, kernel_size for initialization\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_065_conv_transposed_2d_square_input_asymmetric_kernel", "source_kb_id": 65, "category": "convolution", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_065_conv_transposed_2d_square_input_asymmetric_kernel (KernelBench Level 1 #65, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_065_conv_transposed_2d_square_input_asymmetric_kernel\"\nSOURCE_KB_ID = 65\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a transposed 2D convolution with a square input and an asymmetric kernel.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (tuple): Size of the convolution kernel (height, width).\n stride (int, optional): Stride of the convolution. Defaults to 1.\n padding (int or tuple, optional): Padding applied to the input. Defaults to 0.\n output_padding (int or tuple, optional): Additional size added to one side of the output shape. Defaults to 0.\n groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: tuple, stride: int = 1, padding: int = 0, output_padding: int = 0, groups: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv_transpose2d = nn.ConvTranspose2d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, output_padding=output_padding, groups=groups, bias=bias)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the transposed 2D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height, width).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, height_out, width_out).\n \"\"\"\n return self.conv_transpose2d(x)\n\n# Test code\nbatch_size = 8\nin_channels = 64\nout_channels = 64\nkernel_size = (3, 7) # larger asymmetric kernel\nwidth = 512\nheight = 512\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 4\nin_channels = 32\nout_channels = 32\nwidth = 128\nheight = 128\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, height, width)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size] # Provide in_channels, out_channels, kernel_size for initialization\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_066_conv_standard_3d_asymmetric_input_asymmetric_kernel", "source_kb_id": 66, "category": "convolution", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_066_conv_standard_3d_asymmetric_input_asymmetric_kernel (KernelBench Level 1 #66, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_066_conv_standard_3d_asymmetric_input_asymmetric_kernel\"\nSOURCE_KB_ID = 66\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a standard 3D convolution operation with asymmetric input and kernel sizes.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (tuple): Size of the convolution kernel in the form (kernel_size_d, kernel_size_h, kernel_size_w).\n stride (tuple, optional): Stride of the convolution in the form (stride_d, stride_h, stride_w). Defaults to (1, 1, 1).\n padding (tuple, optional): Padding applied to the input in the form (padding_d, padding_h, padding_w). Defaults to (0, 0, 0).\n dilation (tuple, optional): Spacing between kernel elements in the form (dilation_d, dilation_h, dilation_w). Defaults to (1, 1, 1).\n groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: tuple, stride: tuple = (1, 1, 1), padding: tuple = (0, 0, 0), dilation: tuple = (1, 1, 1), groups: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv3d = nn.Conv3d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, dilation=dilation, groups=groups, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the 3D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, depth, height, width).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, depth_out, height_out, width_out).\n \"\"\"\n return self.conv3d(x)\n\n# Test code\nbatch_size = 8\nin_channels = 3\nout_channels = 64\nkernel_size = (3, 5, 7) # Asymmetric kernel size\ndepth = 16\nheight = 128\nwidth = 128\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 4\ndepth = 8\nheight = 64\nwidth = 64\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, depth, height, width)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size] # Provide in_channels, out_channels, kernel_size for initialization\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_068_conv_transposed_3d_square_input_asymmetric_kernel", "source_kb_id": 68, "category": "convolution", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_068_conv_transposed_3d_square_input_asymmetric_kernel (KernelBench Level 1 #68, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_068_conv_transposed_3d_square_input_asymmetric_kernel\"\nSOURCE_KB_ID = 68\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a transposed 3D convolution with a square input and an asymmetric kernel.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (tuple): Size of the convolution kernel (kernel_depth, kernel_width, kernel_height), \n where kernel_width == kernel_height.\n stride (tuple, optional): Stride of the convolution. Defaults to (1, 1, 1).\n padding (tuple, optional): Padding applied to the input. Defaults to (0, 0, 0).\n output_padding (tuple, optional): Additional size added to one side of the output shape. Defaults to (0, 0, 0).\n groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: tuple, stride: tuple = (1, 1, 1), padding: tuple = (0, 0, 0), output_padding: tuple = (0, 0, 0), groups: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv_transpose3d = nn.ConvTranspose3d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, output_padding=output_padding, groups=groups, bias=bias)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the transposed 3D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, depth, width, height).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, depth_out, width_out, height_out).\n \"\"\"\n return self.conv_transpose3d(x)\n\n# Test code\nbatch_size = 16\nin_channels = 32\nout_channels = 64\nkernel_depth = 3\nkernel_width = 5\nkernel_height = 5\ndepth = 64\nwidth = 64\nheight = 64\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 4\nin_channels = 16\nout_channels = 32\ndepth = 16\nwidth = 16\nheight = 16\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, depth, width, height)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, (kernel_depth, kernel_width, kernel_height)] # Provide in_channels, out_channels, kernel_size for initialization\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_069_conv_transposed_2d_asymmetric_input_asymmetric_kernel", "source_kb_id": 69, "category": "convolution", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_069_conv_transposed_2d_asymmetric_input_asymmetric_kernel (KernelBench Level 1 #69, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_069_conv_transposed_2d_asymmetric_input_asymmetric_kernel\"\nSOURCE_KB_ID = 69\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a transposed 2D convolution operation with asymmetric input and kernel size.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (tuple): Tuple of integers representing the kernel size (height, width).\n stride (tuple, optional): Tuple of integers representing the stride of the convolution. Defaults to (1, 1).\n padding (tuple, optional): Tuple of integers representing the padding applied to the input. Defaults to (0, 0).\n output_padding (tuple, optional): Tuple of integers representing the additional size added to one side of the output shape. Defaults to (0, 0).\n dilation (tuple, optional): Tuple of integers representing the spacing between kernel elements. Defaults to (1, 1).\n groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: tuple, stride: tuple = (1, 1), padding: tuple = (0, 0), output_padding: tuple = (0, 0), dilation: tuple = (1, 1), groups: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv_transpose2d = nn.ConvTranspose2d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, output_padding=output_padding, dilation=dilation, groups=groups, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the transposed 2D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height_in, width_in).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, height_out, width_out).\n \"\"\"\n return self.conv_transpose2d(x)\n\n# Test code\nbatch_size = 64\nin_channels = 64\nout_channels = 128\nkernel_size = (3, 5)\nheight_in = 128\nwidth_in = 256\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 8\nin_channels = 32\nout_channels = 64\nheight_in = 64\nwidth_in = 128\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, height_in, width_in)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size] # Provide in_channels, out_channels, kernel_size for initialization\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_070_conv_transposed_3d_asymmetric_input_square_kernel", "source_kb_id": 70, "category": "convolution", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_070_conv_transposed_3d_asymmetric_input_square_kernel (KernelBench Level 1 #70, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_070_conv_transposed_3d_asymmetric_input_square_kernel\"\nSOURCE_KB_ID = 70\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a transposed 3D convolution operation with asymmetric input and a square kernel.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (int): Size of the square convolution kernel.\n stride (int or tuple, optional): Stride of the convolution. Defaults to 1.\n padding (int or tuple, optional): Padding applied to the input. Defaults to 0.\n output_padding (int or tuple, optional): Additional size added to one side of each dimension in the output shape. \n Defaults to 0.\n dilation (int or tuple, optional): Spacing between kernel elements. Defaults to 1.\n groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, output_padding: int = 0, \n dilation: int = 1, groups: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv_transpose3d = nn.ConvTranspose3d(in_channels, out_channels, (kernel_size, kernel_size, kernel_size), \n stride=stride, padding=padding, output_padding=output_padding, \n dilation=dilation, groups=groups, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the transposed 3D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, depth, height, width).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, depth_out, height_out, width_out).\n \"\"\"\n return self.conv_transpose3d(x)\n\n# Test code\nbatch_size = 8\nin_channels = 48\nout_channels = 24\nkernel_size = 3\ndepth = 96\nheight = 96\nwidth = 96\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2\nin_channels = 16\nout_channels = 16\ndepth = 24\nheight = 24\nwidth = 24\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, depth, height, width)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size] # Provide in_channels, out_channels, kernel_size for initialization\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_071_conv_transposed_2d_asymmetric_input_square_kernel", "source_kb_id": 71, "category": "convolution", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_071_conv_transposed_2d_asymmetric_input_square_kernel (KernelBench Level 1 #71, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_071_conv_transposed_2d_asymmetric_input_square_kernel\"\nSOURCE_KB_ID = 71\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a transposed 2D convolution with asymmetric input and a square kernel.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (int): Size of the square convolution kernel.\n stride (int, optional): Stride of the convolution. Defaults to 1.\n padding (int, optional): Padding applied to the input. Defaults to 0.\n output_padding (int, optional): Additional size added to one side of the output shape. Defaults to 0.\n groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, output_padding: int = 0, groups: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv_transpose2d = nn.ConvTranspose2d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, output_padding=output_padding, groups=groups, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the transposed 2D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height_in, width_in).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, height_out, width_out).\n \"\"\"\n return self.conv_transpose2d(x)\n\n# Test code\nbatch_size = 8\nin_channels = 32\nout_channels = 32\nkernel_size = 3\n# large asymmetric input\nheight_in = 512\nwidth_in = 1024\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 4\nin_channels = 32\nout_channels = 32\nheight_in = 128\nwidth_in = 256\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, height_in, width_in)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size] # Provide in_channels, out_channels, kernel_size for initialization\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_072_conv_transposed_3d_asymmetric_input_asymmetric_kernel_strided_padded_grouped", "source_kb_id": 72, "category": "convolution", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_072_conv_transposed_3d_asymmetric_input_asymmetric_kernel_strided_padded_grouped (KernelBench Level 1 #72, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_072_conv_transposed_3d_asymmetric_input_asymmetric_kernel_strided_padded_grouped\"\nSOURCE_KB_ID = 72\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a 3D transposed convolution operation with asymmetric input and kernel, and optional stride.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (tuple of ints): Size of the convolution kernel in the form (kernel_size_depth, kernel_size_height, kernel_size_width).\n stride (tuple of ints, optional): Stride of the convolution in the form (stride_depth, stride_height, stride_width). Defaults to (1, 1, 1).\n padding (tuple of ints, optional): Padding applied to the input in the form (padding_depth, padding_height, padding_width). Defaults to (0, 0, 0).\n output_padding (tuple of ints, optional): Additional size added to one side of the output shape. Defaults to (0, 0, 0).\n groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: tuple, stride: tuple = (1, 1, 1), padding: tuple = (0, 0, 0), output_padding: tuple = (0, 0, 0), groups: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv_transpose3d = nn.ConvTranspose3d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, output_padding=output_padding, groups=groups, bias=bias)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the 3D transposed convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, depth, height, width).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, depth_out, height_out, width_out).\n \"\"\"\n return self.conv_transpose3d(x)\n\n# Test code\nbatch_size = 8\nin_channels = 32\nout_channels = 32\nkernel_size = (3, 5, 7)\ndepth = 12\nheight = 24\nwidth = 48\nstride = (2, 2, 2)\npadding = (1, 2, 3)\noutput_padding = (1, 1, 1)\ngroups = 4\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2\nin_channels = 16\nout_channels = 16\ndepth = 8\nheight = 12\nwidth = 24\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, depth, height, width)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size, stride, padding, output_padding, groups]\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_073_conv_transposed_3d_asymmetric_input_square_kernel_strided_padded_grouped", "source_kb_id": 73, "category": "convolution", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_073_conv_transposed_3d_asymmetric_input_square_kernel_strided_padded_grouped (KernelBench Level 1 #73, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_073_conv_transposed_3d_asymmetric_input_square_kernel_strided_padded_grouped\"\nSOURCE_KB_ID = 73\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a 3D transposed convolution operation with asymmetric input and square kernel.\n The input is padded before the convolution.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (int): Size of the square convolution kernel.\n stride (int, optional): Stride of the convolution. Defaults to 1.\n padding (int, optional): Padding applied to the input. Defaults to 0.\n groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, output_padding: int = 0, groups: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv_transpose3d = nn.ConvTranspose3d(in_channels, out_channels, kernel_size=(kernel_size, kernel_size, kernel_size), stride=stride, padding=padding, groups=groups, bias=bias)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the 3D transposed convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, depth, height, width).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, depth_out, height_out, width_out).\n \"\"\"\n return self.conv_transpose3d(x)\n\n# Test code\nbatch_size = 4\nin_channels = 32\nout_channels = 32\nkernel_size = 3\ndepth = 32\nheight = 64\nwidth = 128\nstride = 2\npadding = 1\ngroups = 4\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2\nin_channels = 16\nout_channels = 16\ndepth = 12\nheight = 24\nwidth = 32\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, depth, height, width)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size, stride, padding, groups]\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_074_conv_transposed_1d_dilated", "source_kb_id": 74, "category": "convolution", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_074_conv_transposed_1d_dilated (KernelBench Level 1 #74, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_074_conv_transposed_1d_dilated\"\nSOURCE_KB_ID = 74\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a transposed 1D convolution operation with square input and asymmetric kernel, optionally with dilation.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (int): Size of the convolution kernel.\n stride (int, optional): Stride of the convolution. Defaults to 1.\n padding (int, optional): Padding applied to the input. Defaults to 0.\n dilation (int, optional): Spacing between kernel elements. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, dilation: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv1d_transpose = nn.ConvTranspose1d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, dilation=dilation, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the transposed 1D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, length).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, length_out).\n \"\"\"\n return self.conv1d_transpose(x)\n\n# Test code\nbatch_size = 32\nin_channels = 32\nout_channels = 64\nkernel_size = 5\nlength = 131072\nstride = 1\npadding = 0\ndilation = 3\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 16\nin_channels = 32\nout_channels = 64\nlength = 16384\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, length)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size, stride, padding, dilation]\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_075_conv_transposed_2d_asymmetric_input_asymmetric_kernel_strided_grouped_padded_dilated", "source_kb_id": 75, "category": "convolution", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_075_conv_transposed_2d_asymmetric_input_asymmetric_kernel_strided_grouped_padded_dilated (KernelBench Level 1 #75, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_075_conv_transposed_2d_asymmetric_input_asymmetric_kernel_strided_grouped_padded_dilated\"\nSOURCE_KB_ID = 75\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a 2D transposed convolution operation with asymmetric input, asymmetric kernel, \n grouped, padded, and dilated.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (tuple): Size of the convolution kernel (height, width).\n stride (tuple, optional): Stride of the convolution (height, width). Defaults to (1, 1).\n padding (tuple, optional): Padding applied to the input (height, width). Defaults to (0, 0).\n dilation (tuple, optional): Spacing between kernel elements (height, width). Defaults to (1, 1).\n groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: tuple, stride: tuple = (1, 1), padding: tuple = (0, 0), dilation: tuple = (1, 1), groups: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv_transpose2d = nn.ConvTranspose2d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, dilation=dilation, groups=groups, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the 2D transposed convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height, width).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, height_out, width_out).\n \"\"\"\n return self.conv_transpose2d(x)\n\n# Test code\nbatch_size = 16\nin_channels = 32\nout_channels = 64\nkernel_size = (3, 5)\nheight = 128\nwidth = 256\nstride = (2, 3)\npadding = (1, 2)\ndilation = (2, 1)\ngroups = 4\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 4\nin_channels = 32\nout_channels = 64\nheight = 64\nwidth = 64\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, height, width)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size, stride, padding, dilation, groups]\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_076_conv_standard_1d_dilated_strided", "source_kb_id": 76, "category": "convolution", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_076_conv_standard_1d_dilated_strided (KernelBench Level 1 #76, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_076_conv_standard_1d_dilated_strided\"\nSOURCE_KB_ID = 76\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a standard 1D convolution operation with asymmetric input and a square kernel, potentially dilated and strided.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (int): Size of the square convolution kernel.\n stride (int, optional): Stride of the convolution. Defaults to 1.\n dilation (int, optional): Spacing between kernel elements. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, dilation: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv1d = nn.Conv1d(in_channels, out_channels, kernel_size, stride=stride, dilation=dilation, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the 1D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, length).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, length_out).\n \"\"\"\n return self.conv1d(x)\n\n# Test code\nbatch_size = 64\nin_channels = 64\nout_channels = 128\nkernel_size = 3\n# longer signal\nlength = 524280\nstride = 3\ndilation = 4\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 16\nin_channels = 64\nout_channels = 128\nlength = 32768\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, length)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size, stride, dilation]\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_077_conv_transposed_3d_square_input_square_kernel_padded_dilated_strided", "source_kb_id": 77, "category": "convolution", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_077_conv_transposed_3d_square_input_square_kernel_padded_dilated_strided (KernelBench Level 1 #77, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_077_conv_transposed_3d_square_input_square_kernel_padded_dilated_strided\"\nSOURCE_KB_ID = 77\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a 3D transposed convolution operation with square input and square kernel,\n and supports padding, dilation, and stride.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (int): Size of the convolution kernel (square kernel, so only one value needed).\n stride (int, optional): Stride of the convolution. Defaults to 1.\n padding (int, optional): Padding applied to the input. Defaults to 0.\n dilation (int, optional): Spacing between kernel elements. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, dilation: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv_transpose3d = nn.ConvTranspose3d(in_channels, out_channels, kernel_size=(kernel_size, kernel_size, kernel_size), stride=stride, padding=padding, dilation=dilation, bias=bias)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the 3D transposed convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, depth, height, width).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, depth_out, height_out, width_out).\n \"\"\"\n return self.conv_transpose3d(x)\n\n# Test code\nbatch_size = 16\nin_channels = 32\nout_channels = 64\nkernel_size = 3\ndepth = 16\nheight = 32\nwidth = 32\nstride = 2\npadding = 1\ndilation = 2\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2\nin_channels = 16\nout_channels = 32\ndepth = 8\nheight = 16\nwidth = 16\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, depth, height, width)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size, stride, padding, dilation]\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_078_conv_transposed_2d_asymmetric_input_asymmetric_kernel_padded", "source_kb_id": 78, "category": "convolution", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_078_conv_transposed_2d_asymmetric_input_asymmetric_kernel_padded (KernelBench Level 1 #78, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_078_conv_transposed_2d_asymmetric_input_asymmetric_kernel_padded\"\nSOURCE_KB_ID = 78\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a 2D transposed convolution operation with asymmetric input and kernel, with optional padding.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (tuple): Size of the convolution kernel (height, width).\n stride (tuple, optional): Stride of the convolution (height, width). Defaults to (1, 1).\n padding (tuple, optional): Padding applied to the input (height, width). Defaults to (0, 0).\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: tuple, stride: tuple = (1, 1), padding: tuple = (0, 0), bias: bool = False):\n super(Model, self).__init__()\n self.conv_transpose2d = nn.ConvTranspose2d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the 2D transposed convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height, width).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, height_out, width_out).\n \"\"\"\n return self.conv_transpose2d(x)\n\n# Test code\nbatch_size = 8\nin_channels = 32\nout_channels = 32\nkernel_size = (3, 7)\nheight = 512\nwidth = 1024\nstride = (1, 1)\npadding = (1, 3)\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 4\nin_channels = 32\nout_channels = 32\nheight = 128\nwidth = 256\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, height, width)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size, stride, padding]\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_079_conv_transposed_1d_asymmetric_input_square_kernel_padded_strided_dilated", "source_kb_id": 79, "category": "convolution", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_079_conv_transposed_1d_asymmetric_input_square_kernel_padded_strided_dilated (KernelBench Level 1 #79, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_079_conv_transposed_1d_asymmetric_input_square_kernel_padded_strided_dilated\"\nSOURCE_KB_ID = 79\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a transposed 1D convolution operation with asymmetric input and square kernel.\n Supports padding, striding, and dilation.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (int): Size of the square convolution kernel.\n stride (int, optional): Stride of the convolution. Defaults to 1.\n padding (int, optional): Padding applied to the input. Defaults to 0.\n dilation (int, optional): Spacing between kernel elements. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, dilation: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv1d_transpose = nn.ConvTranspose1d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, dilation=dilation, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the transposed 1D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, length).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, length_out).\n \"\"\"\n return self.conv1d_transpose(x)\n\n# Test code\nbatch_size = 16\nin_channels = 32\nout_channels = 64\nkernel_size = 3\n# long sequence\nlength = 131072\nstride = 2\npadding = 1\ndilation = 2\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 16\nin_channels = 32\nout_channels = 64\nlength = 16384\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, length)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size, stride, padding, dilation]\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_080_conv_standard_2d_square_input_asymmetric_kernel_dilated_padded", "source_kb_id": 80, "category": "convolution", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_080_conv_standard_2d_square_input_asymmetric_kernel_dilated_padded (KernelBench Level 1 #80, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_080_conv_standard_2d_square_input_asymmetric_kernel_dilated_padded\"\nSOURCE_KB_ID = 80\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a standard 2D convolution operation with square input and asymmetric kernel, with dilation and padding.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (tuple): Size of the convolution kernel (height, width). \n stride (int, optional): Stride of the convolution. Defaults to 1.\n padding (tuple, optional): Padding applied to the input (top/bottom, left/right). Defaults to (0, 0).\n dilation (tuple, optional): Spacing between kernel elements (height, width). Defaults to (1, 1).\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: tuple, stride: int = 1, padding: tuple = (0, 0), dilation: tuple = (1, 1), bias: bool = False):\n super(Model, self).__init__()\n self.conv2d = nn.Conv2d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, dilation=dilation, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the 2D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height, width).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, height_out, width_out).\n \"\"\"\n return self.conv2d(x)\n\n# Test code\nbatch_size = 8\nin_channels = 32\nout_channels = 64\nkernel_size = (5, 9)\nwidth = 512\nheight = 512\nstride = 1\npadding = (2, 4)\ndilation = (2, 3)\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 4\nin_channels = 32\nout_channels = 64\nwidth = 128\nheight = 128\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, height, width)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size, stride, padding, dilation]\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_081_conv_transposed_2d_asymmetric_input_square_kernel_dilated_padded_strided", "source_kb_id": 81, "category": "convolution", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_081_conv_transposed_2d_asymmetric_input_square_kernel_dilated_padded_strided (KernelBench Level 1 #81, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_081_conv_transposed_2d_asymmetric_input_square_kernel_dilated_padded_strided\"\nSOURCE_KB_ID = 81\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a 2D transposed convolution operation with asymmetric input and square kernel, supporting dilation, padding, and stride.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (int): Size of the convolution kernel (square, e.g., 3 for a 3x3 kernel).\n stride (int, optional): Stride of the convolution. Defaults to 1.\n padding (int, optional): Padding applied to the input. Defaults to 0.\n dilation (int, optional): Spacing between kernel elements. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, dilation: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv_transpose2d = nn.ConvTranspose2d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, dilation=dilation, bias=bias)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the 2D transposed convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height_in, width_in). \n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, height_out, width_out).\n \"\"\"\n return self.conv_transpose2d(x)\n\n\n# Test code\nbatch_size = 16\nin_channels = 32\nout_channels = 64\nkernel_size = 3\nheight_in = 64\nwidth_in = 128\nstride = 5\npadding = 1\ndilation = 2\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 4\nin_channels = 32\nout_channels = 64\nheight_in = 32\nwidth_in = 64\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, height_in, width_in)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size, stride, padding, dilation]\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_083_conv_depthwise_2d_square_input_asymmetric_kernel", "source_kb_id": 83, "category": "convolution", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_083_conv_depthwise_2d_square_input_asymmetric_kernel (KernelBench Level 1 #83, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_083_conv_depthwise_2d_square_input_asymmetric_kernel\"\nSOURCE_KB_ID = 83\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a depthwise 2D convolution with a square input and an asymmetric kernel.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n kernel_size (int): Size of the convolution kernel.\n stride (int, optional): Stride of the convolution. Defaults to 1.\n padding (int, optional): Padding applied to the input. Defaults to 0.\n dilation (int, optional): Spacing between kernel elements. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, dilation: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv2d = nn.Conv2d(in_channels, in_channels, kernel_size=(kernel_size, 1), stride=stride, padding=padding, dilation=dilation, groups=in_channels, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the depthwise 2D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height, width).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, in_channels, height_out, width_out).\n \"\"\"\n return self.conv2d(x)\n\n# Test code\nbatch_size = 64\nin_channels = 8\nkernel_size = 3\nwidth = 512\nheight = 512\nstride = 1\npadding = 0\ndilation = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 16\nin_channels = 16\nwidth = 256\nheight = 256\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, height, width)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, kernel_size, stride, padding, dilation]\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_084_conv_depthwise_2d_asymmetric_input_square_kernel", "source_kb_id": 84, "category": "convolution", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_084_conv_depthwise_2d_asymmetric_input_square_kernel (KernelBench Level 1 #84, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_084_conv_depthwise_2d_asymmetric_input_square_kernel\"\nSOURCE_KB_ID = 84\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a depthwise 2D convolution with asymmetric input and square kernel.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (int): Size of the square convolution kernel.\n stride (int, optional): Stride of the convolution. Defaults to 1.\n padding (int, optional): Padding applied to the input. Defaults to 0.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, bias: bool = False):\n super(Model, self).__init__()\n self.conv2d = nn.Conv2d(in_channels, out_channels, kernel_size=(kernel_size, kernel_size), stride=stride, padding=padding, groups=in_channels, bias=bias)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the depthwise 2D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height_in, width_in).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, height_out, width_out).\n \"\"\"\n return self.conv2d(x)\n\n# Test code\nbatch_size = 64\nin_channels = 128\nout_channels = 128\nkernel_size = 3\nwidth_in = 512\nheight_in = 256\nstride = 1\npadding = 0\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 8\nin_channels = 64\nout_channels = 64\nwidth_in = 256\nheight_in = 128\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, height_in, width_in)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size, stride, padding]\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_085_conv_depthwise_2d_asymmetric_input_asymmetric_kernel", "source_kb_id": 85, "category": "convolution", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_085_conv_depthwise_2d_asymmetric_input_asymmetric_kernel (KernelBench Level 1 #85, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_085_conv_depthwise_2d_asymmetric_input_asymmetric_kernel\"\nSOURCE_KB_ID = 85\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a depthwise 2D convolution with asymmetric input and asymmetric kernel.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size_h (int): Height of the convolution kernel.\n kernel_size_w (int): Width of the convolution kernel.\n stride_h (int, optional): Stride of the convolution in height dimension. Defaults to 1.\n stride_w (int, optional): Stride of the convolution in width dimension. Defaults to 1.\n padding_h (int, optional): Padding applied to the input in height dimension. Defaults to 0.\n padding_w (int, optional): Padding applied to the input in width dimension. Defaults to 0.\n dilation_h (int, optional): Spacing between kernel elements in height dimension. Defaults to 1.\n dilation_w (int, optional): Spacing between kernel elements in width dimension. Defaults to 1.\n groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size_h: int, kernel_size_w: int, stride_h: int = 1, stride_w: int = 1, padding_h: int = 0, padding_w: int = 0, dilation_h: int = 1, dilation_w: int = 1, groups: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv2d = nn.Conv2d(in_channels, in_channels, (kernel_size_h, kernel_size_w), stride=(stride_h, stride_w), padding=(padding_h, padding_w), dilation=(dilation_h, dilation_w), groups=in_channels, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the depthwise 2D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height, width).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, height_out, width_out).\n \"\"\"\n return self.conv2d(x)\n\n# Test code\nbatch_size = 32\nin_channels = 128\nout_channels = 128\nkernel_size_h = 3\nkernel_size_w = 7\nwidth = 256\nheight = 128\nstride_h = 1\nstride_w = 1\npadding_h = 0\npadding_w = 0\ndilation_h = 1\ndilation_w = 1\ngroups = in_channels\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 8\nin_channels = 64\nout_channels = 64\ngroups = in_channels\nwidth = 128\nheight = 128\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, height, width)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size_h, kernel_size_w, stride_h, stride_w, padding_h, padding_w, dilation_h, dilation_w, groups]\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_086_conv_depthwise_separable_2d", "source_kb_id": 86, "category": "convolution", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_086_conv_depthwise_separable_2d (KernelBench Level 1 #86, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_086_conv_depthwise_separable_2d\"\nSOURCE_KB_ID = 86\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a depthwise-separable 2D convolution operation.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (int): Size of the convolution kernel.\n stride (int, optional): Stride of the convolution. Defaults to 1.\n padding (int, optional): Padding applied to the input. Defaults to 0.\n dilation (int, optional): Spacing between kernel elements. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, dilation: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.depthwise = nn.Conv2d(in_channels, in_channels, kernel_size, stride=stride, padding=padding, dilation=dilation, groups=in_channels, bias=bias)\n self.pointwise = nn.Conv2d(in_channels, out_channels, kernel_size=1, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the depthwise-separable 2D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height, width).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, height_out, width_out).\n \"\"\"\n x = self.depthwise(x)\n x = self.pointwise(x)\n return x\n\n# Test code\nbatch_size = 16\nin_channels = 64\nout_channels = 128\nkernel_size = 3\nwidth = 512\nheight = 512\nstride = 1\npadding = 1\ndilation = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 8\nin_channels = 64\nout_channels = 128\nwidth = 128\nheight = 128\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, height, width)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size, stride, padding, dilation]\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_088_mingptnewgelu", "source_kb_id": 88, "category": "activation", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_088_mingptnewgelu (KernelBench Level 1 #88, split=train, category=activation, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_088_mingptnewgelu\"\nSOURCE_KB_ID = 88\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\nimport torch.nn.functional as F\nimport math\n\n# From https://github.com/karpathy/minGPT/blob/master/mingpt/model.py\n\nclass Model(nn.Module):\n \"\"\"\n Implementation of the GELU activation function currently in Google BERT repo (identical to OpenAI GPT).\n Reference: Gaussian Error Linear Units (GELU) paper: https://arxiv.org/abs/1606.08415\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x):\n return 0.5 * x * (1.0 + torch.tanh(math.sqrt(2.0 / math.pi) * (x + 0.044715 * torch.pow(x, 3.0))))\n\nbatch_size = 8192\ndim = 8192\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n return [torch.randn(batch_size, dim)]\n\ndef get_init_inputs():\n return []\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_090_cumprod", "source_kb_id": 90, "category": "reduction_scan", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_090_cumprod (KernelBench Level 1 #90, split=train, category=reduction_scan, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_090_cumprod\"\nSOURCE_KB_ID = 90\nCATEGORY = \"reduction_scan\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n A model that performs a cumulative product operation along a specified dimension.\n\n Parameters:\n dim (int): The dimension along which to perform the cumulative product operation.\n \"\"\"\n\n def __init__(self, dim):\n \"\"\"\n Initialize the CumulativeProductModel.\n\n Args:\n dim (int): The dimension along which to perform the cumulative product.\n \"\"\"\n super(Model, self).__init__()\n self.dim = dim\n\n def forward(self, x):\n \"\"\"\n Forward pass, computing the cumulative product along the specified dimension.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, *input_shape).\n\n Returns:\n torch.Tensor: Tensor of the same shape as `x` after applying cumulative product along `dim`.\n \"\"\"\n return torch.cumprod(x, dim=self.dim)\n\n# Define input dimensions and parameters\nbatch_size = 32768\ninput_shape = (32768,)\ndim = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ninput_shape = (1024,)\n\ndef get_inputs():\n return [torch.rand(batch_size, *input_shape)]\n\ndef get_init_inputs():\n return [dim]\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_091_cumsum_reverse", "source_kb_id": 91, "category": "reduction_scan", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_091_cumsum_reverse (KernelBench Level 1 #91, split=train, category=reduction_scan, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_091_cumsum_reverse\"\nSOURCE_KB_ID = 91\nCATEGORY = \"reduction_scan\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n A model that performs a reverse cumulative sum operation along a specified dimension.\n\n Parameters:\n dim (int): The dimension along which to perform the reverse cumulative sum.\n \"\"\"\n\n def __init__(self, dim):\n super(Model, self).__init__()\n self.dim = dim\n\n def forward(self, x):\n return torch.cumsum(x.flip(self.dim), dim=self.dim).flip(self.dim)\n\nbatch_size = 32768\ninput_shape = (32768,)\ndim = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ninput_shape = (2048,)\n\ndef get_inputs():\n return [torch.rand(batch_size, *input_shape)]\n\ndef get_init_inputs():\n return [dim]\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_092_cumsum_exclusive", "source_kb_id": 92, "category": "reduction_scan", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_092_cumsum_exclusive (KernelBench Level 1 #92, split=train, category=reduction_scan, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_092_cumsum_exclusive\"\nSOURCE_KB_ID = 92\nCATEGORY = \"reduction_scan\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n A model that performs an exclusive cumulative sum (does not include the current element).\n\n Parameters:\n dim (int): The dimension along which to perform the exclusive cumulative sum.\n \"\"\"\n\n def __init__(self, dim):\n super(Model, self).__init__()\n self.dim = dim\n\n def forward(self, x):\n cumsum = torch.cumsum(x.narrow(dim=self.dim, start=0, length=x.size(self.dim)-1), dim=self.dim)\n return torch.cat((torch.zeros_like(x.select(self.dim, 0).unsqueeze(self.dim)), cumsum), dim=self.dim)\n\nbatch_size = 32768\ninput_shape = (32768,)\ndim = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ninput_shape = (2048,)\n\ndef get_inputs():\n return [torch.rand(batch_size, *input_shape)]\n\ndef get_init_inputs():\n return [dim]\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_093_masked_cumsum", "source_kb_id": 93, "category": "reduction_scan", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_093_masked_cumsum (KernelBench Level 1 #93, split=train, category=reduction_scan, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_093_masked_cumsum\"\nSOURCE_KB_ID = 93\nCATEGORY = \"reduction_scan\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n A model that performs a masked cumulative sum, only summing elements that satisfy a condition.\n\n Parameters:\n dim (int): The dimension along which to perform the masked cumulative sum.\n \"\"\"\n\n def __init__(self, dim):\n super(Model, self).__init__()\n self.dim = dim\n\n def forward(self, x, mask):\n \"\"\"\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, *input_shape).\n mask (torch.Tensor): Boolean mask of the same shape as x.\n\n Returns:\n torch.Tensor: Cumulative sum of elements where mask is True.\n \"\"\"\n return torch.cumsum(x * mask, dim=self.dim)\n\nbatch_size = 32768\ninput_shape = (32768,)\ndim = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ninput_shape = (2048,)\n\ndef get_inputs():\n x = torch.rand(batch_size, *input_shape)\n mask = torch.randint(0, 2, x.shape).bool() # Random boolean mask\n return [x, mask]\n\ndef get_init_inputs():\n return [dim]\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_096_huberloss", "source_kb_id": 96, "category": "loss_attention", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_096_huberloss (KernelBench Level 1 #96, split=train, category=loss_attention, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_096_huberloss\"\nSOURCE_KB_ID = 96\nCATEGORY = \"loss_attention\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n A model that computes Smooth L1 (Huber) Loss for regression tasks.\n\n Parameters:\n None\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n\n def forward(self, predictions, targets):\n return torch.nn.functional.smooth_l1_loss(predictions, targets)\n\nbatch_size = 32768\ninput_shape = (32768,)\ndim = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ninput_shape = (4096,)\n\ndef get_inputs():\n scale = torch.rand(())\n return [torch.rand(batch_size, *input_shape)*scale, torch.rand(batch_size, *input_shape)]\n\ndef get_init_inputs():\n return []\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_098_kldivloss", "source_kb_id": 98, "category": "loss_attention", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_098_kldivloss (KernelBench Level 1 #98, split=train, category=loss_attention, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_098_kldivloss\"\nSOURCE_KB_ID = 98\nCATEGORY = \"loss_attention\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n A model that computes Kullback-Leibler Divergence for comparing two distributions.\n\n Parameters:\n None\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n\n def forward(self, predictions, targets):\n return torch.nn.functional.kl_div(torch.log(predictions), targets, reduction='batchmean')\n\nbatch_size = 8192 * 2\ninput_shape = (8192 * 2,)\ndim = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ninput_shape = (4096,)\n\ndef get_inputs():\n scale = torch.rand(())\n return [(torch.rand(batch_size, *input_shape)*scale).softmax(dim=-1), torch.rand(batch_size, *input_shape).softmax(dim=-1)]\n\ndef get_init_inputs():\n return []\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_099_tripletmarginloss", "source_kb_id": 99, "category": "loss_attention", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_099_tripletmarginloss (KernelBench Level 1 #99, split=train, category=loss_attention, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_099_tripletmarginloss\"\nSOURCE_KB_ID = 99\nCATEGORY = \"loss_attention\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n A model that computes Triplet Margin Loss for metric learning tasks.\n\n Parameters:\n margin (float): The margin between the positive and negative samples.\n \"\"\"\n def __init__(self, margin=1.0):\n super(Model, self).__init__()\n self.loss_fn = torch.nn.TripletMarginLoss(margin=margin)\n\n def forward(self, anchor, positive, negative):\n return self.loss_fn(anchor, positive, negative)\n\nbatch_size = 32768\ninput_shape = (8192,)\ndim = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ninput_shape = (2048,)\n\ndef get_inputs():\n scale = torch.rand(())\n return [torch.rand(batch_size, *input_shape)*scale, torch.rand(batch_size, *input_shape), torch.rand(batch_size, *input_shape)]\n \ndef get_init_inputs():\n return [1.0] # Default margin\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_100_hingeloss", "source_kb_id": 100, "category": "loss_attention", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_100_hingeloss (KernelBench Level 1 #100, split=train, category=loss_attention, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_100_hingeloss\"\nSOURCE_KB_ID = 100\nCATEGORY = \"loss_attention\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n A model that computes Hinge Loss for binary classification tasks.\n\n Parameters:\n None\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n\n def forward(self, predictions, targets):\n return torch.mean(torch.clamp(1 - predictions * targets, min=0))\n\nbatch_size = 32768\ninput_shape = (32768,)\ndim = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ninput_shape = (2048,)\n\ndef get_inputs():\n return [torch.rand(batch_size, *input_shape), torch.randint(0, 2, (batch_size,)).float() * 2 - 1]\n\ndef get_init_inputs():\n return []\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_002_standard_matrix_multiplication__bf16", "source_kb_id": 2, "category": "matmul", "dtype": "bf16", "variant": "bf16", "reference_code": "\"\"\"Task kb1_002_standard_matrix_multiplication__bf16 (KernelBench Level 1 #2, split=train, category=matmul, dtype=bf16, variant=bf16).\"\"\"\nPROBLEM_ID = \"kb1_002_standard_matrix_multiplication__bf16\"\nSOURCE_KB_ID = 2\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"bf16\"\nVARIANT = \"bf16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B)\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs matrix multiplication.\n\n Args:\n A: Input tensor of shape (M, K).\n B: Input tensor of shape (K, N).\n\n Returns:\n Output tensor of shape (M, N).\n \"\"\"\n return torch.matmul(A, B)\n\nM = 1024 * 2\nK = 4096 * 2\nN = 2048 * 2\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 1024\nK = 2048\nN = 1024\n\ndef get_inputs():\n A = torch.rand(M, K)\n B = torch.rand(K, N)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_006_matmul_with_large_k_dimension__bf16", "source_kb_id": 6, "category": "matmul", "dtype": "bf16", "variant": "bf16", "reference_code": "\"\"\"Task kb1_006_matmul_with_large_k_dimension__bf16 (KernelBench Level 1 #6, split=train, category=matmul, dtype=bf16, variant=bf16).\"\"\"\nPROBLEM_ID = \"kb1_006_matmul_with_large_k_dimension__bf16\"\nSOURCE_KB_ID = 6\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"bf16\"\nVARIANT = \"bf16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B) with a large K dimension\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs matrix multiplication of A and B.\n\n Args:\n A: Input tensor of shape (M, K)\n B: Input tensor of shape (K, N)\n\n Returns:\n Output tensor of shape (M, N)\n \"\"\"\n return torch.matmul(A, B)\n\nM = 256\nN = 256\nK = 131072 * 4\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 256\nN = 256\nK = 32768\n\ndef get_inputs():\n A = torch.rand(M, K)\n B = torch.rand(K, N)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_016_matmul_with_transposed_a__bf16", "source_kb_id": 16, "category": "matmul", "dtype": "bf16", "variant": "bf16", "reference_code": "\"\"\"Task kb1_016_matmul_with_transposed_a__bf16 (KernelBench Level 1 #16, split=train, category=matmul, dtype=bf16, variant=bf16).\"\"\"\nPROBLEM_ID = \"kb1_016_matmul_with_transposed_a__bf16\"\nSOURCE_KB_ID = 16\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"bf16\"\nVARIANT = \"bf16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B)\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs matrix multiplication.\n\n Args:\n A: Input tensor of shape (M, K).\n B: Input tensor of shape (K, N).\n\n Returns:\n Output tensor of shape (M, N).\n \"\"\"\n return torch.matmul(A.T, B)\n\nM = 1024 * 2\nK = 4096 * 2\nN = 2048 * 2\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 1024\nK = 2048\nN = 1024\n\ndef get_inputs():\n A = torch.rand(K, M)\n B = torch.rand(K, N)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_018_matmul_with_transposed_both__bf16", "source_kb_id": 18, "category": "matmul", "dtype": "bf16", "variant": "bf16", "reference_code": "\"\"\"Task kb1_018_matmul_with_transposed_both__bf16 (KernelBench Level 1 #18, split=train, category=matmul, dtype=bf16, variant=bf16).\"\"\"\nPROBLEM_ID = \"kb1_018_matmul_with_transposed_both__bf16\"\nSOURCE_KB_ID = 18\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"bf16\"\nVARIANT = \"bf16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B)\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs matrix multiplication.\n\n Args:\n A: Input tensor of shape (M, K).\n B: Input tensor of shape (K, N).\n\n Returns:\n Output tensor of shape (M, N).\n \"\"\"\n return torch.matmul(A.T, B.T)\n\nM = 1024 * 2\nK = 4096 * 2\nN = 2048 * 2\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 1024\nK = 2048\nN = 1024\n\ndef get_inputs():\n A = torch.rand(K, M)\n B = torch.rand(N, K)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_020_leakyrelu__bf16", "source_kb_id": 20, "category": "activation", "dtype": "bf16", "variant": "bf16", "reference_code": "\"\"\"Task kb1_020_leakyrelu__bf16 (KernelBench Level 1 #20, split=train, category=activation, dtype=bf16, variant=bf16).\"\"\"\nPROBLEM_ID = \"kb1_020_leakyrelu__bf16\"\nSOURCE_KB_ID = 20\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"bf16\"\nVARIANT = \"bf16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a LeakyReLU activation.\n \"\"\"\n def __init__(self, negative_slope: float = 0.01):\n \"\"\"\n Initializes the LeakyReLU module.\n\n Args:\n negative_slope (float, optional): The negative slope of the activation function. Defaults to 0.01.\n \"\"\"\n super(Model, self).__init__()\n self.negative_slope = negative_slope\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies LeakyReLU activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with LeakyReLU applied, same shape as input.\n \"\"\"\n return torch.nn.functional.leaky_relu(x, negative_slope=self.negative_slope)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_021_sigmoid__bf16", "source_kb_id": 21, "category": "activation", "dtype": "bf16", "variant": "bf16", "reference_code": "\"\"\"Task kb1_021_sigmoid__bf16 (KernelBench Level 1 #21, split=train, category=activation, dtype=bf16, variant=bf16).\"\"\"\nPROBLEM_ID = \"kb1_021_sigmoid__bf16\"\nSOURCE_KB_ID = 21\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"bf16\"\nVARIANT = \"bf16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a Sigmoid activation.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Sigmoid activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with Sigmoid applied, same shape as input.\n \"\"\"\n return torch.sigmoid(x)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_024_logsoftmax__bf16", "source_kb_id": 24, "category": "activation", "dtype": "bf16", "variant": "bf16", "reference_code": "\"\"\"Task kb1_024_logsoftmax__bf16 (KernelBench Level 1 #24, split=train, category=activation, dtype=bf16, variant=bf16).\"\"\"\nPROBLEM_ID = \"kb1_024_logsoftmax__bf16\"\nSOURCE_KB_ID = 24\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"bf16\"\nVARIANT = \"bf16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a LogSoftmax activation.\n \"\"\"\n def __init__(self, dim: int = 1):\n super(Model, self).__init__()\n self.dim = dim\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies LogSoftmax activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, dim).\n\n Returns:\n torch.Tensor: Output tensor with LogSoftmax applied, same shape as input.\n \"\"\"\n return torch.log_softmax(x, dim=self.dim)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_027_selu__bf16", "source_kb_id": 27, "category": "activation", "dtype": "bf16", "variant": "bf16", "reference_code": "\"\"\"Task kb1_027_selu__bf16 (KernelBench Level 1 #27, split=train, category=activation, dtype=bf16, variant=bf16).\"\"\"\nPROBLEM_ID = \"kb1_027_selu__bf16\"\nSOURCE_KB_ID = 27\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"bf16\"\nVARIANT = \"bf16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a SELU activation.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies SELU activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with SELU applied, same shape as input.\n \"\"\"\n return torch.selu(x)\n \nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_033_batchnorm__bf16", "source_kb_id": 33, "category": "normalization", "dtype": "bf16", "variant": "bf16", "reference_code": "\"\"\"Task kb1_033_batchnorm__bf16 (KernelBench Level 1 #33, split=train, category=normalization, dtype=bf16, variant=bf16).\"\"\"\nPROBLEM_ID = \"kb1_033_batchnorm__bf16\"\nSOURCE_KB_ID = 33\nCATEGORY = \"normalization\"\nSPLIT = \"train\"\nDTYPE = \"bf16\"\nVARIANT = \"bf16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs Batch Normalization.\n \"\"\"\n def __init__(self, num_features: int):\n \"\"\"\n Initializes the BatchNorm layer.\n\n Args:\n num_features (int): Number of features in the input tensor.\n \"\"\"\n super(Model, self).__init__()\n self.bn = nn.BatchNorm2d(num_features=num_features)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Batch Normalization to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, num_features, *).\n\n Returns:\n torch.Tensor: Output tensor with Batch Normalization applied, same shape as input.\n \"\"\"\n return self.bn(x)\n\nbatch_size = 64\nfeatures = 64\ndim1 = 512\ndim2 = 512\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 16\nfeatures = 64\ndim1 = 128\ndim2 = 128\n\ndef get_inputs():\n x = torch.randn(batch_size, features, dim1, dim2)\n return [x]\n\ndef get_init_inputs():\n return [features]\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_035_groupnorm__bf16", "source_kb_id": 35, "category": "normalization", "dtype": "bf16", "variant": "bf16", "reference_code": "\"\"\"Task kb1_035_groupnorm__bf16 (KernelBench Level 1 #35, split=train, category=normalization, dtype=bf16, variant=bf16).\"\"\"\nPROBLEM_ID = \"kb1_035_groupnorm__bf16\"\nSOURCE_KB_ID = 35\nCATEGORY = \"normalization\"\nSPLIT = \"train\"\nDTYPE = \"bf16\"\nVARIANT = \"bf16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs Group Normalization.\n \"\"\"\n def __init__(self, num_features: int, num_groups: int):\n \"\"\"\n Initializes the GroupNorm layer.\n\n Args:\n num_features (int): Number of features in the input tensor.\n num_groups (int): Number of groups to divide the channels into.\n \"\"\"\n super(Model, self).__init__()\n self.gn = nn.GroupNorm(num_groups=num_groups, num_channels=num_features)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Group Normalization to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, num_features, *).\n\n Returns:\n torch.Tensor: Output tensor with Group Normalization applied, same shape as input.\n \"\"\"\n return self.gn(x)\n\nbatch_size = 112 # scaled up\nfeatures = 64\nnum_groups = 8\ndim1 = 512\ndim2 = 512\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 16\nfeatures = 64\nnum_groups = 8\ndim1 = 128\ndim2 = 128\n\ndef get_inputs():\n x = torch.randn(batch_size, features, dim1, dim2)\n return [x]\n\ndef get_init_inputs():\n return [features, num_groups] # num_features\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_039_l2norm__bf16", "source_kb_id": 39, "category": "normalization", "dtype": "bf16", "variant": "bf16", "reference_code": "\"\"\"Task kb1_039_l2norm__bf16 (KernelBench Level 1 #39, split=train, category=normalization, dtype=bf16, variant=bf16).\"\"\"\nPROBLEM_ID = \"kb1_039_l2norm__bf16\"\nSOURCE_KB_ID = 39\nCATEGORY = \"normalization\"\nSPLIT = \"train\"\nDTYPE = \"bf16\"\nVARIANT = \"bf16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs L2 normalization.\n \"\"\"\n def __init__(self):\n \"\"\"\n Initializes the L2Norm layer.\n\n Args:\n dim (int): Dimension along which to normalize.\n \"\"\"\n super(Model, self).__init__()\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies L2 normalization to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (*, dim, *).\n\n Returns:\n torch.Tensor: Output tensor with L2 normalization applied, same shape as input.\n \"\"\"\n return x / torch.norm(x, p=2, dim=1, keepdim=True)\n\nbatch_size = 32768\n# choose dim so total <2^31\ndim = 65535\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return []\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_048_mean_reduction_over_a_dimension__bf16", "source_kb_id": 48, "category": "reduction_scan", "dtype": "bf16", "variant": "bf16", "reference_code": "\"\"\"Task kb1_048_mean_reduction_over_a_dimension__bf16 (KernelBench Level 1 #48, split=train, category=reduction_scan, dtype=bf16, variant=bf16).\"\"\"\nPROBLEM_ID = \"kb1_048_mean_reduction_over_a_dimension__bf16\"\nSOURCE_KB_ID = 48\nCATEGORY = \"reduction_scan\"\nSPLIT = \"train\"\nDTYPE = \"bf16\"\nVARIANT = \"bf16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs mean reduction over a specific dimension.\n \"\"\"\n def __init__(self, dim: int):\n \"\"\"\n Initializes the model with the dimension to reduce over.\n\n Args:\n dim (int): The dimension to reduce over.\n \"\"\"\n super(Model, self).__init__()\n self.dim = dim\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Reduces the input tensor along the specified dimension by taking the mean.\n\n Args:\n x (torch.Tensor): Input tensor of arbitrary shape.\n\n Returns:\n torch.Tensor: Output tensor with reduced dimension. The shape of the output is the same as the input except for the reduced dimension which is removed.\n \"\"\"\n return torch.mean(x, dim=self.dim)\n\nbatch_size = 128\ndim1 = 4096\ndim2 = 4095\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 32\ndim1 = 512\ndim2 = 511\n\ndef get_inputs():\n x = torch.randn(batch_size, dim1, dim2)\n return [x]\n\ndef get_init_inputs():\n return [1]\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_055_conv_standard_2d_asymmetric_input_square_kernel__bf16", "source_kb_id": 55, "category": "convolution", "dtype": "bf16", "variant": "bf16", "reference_code": "\"\"\"Task kb1_055_conv_standard_2d_asymmetric_input_square_kernel__bf16 (KernelBench Level 1 #55, split=train, category=convolution, dtype=bf16, variant=bf16).\"\"\"\nPROBLEM_ID = \"kb1_055_conv_standard_2d_asymmetric_input_square_kernel__bf16\"\nSOURCE_KB_ID = 55\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"bf16\"\nVARIANT = \"bf16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a standard 2D convolution operation with an asymmetric input and a square kernel.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (int): Size of the square convolution kernel.\n stride (int, optional): Stride of the convolution. Defaults to 1.\n padding (int, optional): Padding applied to the input. Defaults to 0.\n dilation (int, optional): Spacing between kernel elements. Defaults to 1.\n groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, dilation: int = 1, groups: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv2d = nn.Conv2d(in_channels, out_channels, (kernel_size, kernel_size), stride=stride, padding=padding, dilation=dilation, groups=groups, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the 2D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height, width).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, height_out, width_out).\n \"\"\"\n return self.conv2d(x)\n\n# Test code\nbatch_size = 8\n# smaller spatial dims\nheight = 512\nwidth = 1024\nin_channels = 64 # increased channels\nout_channels = 128\nkernel_size = 3\n# asymmetric input: make width considerably larger than height\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 4\nheight = 128\nwidth = 256\nin_channels = 32\nout_channels = 64\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, height, width)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size] # Provide in_channels, out_channels, kernel_size for initialization\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_088_mingptnewgelu__bf16", "source_kb_id": 88, "category": "activation", "dtype": "bf16", "variant": "bf16", "reference_code": "\"\"\"Task kb1_088_mingptnewgelu__bf16 (KernelBench Level 1 #88, split=train, category=activation, dtype=bf16, variant=bf16).\"\"\"\nPROBLEM_ID = \"kb1_088_mingptnewgelu__bf16\"\nSOURCE_KB_ID = 88\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"bf16\"\nVARIANT = \"bf16\"\n\nimport torch\nimport torch.nn as nn\nimport torch.nn.functional as F\nimport math\n\n# From https://github.com/karpathy/minGPT/blob/master/mingpt/model.py\n\nclass Model(nn.Module):\n \"\"\"\n Implementation of the GELU activation function currently in Google BERT repo (identical to OpenAI GPT).\n Reference: Gaussian Error Linear Units (GELU) paper: https://arxiv.org/abs/1606.08415\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x):\n return 0.5 * x * (1.0 + torch.tanh(math.sqrt(2.0 / math.pi) * (x + 0.044715 * torch.pow(x, 3.0))))\n\nbatch_size = 8192\ndim = 8192\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n return [torch.randn(batch_size, dim)]\n\ndef get_init_inputs():\n return []\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_096_huberloss__bf16", "source_kb_id": 96, "category": "loss_attention", "dtype": "bf16", "variant": "bf16", "reference_code": "\"\"\"Task kb1_096_huberloss__bf16 (KernelBench Level 1 #96, split=train, category=loss_attention, dtype=bf16, variant=bf16).\"\"\"\nPROBLEM_ID = \"kb1_096_huberloss__bf16\"\nSOURCE_KB_ID = 96\nCATEGORY = \"loss_attention\"\nSPLIT = \"train\"\nDTYPE = \"bf16\"\nVARIANT = \"bf16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n A model that computes Smooth L1 (Huber) Loss for regression tasks.\n\n Parameters:\n None\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n\n def forward(self, predictions, targets):\n return torch.nn.functional.smooth_l1_loss(predictions, targets)\n\nbatch_size = 32768\ninput_shape = (32768,)\ndim = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ninput_shape = (4096,)\n\ndef get_inputs():\n scale = torch.rand(())\n return [torch.rand(batch_size, *input_shape)*scale, torch.rand(batch_size, *input_shape)]\n\ndef get_init_inputs():\n return []\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_002_standard_matrix_multiplication__fp16", "source_kb_id": 2, "category": "matmul", "dtype": "fp16", "variant": "fp16", "reference_code": "\"\"\"Task kb1_002_standard_matrix_multiplication__fp16 (KernelBench Level 1 #2, split=train, category=matmul, dtype=fp16, variant=fp16).\"\"\"\nPROBLEM_ID = \"kb1_002_standard_matrix_multiplication__fp16\"\nSOURCE_KB_ID = 2\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp16\"\nVARIANT = \"fp16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B)\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs matrix multiplication.\n\n Args:\n A: Input tensor of shape (M, K).\n B: Input tensor of shape (K, N).\n\n Returns:\n Output tensor of shape (M, N).\n \"\"\"\n return torch.matmul(A, B)\n\nM = 1024 * 2\nK = 4096 * 2\nN = 2048 * 2\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 1024\nK = 2048\nN = 1024\n\ndef get_inputs():\n A = torch.rand(M, K)\n B = torch.rand(K, N)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_005_matrix_scalar_multiplication__fp16", "source_kb_id": 5, "category": "matmul", "dtype": "fp16", "variant": "fp16", "reference_code": "\"\"\"Task kb1_005_matrix_scalar_multiplication__fp16 (KernelBench Level 1 #5, split=train, category=matmul, dtype=fp16, variant=fp16).\"\"\"\nPROBLEM_ID = \"kb1_005_matrix_scalar_multiplication__fp16\"\nSOURCE_KB_ID = 5\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp16\"\nVARIANT = \"fp16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a matrix-scalar multiplication (C = A * s)\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, s: float) -> torch.Tensor:\n \"\"\"\n Performs matrix-scalar multiplication.\n\n Args:\n A: Input matrix of shape (M, N)\n s: Scalar value\n\n Returns:\n C: Resulting matrix of shape (M, N)\n \"\"\"\n return A * s\n\nM = 16384 * 4\nN = 4096 * 4\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 4096\nN = 4096\n\ndef get_inputs():\n A = torch.rand(M, N)\n s = 3.14\n return [A, s]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_008_matmul_with_irregular_shapes__fp16", "source_kb_id": 8, "category": "matmul", "dtype": "fp16", "variant": "fp16", "reference_code": "\"\"\"Task kb1_008_matmul_with_irregular_shapes__fp16 (KernelBench Level 1 #8, split=train, category=matmul, dtype=fp16, variant=fp16).\"\"\"\nPROBLEM_ID = \"kb1_008_matmul_with_irregular_shapes__fp16\"\nSOURCE_KB_ID = 8\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp16\"\nVARIANT = \"fp16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B) with irregular shapes\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs matrix multiplication of A and B.\n\n Args:\n A: Input tensor with shape (M, K).\n B: Input tensor with shape (K, N).\n\n Returns:\n C: Output tensor with shape (M, N).\n \"\"\"\n return torch.matmul(A, B)\n\nM = 8205\nK = 2949\nN = 5921\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 2051\nK = 1473\nN = 1973\n\ndef get_inputs():\n A = torch.rand(M, K)\n B = torch.rand(K, N)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_010_3d_tensor_matrix_multiplication__fp16", "source_kb_id": 10, "category": "matmul", "dtype": "fp16", "variant": "fp16", "reference_code": "\"\"\"Task kb1_010_3d_tensor_matrix_multiplication__fp16 (KernelBench Level 1 #10, split=train, category=matmul, dtype=fp16, variant=fp16).\"\"\"\nPROBLEM_ID = \"kb1_010_3d_tensor_matrix_multiplication__fp16\"\nSOURCE_KB_ID = 10\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp16\"\nVARIANT = \"fp16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs 3D tensor-matrix multiplication.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A, B):\n \"\"\"\n Performs 3D tensor-matrix multiplication.\n\n Args:\n A (torch.Tensor): Input 3D tensor of shape (N, M, K).\n B (torch.Tensor): Input matrix of shape (K, L).\n\n Returns:\n torch.Tensor: Output tensor of shape (N, M, L), resulting from the multiplication of A and B along the last dimension of A.\n \"\"\"\n return torch.matmul(A, B)\n\nN = 16\nM = 1024\nK = 2048\nL = 768\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nN = 16\nM = 512\nK = 1024\nL = 512\n\ndef get_inputs():\n A = torch.rand(N, M, K)\n B = torch.rand(K, L)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_022_tanh__fp16", "source_kb_id": 22, "category": "activation", "dtype": "fp16", "variant": "fp16", "reference_code": "\"\"\"Task kb1_022_tanh__fp16 (KernelBench Level 1 #22, split=train, category=activation, dtype=fp16, variant=fp16).\"\"\"\nPROBLEM_ID = \"kb1_022_tanh__fp16\"\nSOURCE_KB_ID = 22\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp16\"\nVARIANT = \"fp16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a Tanh activation.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Tanh activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with Tanh applied, same shape as input.\n \"\"\"\n return torch.tanh(x)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_028_hardsigmoid__fp16", "source_kb_id": 28, "category": "activation", "dtype": "fp16", "variant": "fp16", "reference_code": "\"\"\"Task kb1_028_hardsigmoid__fp16 (KernelBench Level 1 #28, split=train, category=activation, dtype=fp16, variant=fp16).\"\"\"\nPROBLEM_ID = \"kb1_028_hardsigmoid__fp16\"\nSOURCE_KB_ID = 28\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp16\"\nVARIANT = \"fp16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a HardSigmoid activation.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies HardSigmoid activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with HardSigmoid applied, same shape as input.\n \"\"\"\n return torch.nn.functional.hardsigmoid(x)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_029_softplus__fp16", "source_kb_id": 29, "category": "activation", "dtype": "fp16", "variant": "fp16", "reference_code": "\"\"\"Task kb1_029_softplus__fp16 (KernelBench Level 1 #29, split=train, category=activation, dtype=fp16, variant=fp16).\"\"\"\nPROBLEM_ID = \"kb1_029_softplus__fp16\"\nSOURCE_KB_ID = 29\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp16\"\nVARIANT = \"fp16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a Softplus activation.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Softplus activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with Softplus applied, same shape as input.\n \"\"\"\n return torch.nn.functional.softplus(x)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_031_elu__fp16", "source_kb_id": 31, "category": "activation", "dtype": "fp16", "variant": "fp16", "reference_code": "\"\"\"Task kb1_031_elu__fp16 (KernelBench Level 1 #31, split=train, category=activation, dtype=fp16, variant=fp16).\"\"\"\nPROBLEM_ID = \"kb1_031_elu__fp16\"\nSOURCE_KB_ID = 31\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp16\"\nVARIANT = \"fp16\"\n\nimport torch\nimport torch.nn as nn\nimport torch.nn.functional as F\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs an ELU activation.\n \"\"\"\n def __init__(self, alpha: float = 1.0):\n \"\"\"\n Initializes the ELU model.\n\n Args:\n alpha (float, optional): The alpha parameter for the ELU function. Defaults to 1.0.\n \"\"\"\n super(Model, self).__init__()\n self.alpha = alpha\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies ELU activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with ELU applied, same shape as input.\n \"\"\"\n return F.elu(x, alpha=self.alpha)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [1.0] # Provide alpha value for initialization\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_034_instancenorm__fp16", "source_kb_id": 34, "category": "normalization", "dtype": "fp16", "variant": "fp16", "reference_code": "\"\"\"Task kb1_034_instancenorm__fp16 (KernelBench Level 1 #34, split=train, category=normalization, dtype=fp16, variant=fp16).\"\"\"\nPROBLEM_ID = \"kb1_034_instancenorm__fp16\"\nSOURCE_KB_ID = 34\nCATEGORY = \"normalization\"\nSPLIT = \"train\"\nDTYPE = \"fp16\"\nVARIANT = \"fp16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs Instance Normalization.\n \"\"\"\n def __init__(self, num_features: int):\n \"\"\"\n Initializes the InstanceNorm layer.\n\n Args:\n num_features (int): Number of features in the input tensor.\n \"\"\"\n super(Model, self).__init__()\n self.inorm = nn.InstanceNorm2d(num_features=num_features)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Instance Normalization to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, num_features, height, width).\n\n Returns:\n torch.Tensor: Output tensor with Instance Normalization applied, same shape as input.\n \"\"\"\n return self.inorm(x)\n\nbatch_size = 112 # heavier workload\nfeatures = 64\ndim1 = 512\ndim2 = 512\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 16\nfeatures = 64\ndim1 = 128\ndim2 = 128\n\ndef get_inputs():\n x = torch.randn(batch_size, features, dim1, dim2)\n return [x]\n\ndef get_init_inputs():\n return [features]\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_038_l1norm__fp16", "source_kb_id": 38, "category": "normalization", "dtype": "fp16", "variant": "fp16", "reference_code": "\"\"\"Task kb1_038_l1norm__fp16 (KernelBench Level 1 #38, split=train, category=normalization, dtype=fp16, variant=fp16).\"\"\"\nPROBLEM_ID = \"kb1_038_l1norm__fp16\"\nSOURCE_KB_ID = 38\nCATEGORY = \"normalization\"\nSPLIT = \"train\"\nDTYPE = \"fp16\"\nVARIANT = \"fp16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs L1 normalization.\n \"\"\"\n def __init__(self):\n \"\"\"\n Initializes the L1 normalization layer.\n \"\"\"\n super(Model, self).__init__()\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies L1 normalization to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (..., dim, ...).\n\n Returns:\n torch.Tensor: Output tensor with L1 normalization applied, same shape as input.\n \"\"\"\n return x / torch.mean(torch.abs(x), dim=1, keepdim=True)\n\nbatch_size = 32768\n# choose dim so total <2^31\ndim = 65535\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return []\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_049_max_reduction_over_a_dimension__fp16", "source_kb_id": 49, "category": "reduction_scan", "dtype": "fp16", "variant": "fp16", "reference_code": "\"\"\"Task kb1_049_max_reduction_over_a_dimension__fp16 (KernelBench Level 1 #49, split=train, category=reduction_scan, dtype=fp16, variant=fp16).\"\"\"\nPROBLEM_ID = \"kb1_049_max_reduction_over_a_dimension__fp16\"\nSOURCE_KB_ID = 49\nCATEGORY = \"reduction_scan\"\nSPLIT = \"train\"\nDTYPE = \"fp16\"\nVARIANT = \"fp16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs Max reduction over a specific dimension.\n \"\"\"\n def __init__(self, dim: int):\n \"\"\"\n Initializes the model with the dimension to reduce over.\n\n Args:\n dim (int): The dimension to reduce over.\n \"\"\"\n super(Model, self).__init__()\n self.dim = dim\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Max reduction over the specified dimension to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor.\n\n Returns:\n torch.Tensor: Output tensor after Max reduction over the specified dimension.\n \"\"\"\n return torch.max(x, dim=self.dim)[0]\n\nbatch_size = 128\ndim1 = 4096\ndim2 = 4095\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 32\ndim1 = 512\ndim2 = 511\n\ndef get_inputs():\n x = torch.randn(batch_size, dim1, dim2)\n return [x]\n\ndef get_init_inputs():\n return [1] # Example, change to desired dimension\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_064_conv_transposed_1d__fp16", "source_kb_id": 64, "category": "convolution", "dtype": "fp16", "variant": "fp16", "reference_code": "\"\"\"Task kb1_064_conv_transposed_1d__fp16 (KernelBench Level 1 #64, split=train, category=convolution, dtype=fp16, variant=fp16).\"\"\"\nPROBLEM_ID = \"kb1_064_conv_transposed_1d__fp16\"\nSOURCE_KB_ID = 64\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp16\"\nVARIANT = \"fp16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a transposed 1D convolution operation.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (int): Size of the convolution kernel.\n stride (int, optional): Stride of the convolution. Defaults to 1.\n padding (int, optional): Padding applied to the input. Defaults to 0.\n output_padding (int, optional): Additional size added to one side of the output shape. Defaults to 0.\n groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, output_padding: int = 0, groups: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv1d_transpose = nn.ConvTranspose1d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, output_padding=output_padding, groups=groups, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the transposed 1D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, length).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, length_out).\n \"\"\"\n return self.conv1d_transpose(x)\n\n# Test code\nbatch_size = 64\nin_channels = 128\nout_channels = 128\nkernel_size = 3\n# much larger signal length for heavier workload\nlength = 65536\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 16\nin_channels = 64\nout_channels = 64\nlength = 8192\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, length)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size] # Provide in_channels, out_channels, kernel_size for initialization\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_086_conv_depthwise_separable_2d__fp16", "source_kb_id": 86, "category": "convolution", "dtype": "fp16", "variant": "fp16", "reference_code": "\"\"\"Task kb1_086_conv_depthwise_separable_2d__fp16 (KernelBench Level 1 #86, split=train, category=convolution, dtype=fp16, variant=fp16).\"\"\"\nPROBLEM_ID = \"kb1_086_conv_depthwise_separable_2d__fp16\"\nSOURCE_KB_ID = 86\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp16\"\nVARIANT = \"fp16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a depthwise-separable 2D convolution operation.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (int): Size of the convolution kernel.\n stride (int, optional): Stride of the convolution. Defaults to 1.\n padding (int, optional): Padding applied to the input. Defaults to 0.\n dilation (int, optional): Spacing between kernel elements. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, dilation: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.depthwise = nn.Conv2d(in_channels, in_channels, kernel_size, stride=stride, padding=padding, dilation=dilation, groups=in_channels, bias=bias)\n self.pointwise = nn.Conv2d(in_channels, out_channels, kernel_size=1, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the depthwise-separable 2D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height, width).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, height_out, width_out).\n \"\"\"\n x = self.depthwise(x)\n x = self.pointwise(x)\n return x\n\n# Test code\nbatch_size = 16\nin_channels = 64\nout_channels = 128\nkernel_size = 3\nwidth = 512\nheight = 512\nstride = 1\npadding = 1\ndilation = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 8\nin_channels = 64\nout_channels = 128\nwidth = 128\nheight = 128\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, height, width)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size, stride, padding, dilation]\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_098_kldivloss__fp16", "source_kb_id": 98, "category": "loss_attention", "dtype": "fp16", "variant": "fp16", "reference_code": "\"\"\"Task kb1_098_kldivloss__fp16 (KernelBench Level 1 #98, split=train, category=loss_attention, dtype=fp16, variant=fp16).\"\"\"\nPROBLEM_ID = \"kb1_098_kldivloss__fp16\"\nSOURCE_KB_ID = 98\nCATEGORY = \"loss_attention\"\nSPLIT = \"train\"\nDTYPE = \"fp16\"\nVARIANT = \"fp16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n A model that computes Kullback-Leibler Divergence for comparing two distributions.\n\n Parameters:\n None\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n\n def forward(self, predictions, targets):\n return torch.nn.functional.kl_div(torch.log(predictions), targets, reduction='batchmean')\n\nbatch_size = 8192 * 2\ninput_shape = (8192 * 2,)\ndim = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ninput_shape = (4096,)\n\ndef get_inputs():\n scale = torch.rand(())\n return [(torch.rand(batch_size, *input_shape)*scale).softmax(dim=-1), torch.rand(batch_size, *input_shape).softmax(dim=-1)]\n\ndef get_init_inputs():\n return []\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_100_hingeloss__fp16", "source_kb_id": 100, "category": "loss_attention", "dtype": "fp16", "variant": "fp16", "reference_code": "\"\"\"Task kb1_100_hingeloss__fp16 (KernelBench Level 1 #100, split=train, category=loss_attention, dtype=fp16, variant=fp16).\"\"\"\nPROBLEM_ID = \"kb1_100_hingeloss__fp16\"\nSOURCE_KB_ID = 100\nCATEGORY = \"loss_attention\"\nSPLIT = \"train\"\nDTYPE = \"fp16\"\nVARIANT = \"fp16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n A model that computes Hinge Loss for binary classification tasks.\n\n Parameters:\n None\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n\n def forward(self, predictions, targets):\n return torch.mean(torch.clamp(1 - predictions * targets, min=0))\n\nbatch_size = 32768\ninput_shape = (32768,)\ndim = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ninput_shape = (2048,)\n\ndef get_inputs():\n return [torch.rand(batch_size, *input_shape), torch.randint(0, 2, (batch_size,)).float() * 2 - 1]\n\ndef get_init_inputs():\n return []\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_002_standard_matrix_multiplication__shape_nonpow2", "source_kb_id": 2, "category": "matmul", "dtype": "fp32", "variant": "shape_nonpow2", "reference_code": "\"\"\"Task kb1_002_standard_matrix_multiplication__shape_nonpow2 (KernelBench Level 1 #2, split=train, category=matmul, dtype=fp32, variant=shape_nonpow2).\"\"\"\nPROBLEM_ID = \"kb1_002_standard_matrix_multiplication__shape_nonpow2\"\nSOURCE_KB_ID = 2\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_nonpow2\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B)\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs matrix multiplication.\n\n Args:\n A: Input tensor of shape (M, K).\n B: Input tensor of shape (K, N).\n\n Returns:\n Output tensor of shape (M, N).\n \"\"\"\n return torch.matmul(A, B)\n\nM = 1024 * 2\nK = 4096 * 2\nN = 2048 * 2\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 1024\nK = 2048\nN = 1024\nM = 768\nK = 1536\nN = 1280\n\ndef get_inputs():\n A = torch.rand(M, K)\n B = torch.rand(K, N)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_004_matrix_vector_multiplication__shape_wide", "source_kb_id": 4, "category": "matmul", "dtype": "fp32", "variant": "shape_wide", "reference_code": "\"\"\"Task kb1_004_matrix_vector_multiplication__shape_wide (KernelBench Level 1 #4, split=train, category=matmul, dtype=fp32, variant=shape_wide).\"\"\"\nPROBLEM_ID = \"kb1_004_matrix_vector_multiplication__shape_wide\"\nSOURCE_KB_ID = 4\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_wide\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs matrix-vector multiplication (C = A * B).\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs matrix-vector multiplication.\n\n Args:\n A: Input matrix of shape (M, K).\n B: Input vector of shape (K, 1).\n\n Returns:\n Output vector of shape (M, 1).\n \"\"\"\n return torch.matmul(A, B)\n\nM = 256 * 8 # 2048\nK = 131072 * 8 # 1048576\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 1024\nK = 16384\nM = 512\nK = 32768\n\ndef get_inputs():\n A = torch.rand(M, K)\n B = torch.rand(K, 1)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_005_matrix_scalar_multiplication__shape_nonpow2", "source_kb_id": 5, "category": "matmul", "dtype": "fp32", "variant": "shape_nonpow2", "reference_code": "\"\"\"Task kb1_005_matrix_scalar_multiplication__shape_nonpow2 (KernelBench Level 1 #5, split=train, category=matmul, dtype=fp32, variant=shape_nonpow2).\"\"\"\nPROBLEM_ID = \"kb1_005_matrix_scalar_multiplication__shape_nonpow2\"\nSOURCE_KB_ID = 5\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_nonpow2\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a matrix-scalar multiplication (C = A * s)\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, s: float) -> torch.Tensor:\n \"\"\"\n Performs matrix-scalar multiplication.\n\n Args:\n A: Input matrix of shape (M, N)\n s: Scalar value\n\n Returns:\n C: Resulting matrix of shape (M, N)\n \"\"\"\n return A * s\n\nM = 16384 * 4\nN = 4096 * 4\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 4096\nN = 4096\nM = 3000\nN = 2500\n\ndef get_inputs():\n A = torch.rand(M, N)\n s = 3.14\n return [A, s]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_006_matmul_with_large_k_dimension__shape_tall", "source_kb_id": 6, "category": "matmul", "dtype": "fp32", "variant": "shape_tall", "reference_code": "\"\"\"Task kb1_006_matmul_with_large_k_dimension__shape_tall (KernelBench Level 1 #6, split=train, category=matmul, dtype=fp32, variant=shape_tall).\"\"\"\nPROBLEM_ID = \"kb1_006_matmul_with_large_k_dimension__shape_tall\"\nSOURCE_KB_ID = 6\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_tall\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B) with a large K dimension\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs matrix multiplication of A and B.\n\n Args:\n A: Input tensor of shape (M, K)\n B: Input tensor of shape (K, N)\n\n Returns:\n Output tensor of shape (M, N)\n \"\"\"\n return torch.matmul(A, B)\n\nM = 256\nN = 256\nK = 131072 * 4\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 256\nN = 256\nK = 32768\nM = 512\nN = 128\nK = 16384\n\ndef get_inputs():\n A = torch.rand(M, K)\n B = torch.rand(K, N)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_007_matmul_with_small_k_dimension__shape_rect", "source_kb_id": 7, "category": "matmul", "dtype": "fp32", "variant": "shape_rect", "reference_code": "\"\"\"Task kb1_007_matmul_with_small_k_dimension__shape_rect (KernelBench Level 1 #7, split=train, category=matmul, dtype=fp32, variant=shape_rect).\"\"\"\nPROBLEM_ID = \"kb1_007_matmul_with_small_k_dimension__shape_rect\"\nSOURCE_KB_ID = 7\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_rect\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B) with a small K dimension\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs matrix multiplication.\n\n Args:\n A: Input tensor of shape (M, K).\n B: Input tensor of shape (K, N).\n\n Returns:\n Output tensor of shape (M, N).\n \"\"\"\n return torch.matmul(A, B)\n\nM = 16384 * 2\nN = 16384 * 2\nK = 32 * 2\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 4096\nN = 4096\nK = 64\nM = 2048\nN = 3072\nK = 48\n\ndef get_inputs():\n A = torch.rand(M, K)\n B = torch.rand(K, N)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_009_tall_skinny_matrix_multiplication__shape_skinny", "source_kb_id": 9, "category": "matmul", "dtype": "fp32", "variant": "shape_skinny", "reference_code": "\"\"\"Task kb1_009_tall_skinny_matrix_multiplication__shape_skinny (KernelBench Level 1 #9, split=train, category=matmul, dtype=fp32, variant=shape_skinny).\"\"\"\nPROBLEM_ID = \"kb1_009_tall_skinny_matrix_multiplication__shape_skinny\"\nSOURCE_KB_ID = 9\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_skinny\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B) where one of the matrices is tall and skinny (M >> N or N >> M)\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A, B):\n \"\"\"\n Performs the matrix multiplication.\n\n Args:\n A (torch.Tensor): Input matrix of shape (M, K) or (K, M) where M >> N or N >> M.\n B (torch.Tensor): Input matrix of shape (K, N) or (N, K) where M >> N or N >> M.\n\n Returns:\n torch.Tensor: Output matrix of shape (M, N) or (N, M)\n \"\"\"\n return torch.matmul(A, B)\n\nM = 16384 * 2\nN = 16 * 2\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 8192\nN = 64\nM = 4096\nN = 32\n\ndef get_inputs():\n A = torch.rand(M, N)\n B = torch.rand(N, M)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_010_3d_tensor_matrix_multiplication__shape_large_batch", "source_kb_id": 10, "category": "matmul", "dtype": "fp32", "variant": "shape_large_batch", "reference_code": "\"\"\"Task kb1_010_3d_tensor_matrix_multiplication__shape_large_batch (KernelBench Level 1 #10, split=train, category=matmul, dtype=fp32, variant=shape_large_batch).\"\"\"\nPROBLEM_ID = \"kb1_010_3d_tensor_matrix_multiplication__shape_large_batch\"\nSOURCE_KB_ID = 10\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_large_batch\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs 3D tensor-matrix multiplication.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A, B):\n \"\"\"\n Performs 3D tensor-matrix multiplication.\n\n Args:\n A (torch.Tensor): Input 3D tensor of shape (N, M, K).\n B (torch.Tensor): Input matrix of shape (K, L).\n\n Returns:\n torch.Tensor: Output tensor of shape (N, M, L), resulting from the multiplication of A and B along the last dimension of A.\n \"\"\"\n return torch.matmul(A, B)\n\nN = 16\nM = 1024\nK = 2048\nL = 768\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nN = 16\nM = 512\nK = 1024\nL = 512\nN = 32\nM = 256\nK = 512\nL = 768\n\ndef get_inputs():\n A = torch.rand(N, M, K)\n B = torch.rand(K, L)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_012_matmul_with_diagonal_matrices__shape_rect", "source_kb_id": 12, "category": "matmul", "dtype": "fp32", "variant": "shape_rect", "reference_code": "\"\"\"Task kb1_012_matmul_with_diagonal_matrices__shape_rect (KernelBench Level 1 #12, split=train, category=matmul, dtype=fp32, variant=shape_rect).\"\"\"\nPROBLEM_ID = \"kb1_012_matmul_with_diagonal_matrices__shape_rect\"\nSOURCE_KB_ID = 12\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_rect\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a matrix multiplication of a diagonal matrix with another matrix.\n C = diag(A) * B\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A, B):\n \"\"\"\n Performs the matrix multiplication.\n\n Args:\n A (torch.Tensor): A 1D tensor representing the diagonal of the diagonal matrix. Shape: (N,).\n B (torch.Tensor): A 2D tensor representing the second matrix. Shape: (N, M).\n\n Returns:\n torch.Tensor: The result of the matrix multiplication. Shape: (N, M).\n \"\"\"\n # Logically equivalent to torch.diag(A) @ B \n # more efficient as no need to materialize a full N\u00d7N matrix\n return A.unsqueeze(1) * B\n\nM = 4096\nN = 4096\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 2048\nN = 2048\nM = 1536\nN = 3072\n\ndef get_inputs():\n A = torch.rand(N)\n B = torch.rand(N, M)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_013_matmul_for_symmetric_matrices__shape_small", "source_kb_id": 13, "category": "matmul", "dtype": "fp32", "variant": "shape_small", "reference_code": "\"\"\"Task kb1_013_matmul_for_symmetric_matrices__shape_small (KernelBench Level 1 #13, split=train, category=matmul, dtype=fp32, variant=shape_small).\"\"\"\nPROBLEM_ID = \"kb1_013_matmul_for_symmetric_matrices__shape_small\"\nSOURCE_KB_ID = 13\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_small\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B) with A and B being symmetric matrices.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A, B):\n \"\"\"\n Performs matrix multiplication of two symmetric matrices.\n\n Args:\n A (torch.Tensor): Input matrix A, shape (N, N), symmetric.\n B (torch.Tensor): Input matrix B, shape (N, N), symmetric.\n\n Returns:\n torch.Tensor: Output matrix C, shape (N, N).\n \"\"\"\n return torch.matmul(A, B)\n\nN = 4096\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nN = 1024\nN = 768\n\ndef get_inputs():\n \"\"\"\n Generates a pair of random symmetric matrices for testing.\n\n Returns:\n list: List containing two symmetric tensors A and B.\n \"\"\"\n A = torch.rand(N, N)\n A = (A + A.T) / 2 # Ensure symmetry\n B = torch.rand(N, N)\n B = (B + B.T) / 2 # Ensure symmetry\n return [A, B]\n\ndef get_init_inputs():\n \"\"\"\n No specific initialization inputs needed for this model.\n\n Returns:\n list: Empty list.\n \"\"\"\n return []\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_016_matmul_with_transposed_a__shape_nonpow2", "source_kb_id": 16, "category": "matmul", "dtype": "fp32", "variant": "shape_nonpow2", "reference_code": "\"\"\"Task kb1_016_matmul_with_transposed_a__shape_nonpow2 (KernelBench Level 1 #16, split=train, category=matmul, dtype=fp32, variant=shape_nonpow2).\"\"\"\nPROBLEM_ID = \"kb1_016_matmul_with_transposed_a__shape_nonpow2\"\nSOURCE_KB_ID = 16\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_nonpow2\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B)\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs matrix multiplication.\n\n Args:\n A: Input tensor of shape (M, K).\n B: Input tensor of shape (K, N).\n\n Returns:\n Output tensor of shape (M, N).\n \"\"\"\n return torch.matmul(A.T, B)\n\nM = 1024 * 2\nK = 4096 * 2\nN = 2048 * 2\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 1024\nK = 2048\nN = 1024\nM = 1536\nK = 1024\nN = 768\n\ndef get_inputs():\n A = torch.rand(K, M)\n B = torch.rand(K, N)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_020_leakyrelu__shape_wide", "source_kb_id": 20, "category": "activation", "dtype": "fp32", "variant": "shape_wide", "reference_code": "\"\"\"Task kb1_020_leakyrelu__shape_wide (KernelBench Level 1 #20, split=train, category=activation, dtype=fp32, variant=shape_wide).\"\"\"\nPROBLEM_ID = \"kb1_020_leakyrelu__shape_wide\"\nSOURCE_KB_ID = 20\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_wide\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a LeakyReLU activation.\n \"\"\"\n def __init__(self, negative_slope: float = 0.01):\n \"\"\"\n Initializes the LeakyReLU module.\n\n Args:\n negative_slope (float, optional): The negative slope of the activation function. Defaults to 0.01.\n \"\"\"\n super(Model, self).__init__()\n self.negative_slope = negative_slope\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies LeakyReLU activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with LeakyReLU applied, same shape as input.\n \"\"\"\n return torch.nn.functional.leaky_relu(x, negative_slope=self.negative_slope)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\nbatch_size = 512\ndim = 12288\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_021_sigmoid__shape_nonpow2", "source_kb_id": 21, "category": "activation", "dtype": "fp32", "variant": "shape_nonpow2", "reference_code": "\"\"\"Task kb1_021_sigmoid__shape_nonpow2 (KernelBench Level 1 #21, split=train, category=activation, dtype=fp32, variant=shape_nonpow2).\"\"\"\nPROBLEM_ID = \"kb1_021_sigmoid__shape_nonpow2\"\nSOURCE_KB_ID = 21\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_nonpow2\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a Sigmoid activation.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Sigmoid activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with Sigmoid applied, same shape as input.\n \"\"\"\n return torch.sigmoid(x)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\nbatch_size = 1500\ndim = 3000\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_022_tanh__shape_tall", "source_kb_id": 22, "category": "activation", "dtype": "fp32", "variant": "shape_tall", "reference_code": "\"\"\"Task kb1_022_tanh__shape_tall (KernelBench Level 1 #22, split=train, category=activation, dtype=fp32, variant=shape_tall).\"\"\"\nPROBLEM_ID = \"kb1_022_tanh__shape_tall\"\nSOURCE_KB_ID = 22\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_tall\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a Tanh activation.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Tanh activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with Tanh applied, same shape as input.\n \"\"\"\n return torch.tanh(x)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\nbatch_size = 8192\ndim = 1024\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_024_logsoftmax__shape_vocab", "source_kb_id": 24, "category": "activation", "dtype": "fp32", "variant": "shape_vocab", "reference_code": "\"\"\"Task kb1_024_logsoftmax__shape_vocab (KernelBench Level 1 #24, split=train, category=activation, dtype=fp32, variant=shape_vocab).\"\"\"\nPROBLEM_ID = \"kb1_024_logsoftmax__shape_vocab\"\nSOURCE_KB_ID = 24\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_vocab\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a LogSoftmax activation.\n \"\"\"\n def __init__(self, dim: int = 1):\n super(Model, self).__init__()\n self.dim = dim\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies LogSoftmax activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, dim).\n\n Returns:\n torch.Tensor: Output tensor with LogSoftmax applied, same shape as input.\n \"\"\"\n return torch.log_softmax(x, dim=self.dim)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\nbatch_size = 512\ndim = 16384\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_027_selu__shape_nonpow2", "source_kb_id": 27, "category": "activation", "dtype": "fp32", "variant": "shape_nonpow2", "reference_code": "\"\"\"Task kb1_027_selu__shape_nonpow2 (KernelBench Level 1 #27, split=train, category=activation, dtype=fp32, variant=shape_nonpow2).\"\"\"\nPROBLEM_ID = \"kb1_027_selu__shape_nonpow2\"\nSOURCE_KB_ID = 27\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_nonpow2\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a SELU activation.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies SELU activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with SELU applied, same shape as input.\n \"\"\"\n return torch.selu(x)\n \nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\nbatch_size = 1024\ndim = 6144\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_029_softplus__shape_wide", "source_kb_id": 29, "category": "activation", "dtype": "fp32", "variant": "shape_wide", "reference_code": "\"\"\"Task kb1_029_softplus__shape_wide (KernelBench Level 1 #29, split=train, category=activation, dtype=fp32, variant=shape_wide).\"\"\"\nPROBLEM_ID = \"kb1_029_softplus__shape_wide\"\nSOURCE_KB_ID = 29\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_wide\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a Softplus activation.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Softplus activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with Softplus applied, same shape as input.\n \"\"\"\n return torch.nn.functional.softplus(x)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\nbatch_size = 1024\ndim = 8192\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_030_softsign__shape_nonpow2", "source_kb_id": 30, "category": "activation", "dtype": "fp32", "variant": "shape_nonpow2", "reference_code": "\"\"\"Task kb1_030_softsign__shape_nonpow2 (KernelBench Level 1 #30, split=train, category=activation, dtype=fp32, variant=shape_nonpow2).\"\"\"\nPROBLEM_ID = \"kb1_030_softsign__shape_nonpow2\"\nSOURCE_KB_ID = 30\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_nonpow2\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a Softsign activation.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Softsign activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with Softsign applied, same shape as input.\n \"\"\"\n return x / (1 + torch.abs(x))\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\nbatch_size = 3000\ndim = 2000\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_031_elu__shape_tall", "source_kb_id": 31, "category": "activation", "dtype": "fp32", "variant": "shape_tall", "reference_code": "\"\"\"Task kb1_031_elu__shape_tall (KernelBench Level 1 #31, split=train, category=activation, dtype=fp32, variant=shape_tall).\"\"\"\nPROBLEM_ID = \"kb1_031_elu__shape_tall\"\nSOURCE_KB_ID = 31\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_tall\"\n\nimport torch\nimport torch.nn as nn\nimport torch.nn.functional as F\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs an ELU activation.\n \"\"\"\n def __init__(self, alpha: float = 1.0):\n \"\"\"\n Initializes the ELU model.\n\n Args:\n alpha (float, optional): The alpha parameter for the ELU function. Defaults to 1.0.\n \"\"\"\n super(Model, self).__init__()\n self.alpha = alpha\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies ELU activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with ELU applied, same shape as input.\n \"\"\"\n return F.elu(x, alpha=self.alpha)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\nbatch_size = 4096\ndim = 2048\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [1.0] # Provide alpha value for initialization\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_032_hardtanh__shape_nonpow2", "source_kb_id": 32, "category": "activation", "dtype": "fp32", "variant": "shape_nonpow2", "reference_code": "\"\"\"Task kb1_032_hardtanh__shape_nonpow2 (KernelBench Level 1 #32, split=train, category=activation, dtype=fp32, variant=shape_nonpow2).\"\"\"\nPROBLEM_ID = \"kb1_032_hardtanh__shape_nonpow2\"\nSOURCE_KB_ID = 32\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_nonpow2\"\n\nimport torch\nimport torch.nn as nn\nimport torch.nn.functional as F\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a HardTanh activation.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies HardTanh activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with HardTanh applied, same shape as input.\n \"\"\"\n return F.hardtanh(x, min_val=-1., max_val=1.)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\nbatch_size = 2500\ndim = 3072\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_033_batchnorm__shape_spatial", "source_kb_id": 33, "category": "normalization", "dtype": "fp32", "variant": "shape_spatial", "reference_code": "\"\"\"Task kb1_033_batchnorm__shape_spatial (KernelBench Level 1 #33, split=train, category=normalization, dtype=fp32, variant=shape_spatial).\"\"\"\nPROBLEM_ID = \"kb1_033_batchnorm__shape_spatial\"\nSOURCE_KB_ID = 33\nCATEGORY = \"normalization\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_spatial\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs Batch Normalization.\n \"\"\"\n def __init__(self, num_features: int):\n \"\"\"\n Initializes the BatchNorm layer.\n\n Args:\n num_features (int): Number of features in the input tensor.\n \"\"\"\n super(Model, self).__init__()\n self.bn = nn.BatchNorm2d(num_features=num_features)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Batch Normalization to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, num_features, *).\n\n Returns:\n torch.Tensor: Output tensor with Batch Normalization applied, same shape as input.\n \"\"\"\n return self.bn(x)\n\nbatch_size = 64\nfeatures = 64\ndim1 = 512\ndim2 = 512\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 16\nfeatures = 64\ndim1 = 128\ndim2 = 128\nbatch_size = 8\nfeatures = 128\ndim1 = 64\ndim2 = 64\n\ndef get_inputs():\n x = torch.randn(batch_size, features, dim1, dim2)\n return [x]\n\ndef get_init_inputs():\n return [features]\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_035_groupnorm__shape_groups16", "source_kb_id": 35, "category": "normalization", "dtype": "fp32", "variant": "shape_groups16", "reference_code": "\"\"\"Task kb1_035_groupnorm__shape_groups16 (KernelBench Level 1 #35, split=train, category=normalization, dtype=fp32, variant=shape_groups16).\"\"\"\nPROBLEM_ID = \"kb1_035_groupnorm__shape_groups16\"\nSOURCE_KB_ID = 35\nCATEGORY = \"normalization\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_groups16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs Group Normalization.\n \"\"\"\n def __init__(self, num_features: int, num_groups: int):\n \"\"\"\n Initializes the GroupNorm layer.\n\n Args:\n num_features (int): Number of features in the input tensor.\n num_groups (int): Number of groups to divide the channels into.\n \"\"\"\n super(Model, self).__init__()\n self.gn = nn.GroupNorm(num_groups=num_groups, num_channels=num_features)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Group Normalization to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, num_features, *).\n\n Returns:\n torch.Tensor: Output tensor with Group Normalization applied, same shape as input.\n \"\"\"\n return self.gn(x)\n\nbatch_size = 112 # scaled up\nfeatures = 64\nnum_groups = 8\ndim1 = 512\ndim2 = 512\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 16\nfeatures = 64\nnum_groups = 8\ndim1 = 128\ndim2 = 128\nbatch_size = 8\nfeatures = 128\nnum_groups = 16\ndim1 = 64\ndim2 = 64\n\ndef get_inputs():\n x = torch.randn(batch_size, features, dim1, dim2)\n return [x]\n\ndef get_init_inputs():\n return [features, num_groups] # num_features\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_038_l1norm__shape_nonpow2", "source_kb_id": 38, "category": "normalization", "dtype": "fp32", "variant": "shape_nonpow2", "reference_code": "\"\"\"Task kb1_038_l1norm__shape_nonpow2 (KernelBench Level 1 #38, split=train, category=normalization, dtype=fp32, variant=shape_nonpow2).\"\"\"\nPROBLEM_ID = \"kb1_038_l1norm__shape_nonpow2\"\nSOURCE_KB_ID = 38\nCATEGORY = \"normalization\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_nonpow2\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs L1 normalization.\n \"\"\"\n def __init__(self):\n \"\"\"\n Initializes the L1 normalization layer.\n \"\"\"\n super(Model, self).__init__()\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies L1 normalization to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (..., dim, ...).\n\n Returns:\n torch.Tensor: Output tensor with L1 normalization applied, same shape as input.\n \"\"\"\n return x / torch.mean(torch.abs(x), dim=1, keepdim=True)\n\nbatch_size = 32768\n# choose dim so total <2^31\ndim = 65535\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\nbatch_size = 1536\ndim = 5120\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return []\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_039_l2norm__shape_wide", "source_kb_id": 39, "category": "normalization", "dtype": "fp32", "variant": "shape_wide", "reference_code": "\"\"\"Task kb1_039_l2norm__shape_wide (KernelBench Level 1 #39, split=train, category=normalization, dtype=fp32, variant=shape_wide).\"\"\"\nPROBLEM_ID = \"kb1_039_l2norm__shape_wide\"\nSOURCE_KB_ID = 39\nCATEGORY = \"normalization\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_wide\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs L2 normalization.\n \"\"\"\n def __init__(self):\n \"\"\"\n Initializes the L2Norm layer.\n\n Args:\n dim (int): Dimension along which to normalize.\n \"\"\"\n super(Model, self).__init__()\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies L2 normalization to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (*, dim, *).\n\n Returns:\n torch.Tensor: Output tensor with L2 normalization applied, same shape as input.\n \"\"\"\n return x / torch.norm(x, p=2, dim=1, keepdim=True)\n\nbatch_size = 32768\n# choose dim so total <2^31\ndim = 65535\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\nbatch_size = 1024\ndim = 8192\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return []\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_048_mean_reduction_over_a_dimension__shape_large_reduce", "source_kb_id": 48, "category": "reduction_scan", "dtype": "fp32", "variant": "shape_large_reduce", "reference_code": "\"\"\"Task kb1_048_mean_reduction_over_a_dimension__shape_large_reduce (KernelBench Level 1 #48, split=train, category=reduction_scan, dtype=fp32, variant=shape_large_reduce).\"\"\"\nPROBLEM_ID = \"kb1_048_mean_reduction_over_a_dimension__shape_large_reduce\"\nSOURCE_KB_ID = 48\nCATEGORY = \"reduction_scan\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_large_reduce\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs mean reduction over a specific dimension.\n \"\"\"\n def __init__(self, dim: int):\n \"\"\"\n Initializes the model with the dimension to reduce over.\n\n Args:\n dim (int): The dimension to reduce over.\n \"\"\"\n super(Model, self).__init__()\n self.dim = dim\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Reduces the input tensor along the specified dimension by taking the mean.\n\n Args:\n x (torch.Tensor): Input tensor of arbitrary shape.\n\n Returns:\n torch.Tensor: Output tensor with reduced dimension. The shape of the output is the same as the input except for the reduced dimension which is removed.\n \"\"\"\n return torch.mean(x, dim=self.dim)\n\nbatch_size = 128\ndim1 = 4096\ndim2 = 4095\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 32\ndim1 = 512\ndim2 = 511\nbatch_size = 64\ndim1 = 256\ndim2 = 1023\n\ndef get_inputs():\n x = torch.randn(batch_size, dim1, dim2)\n return [x]\n\ndef get_init_inputs():\n return [1]\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_049_max_reduction_over_a_dimension__shape_large_reduce", "source_kb_id": 49, "category": "reduction_scan", "dtype": "fp32", "variant": "shape_large_reduce", "reference_code": "\"\"\"Task kb1_049_max_reduction_over_a_dimension__shape_large_reduce (KernelBench Level 1 #49, split=train, category=reduction_scan, dtype=fp32, variant=shape_large_reduce).\"\"\"\nPROBLEM_ID = \"kb1_049_max_reduction_over_a_dimension__shape_large_reduce\"\nSOURCE_KB_ID = 49\nCATEGORY = \"reduction_scan\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_large_reduce\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs Max reduction over a specific dimension.\n \"\"\"\n def __init__(self, dim: int):\n \"\"\"\n Initializes the model with the dimension to reduce over.\n\n Args:\n dim (int): The dimension to reduce over.\n \"\"\"\n super(Model, self).__init__()\n self.dim = dim\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Max reduction over the specified dimension to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor.\n\n Returns:\n torch.Tensor: Output tensor after Max reduction over the specified dimension.\n \"\"\"\n return torch.max(x, dim=self.dim)[0]\n\nbatch_size = 128\ndim1 = 4096\ndim2 = 4095\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 32\ndim1 = 512\ndim2 = 511\nbatch_size = 64\ndim1 = 256\ndim2 = 1023\n\ndef get_inputs():\n x = torch.randn(batch_size, dim1, dim2)\n return [x]\n\ndef get_init_inputs():\n return [1] # Example, change to desired dimension\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_053_min_reduction_over_a_dimension__shape_nonpow2", "source_kb_id": 53, "category": "reduction_scan", "dtype": "fp32", "variant": "shape_nonpow2", "reference_code": "\"\"\"Task kb1_053_min_reduction_over_a_dimension__shape_nonpow2 (KernelBench Level 1 #53, split=train, category=reduction_scan, dtype=fp32, variant=shape_nonpow2).\"\"\"\nPROBLEM_ID = \"kb1_053_min_reduction_over_a_dimension__shape_nonpow2\"\nSOURCE_KB_ID = 53\nCATEGORY = \"reduction_scan\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_nonpow2\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs min reduction over a specific dimension.\n \"\"\"\n def __init__(self, dim: int):\n \"\"\"\n Initializes the model with the dimension to reduce over.\n\n Args:\n dim (int): The dimension to reduce over.\n \"\"\"\n super(Model, self).__init__()\n self.dim = dim\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies min reduction over the specified dimension to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor.\n\n Returns:\n torch.Tensor: Output tensor after min reduction over the specified dimension.\n \"\"\"\n return torch.min(x, dim=self.dim)[0]\n\nbatch_size = 128\ndim1 = 4096\ndim2 = 4095\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 32\ndim1 = 512\ndim2 = 511\nbatch_size = 48\ndim1 = 384\ndim2 = 768\n\ndef get_inputs():\n x = torch.randn(batch_size, dim1, dim2)\n return [x]\n\ndef get_init_inputs():\n return [1] # Example, change to desired dimension\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_088_mingptnewgelu__shape_nonpow2", "source_kb_id": 88, "category": "activation", "dtype": "fp32", "variant": "shape_nonpow2", "reference_code": "\"\"\"Task kb1_088_mingptnewgelu__shape_nonpow2 (KernelBench Level 1 #88, split=train, category=activation, dtype=fp32, variant=shape_nonpow2).\"\"\"\nPROBLEM_ID = \"kb1_088_mingptnewgelu__shape_nonpow2\"\nSOURCE_KB_ID = 88\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_nonpow2\"\n\nimport torch\nimport torch.nn as nn\nimport torch.nn.functional as F\nimport math\n\n# From https://github.com/karpathy/minGPT/blob/master/mingpt/model.py\n\nclass Model(nn.Module):\n \"\"\"\n Implementation of the GELU activation function currently in Google BERT repo (identical to OpenAI GPT).\n Reference: Gaussian Error Linear Units (GELU) paper: https://arxiv.org/abs/1606.08415\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x):\n return 0.5 * x * (1.0 + torch.tanh(math.sqrt(2.0 / math.pi) * (x + 0.044715 * torch.pow(x, 3.0))))\n\nbatch_size = 8192\ndim = 8192\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\nbatch_size = 1536\ndim = 5120\n\ndef get_inputs():\n return [torch.randn(batch_size, dim)]\n\ndef get_init_inputs():\n return []\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_091_cumsum_reverse__shape_wide", "source_kb_id": 91, "category": "reduction_scan", "dtype": "fp32", "variant": "shape_wide", "reference_code": "\"\"\"Task kb1_091_cumsum_reverse__shape_wide (KernelBench Level 1 #91, split=train, category=reduction_scan, dtype=fp32, variant=shape_wide).\"\"\"\nPROBLEM_ID = \"kb1_091_cumsum_reverse__shape_wide\"\nSOURCE_KB_ID = 91\nCATEGORY = \"reduction_scan\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_wide\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n A model that performs a reverse cumulative sum operation along a specified dimension.\n\n Parameters:\n dim (int): The dimension along which to perform the reverse cumulative sum.\n \"\"\"\n\n def __init__(self, dim):\n super(Model, self).__init__()\n self.dim = dim\n\n def forward(self, x):\n return torch.cumsum(x.flip(self.dim), dim=self.dim).flip(self.dim)\n\nbatch_size = 32768\ninput_shape = (32768,)\ndim = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ninput_shape = (2048,)\nbatch_size = 1024\ninput_shape = (4096,)\n\ndef get_inputs():\n return [torch.rand(batch_size, *input_shape)]\n\ndef get_init_inputs():\n return [dim]\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_096_huberloss__shape_nonpow2", "source_kb_id": 96, "category": "loss_attention", "dtype": "fp32", "variant": "shape_nonpow2", "reference_code": "\"\"\"Task kb1_096_huberloss__shape_nonpow2 (KernelBench Level 1 #96, split=train, category=loss_attention, dtype=fp32, variant=shape_nonpow2).\"\"\"\nPROBLEM_ID = \"kb1_096_huberloss__shape_nonpow2\"\nSOURCE_KB_ID = 96\nCATEGORY = \"loss_attention\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_nonpow2\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n A model that computes Smooth L1 (Huber) Loss for regression tasks.\n\n Parameters:\n None\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n\n def forward(self, predictions, targets):\n return torch.nn.functional.smooth_l1_loss(predictions, targets)\n\nbatch_size = 32768\ninput_shape = (32768,)\ndim = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ninput_shape = (4096,)\nbatch_size = 1500\ninput_shape = (3000,)\n\ndef get_inputs():\n scale = torch.rand(())\n return [torch.rand(batch_size, *input_shape)*scale, torch.rand(batch_size, *input_shape)]\n\ndef get_init_inputs():\n return []\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}
{"problem_id": "kb1_099_tripletmarginloss__shape_wide", "source_kb_id": 99, "category": "loss_attention", "dtype": "fp32", "variant": "shape_wide", "reference_code": "\"\"\"Task kb1_099_tripletmarginloss__shape_wide (KernelBench Level 1 #99, split=train, category=loss_attention, dtype=fp32, variant=shape_wide).\"\"\"\nPROBLEM_ID = \"kb1_099_tripletmarginloss__shape_wide\"\nSOURCE_KB_ID = 99\nCATEGORY = \"loss_attention\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_wide\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n A model that computes Triplet Margin Loss for metric learning tasks.\n\n Parameters:\n margin (float): The margin between the positive and negative samples.\n \"\"\"\n def __init__(self, margin=1.0):\n super(Model, self).__init__()\n self.loss_fn = torch.nn.TripletMarginLoss(margin=margin)\n\n def forward(self, anchor, positive, negative):\n return self.loss_fn(anchor, positive, negative)\n\nbatch_size = 32768\ninput_shape = (8192,)\ndim = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ninput_shape = (2048,)\nbatch_size = 1024\ninput_shape = (4096,)\n\ndef get_inputs():\n scale = torch.rand(())\n return [torch.rand(batch_size, *input_shape)*scale, torch.rand(batch_size, *input_shape), torch.rand(batch_size, *input_shape)]\n \ndef get_init_inputs():\n return [1.0] # Default margin\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}