Skip to content

Allow v2 Normalize to reuse tensor statistics - #9621

Open
medisean wants to merge 2 commits into
pytorch:mainfrom
medisean:feat/normalize-tensor-parameters
Open

Allow v2 Normalize to reuse tensor statistics#9621
medisean wants to merge 2 commits into
pytorch:mainfrom
medisean:feat/normalize-tensor-parameters

Conversation

@medisean

Copy link
Copy Markdown

Summary

Fixes #9576.

  • Allow transforms.v2.Normalize to receive tensor mean/std values directly.
  • Preserve tensor objects instead of converting them to Python lists, so torch.as_tensor in the kernel can reuse already device-resident statistics without repeated host-to-device copies.
  • Keep sequence inputs backward compatible and add regression coverage.

Testing

  • python3 -m py_compile torchvision/transforms/v2/_misc.py test/test_transforms_v2.py
  • git diff --check
  • The focused PyTorch test is deferred to CI because PyTorch is not installed in this checkout.

@pytorch-bot

pytorch-bot Bot commented Aug 22, 2026

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/vision/9621

Note: Links to docs will display an error until the docs builds have been completed.

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla Bot added the cla signed label Aug 22, 2026
@medisean
medisean marked this pull request as ready for review August 23, 2026 00:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

transforms.v2.Normalize caused small H2D and cpu waits gpu if process image on gpu

1 participant