From 02621717de47db95043acf1a6c45f99afcdcb9a6 Mon Sep 17 00:00:00 2001 From: Ahmad Sharif Date: Tue, 6 Aug 2024 11:06:03 -0700 Subject: [PATCH] [torchcodec] Improve GPU benchmark (#157) Summary: Pull Request resolved: https://github.com/pytorch/torchcodec/pull/157 Use functional resize for the resize transform. Display values as a single column instead of a single row as it's easier to share (it fits in a narrow column). Reviewed By: NicolasHug Differential Revision: D60840151 --- benchmarks/decoders/gpu_benchmark.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/benchmarks/decoders/gpu_benchmark.py b/benchmarks/decoders/gpu_benchmark.py index daa397159..4fd7c8ad6 100644 --- a/benchmarks/decoders/gpu_benchmark.py +++ b/benchmarks/decoders/gpu_benchmark.py @@ -5,16 +5,16 @@ import torch.utils.benchmark as benchmark import torchcodec -from torchvision.transforms import Resize +import torchvision.transforms.v2.functional as F RESIZED_WIDTH = 256 RESIZED_HEIGHT = 256 def transfer_and_resize_frame(frame, resize_device_string): - # This should be a no-op if the frame is already on the GPU. + # This should be a no-op if the frame is already on the target device. frame = frame.to(resize_device_string) - frame = Resize((RESIZED_HEIGHT, RESIZED_WIDTH))(frame) + frame = F.resize(frame, (RESIZED_HEIGHT, RESIZED_WIDTH)) return frame @@ -129,8 +129,8 @@ def main(): "resize_device_string": resize_device_string, }, label=label, - sub_label=f"video={os.path.basename(video_path)}", - description=f"D={decode_label},R={resize_label}", + description=f"video={os.path.basename(video_path)}", + sub_label=f"D={decode_label} R={resize_label}", ).blocked_autorange() results.append(t) compare = benchmark.Compare(results)