()
| 937 | # --------------------------------------------------------------------------- |
| 938 | |
| 939 | def main() -> int: |
| 940 | global WARMUP_ITERS, PROFILE_ITERS |
| 941 | |
| 942 | args = parse_args() |
| 943 | WARMUP_ITERS = args.warmup_iters |
| 944 | PROFILE_ITERS = args.profile_iters |
| 945 | |
| 946 | # Discover supported kernel types from kernels/ directory |
| 947 | global _SUPPORTED_OP_TYPES |
| 948 | _SUPPORTED_OP_TYPES = _discover_supported_op_types() |
| 949 | |
| 950 | # Parse input shape |
| 951 | try: |
| 952 | input_shape = [int(x.strip()) for x in args.input_shape.split(",")] |
| 953 | except ValueError: |
| 954 | print( |
| 955 | f"ERROR: Invalid --input-shape '{args.input_shape}'. " |
| 956 | "Expected comma-separated integers." |
| 957 | ) |
| 958 | return 1 |
| 959 | |
| 960 | # Resolve dtype |
| 961 | try: |
| 962 | dtype = _resolve_dtype(args.dtype) |
| 963 | except ValueError as e: |
| 964 | print(f"ERROR: {e}") |
| 965 | return 1 |
| 966 | |
| 967 | # Check GPU availability |
| 968 | if not torch.cuda.is_available(): |
| 969 | print("ERROR: No CUDA GPU detected. The profiler requires a GPU.") |
| 970 | return 1 |
| 971 | |
| 972 | device = "cuda" |
| 973 | |
| 974 | # Detect GPU |
| 975 | gpu = detect_gpu() |
| 976 | |
| 977 | print() |
| 978 | print("=== AutoKernel Profiler ===") |
| 979 | |
| 980 | # Load model |
| 981 | print("Loading model...") |
| 982 | try: |
| 983 | model, model_desc = load_model(args) |
| 984 | except Exception as e: |
| 985 | print(f"ERROR loading model: {e}") |
| 986 | traceback.print_exc() |
| 987 | return 1 |
| 988 | |
| 989 | print(f" Model: {model_desc}") |
| 990 | print(f" Input: shape={input_shape}, dtype={args.dtype}") |
| 991 | print(f" GPU: {gpu.name}") |
| 992 | print() |
| 993 | |
| 994 | # Prepare model and input |
| 995 | print("Preparing model and input...") |
| 996 | try: |
no test coverage detected