"""Task kb1_015_matmul_for_lower_triangular_matrices (KernelBench Level 1 #15, split=train, category=matmul, dtype=fp32, variant=base).""" PROBLEM_ID = "kb1_015_matmul_for_lower_triangular_matrices" SOURCE_KB_ID = 15 CATEGORY = "matmul" SPLIT = "train" DTYPE = "fp32" VARIANT = "base" import torch import torch.nn as nn class Model(nn.Module): """ Simple model that performs a matrix multiplication (C = A * B) where A and B are lower triangular matrices. """ def __init__(self): super(Model, self).__init__() def forward(self, A, B): """ Performs matrix multiplication of lower triangular matrices A and B. Args: A (torch.Tensor): Lower triangular matrix of shape (N, N). B (torch.Tensor): Lower triangular matrix of shape (N, N). Returns: torch.Tensor: The result of matrix multiplication C of shape (N, N). """ return torch.tril(torch.matmul(A, B)) M = 4096 # --- Task shape configuration (4GB-safe laptop envelope) --- M = 1024 def get_inputs(): A = torch.rand(M, M) B = torch.rand(M, M) A = torch.tril(A) B = torch.tril(B) return [A, B] def get_init_inputs(): return [] # No special initialization inputs needed if __name__ == "__main__": import sys from pathlib import Path sys.path.insert(0, str(Path(__file__).resolve().parents[2])) from verifier import verify_kernel, format_result res = verify_kernel(None, __file__, self_check=True) print(format_result(res)) sys.exit(0 if res["status"] == "PASS" else 1)