Read the starter kernel file. Returns None if not found. For backend='triton': reads from kernels/{op_type}.py For backend='cuda': reads from kernels/cuda/{op_type}.py
(op_type: str, backend: str = "triton")
| 244 | # --------------------------------------------------------------------------- |
| 245 | |
| 246 | def read_starter_kernel(op_type: str, backend: str = "triton") -> Optional[str]: |
| 247 | """Read the starter kernel file. Returns None if not found. |
| 248 | |
| 249 | For backend='triton': reads from kernels/{op_type}.py |
| 250 | For backend='cuda': reads from kernels/cuda/{op_type}.py |
| 251 | """ |
| 252 | if backend == "cuda": |
| 253 | path = os.path.join(KERNELS_DIR, "cuda", f"{op_type}.py") |
| 254 | else: |
| 255 | path = os.path.join(KERNELS_DIR, f"{op_type}.py") |
| 256 | if not os.path.exists(path): |
| 257 | return None |
| 258 | with open(path, "r", encoding="utf-8") as f: |
| 259 | return f.read() |
| 260 | |
| 261 | |
| 262 | def extract_kernel_body(starter_code: str) -> str: |