Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions benchmarks/base_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,25 @@ def run_inference(self, pipe, args):
guidance_scale=1.0,
)

def benchmark(self, args):
Copy link
Member Author

@sayakpaul sayakpaul Dec 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This ensures that the overridden get_result_filepath() in the LCMLoRATextToImageBenchmark class gets called properly.

flush()

print(f"[INFO] {self.pipe.__class__.__name__}: Running benchmark with: {vars(args)}\n")

time = benchmark_fn(self.run_inference, self.pipe, args) # in seconds.
memory = bytes_to_giga_bytes(torch.cuda.max_memory_allocated()) # in GBs.
benchmark_info = BenchmarkInfo(time=time, memory=memory)

pipeline_class_name = str(self.pipe.__class__.__name__)
flush()
csv_dict = generate_csv_dict(
pipeline_cls=pipeline_class_name, ckpt=self.lora_id, args=args, benchmark_info=benchmark_info
)
filepath = self.get_result_filepath(args)
write_to_csv(filepath, csv_dict)
print(f"Logs written to: {filepath}")
flush()


class ImageToImageBenchmark(TextToImageBenchmark):
pipeline_class = AutoPipelineForImage2Image
Expand Down