Extract the list of supported (autokernel_supported=True) kernels from the profile report, sorted by rank.
(report: Dict[str, Any])
| 403 | |
| 404 | |
| 405 | def get_supported_kernels(report: Dict[str, Any]) -> List[Dict[str, Any]]: |
| 406 | """ |
| 407 | Extract the list of supported (autokernel_supported=True) kernels from |
| 408 | the profile report, sorted by rank. |
| 409 | """ |
| 410 | kernels = report.get("top_kernels", report.get("kernels", report.get("bottleneck_kernels", []))) |
| 411 | supported = [] |
| 412 | for k in kernels: |
| 413 | if k.get("autokernel_supported", False): |
| 414 | supported.append(k) |
| 415 | |
| 416 | # Sort by rank if available, otherwise by gpu_time_ms descending |
| 417 | supported.sort(key=lambda x: x.get("rank", x.get("gpu_time_ms", 0))) |
| 418 | # Ensure rank ordering (lower rank = higher priority) |
| 419 | for i, k in enumerate(supported): |
| 420 | if "rank" not in k: |
| 421 | k["rank"] = i + 1 |
| 422 | |
| 423 | return supported |
| 424 | |
| 425 | |
| 426 | # --------------------------------------------------------------------------- |