[BE]: Optimize min/max/sum comprehensions C419 (#123960)

Automatic fixes that replaces certain list comprehensions with generator ones where appropriate so that they are immediately consumed. This is preview functionality in ruff for rule C419 and it was automatically applied.

Co-authored-by: Nikita Shulga <2453524+malfet@users.noreply.github.com>
Pull Request resolved: https://github.com/pytorch/pytorch/pull/123960
Approved by: https://github.com/malfet
This commit is contained in:
Aaron Gokaslan
2024-04-12 23:54:11 +00:00
committed by PyTorch MergeBot
parent 961eb39348
commit 1d6c5972c1
42 changed files with 89 additions and 110 deletions

View File

@ -334,9 +334,7 @@ class TestForeach(TestCase):
[rhs_arg, tensors], is_cuda=False, expect_fastpath=False
)
).mean().backward()
sum(
[ref.func(ref_rhs_arg, t) for t in ref_tensors]
).mean().backward()
sum(ref.func(ref_rhs_arg, t) for t in ref_tensors).mean().backward()
self.assertEqual(
[t.grad for t in tensors], [t.grad for t in ref_tensors]
)