| 34 | |
| 35 | |
| 36 | def main(): |
| 37 | python_files = glob.glob(PATTERN) |
| 38 | |
| 39 | for file in python_files: |
| 40 | print(f"****** Running file: {file} ******") |
| 41 | |
| 42 | # Run with canonical settings. |
| 43 | if file != "benchmark_text_to_image.py" and file != "benchmark_ip_adapters.py": |
| 44 | command = f"python {file}" |
| 45 | run_command(command.split()) |
| 46 | |
| 47 | command += " --run_compile" |
| 48 | run_command(command.split()) |
| 49 | |
| 50 | # Run variants. |
| 51 | for file in python_files: |
| 52 | # See: https://github.com/pytorch/pytorch/issues/129637 |
| 53 | if file == "benchmark_ip_adapters.py": |
| 54 | continue |
| 55 | |
| 56 | if file == "benchmark_text_to_image.py": |
| 57 | for ckpt in ALL_T2I_CKPTS: |
| 58 | command = f"python {file} --ckpt {ckpt}" |
| 59 | |
| 60 | if "turbo" in ckpt: |
| 61 | command += " --num_inference_steps 1" |
| 62 | |
| 63 | run_command(command.split()) |
| 64 | |
| 65 | command += " --run_compile" |
| 66 | run_command(command.split()) |
| 67 | |
| 68 | elif file == "benchmark_sd_img.py": |
| 69 | for ckpt in ["stabilityai/stable-diffusion-xl-refiner-1.0", "stabilityai/sdxl-turbo"]: |
| 70 | command = f"python {file} --ckpt {ckpt}" |
| 71 | |
| 72 | if ckpt == "stabilityai/sdxl-turbo": |
| 73 | command += " --num_inference_steps 2" |
| 74 | |
| 75 | run_command(command.split()) |
| 76 | command += " --run_compile" |
| 77 | run_command(command.split()) |
| 78 | |
| 79 | elif file in ["benchmark_sd_inpainting.py", "benchmark_ip_adapters.py"]: |
| 80 | sdxl_ckpt = "stabilityai/stable-diffusion-xl-base-1.0" |
| 81 | command = f"python {file} --ckpt {sdxl_ckpt}" |
| 82 | run_command(command.split()) |
| 83 | |
| 84 | command += " --run_compile" |
| 85 | run_command(command.split()) |
| 86 | |
| 87 | elif file in ["benchmark_controlnet.py", "benchmark_t2i_adapter.py"]: |
| 88 | sdxl_ckpt = ( |
| 89 | "diffusers/controlnet-canny-sdxl-1.0" |
| 90 | if "controlnet" in file |
| 91 | else "TencentARC/t2i-adapter-canny-sdxl-1.0" |
| 92 | ) |
| 93 | command = f"python {file} --ckpt {sdxl_ckpt}" |