mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-21 05:34:18 +08:00
[BE]: Apply FURB118 (prev): replaces unnecessary lambdas with operator. (#116027)
This replaces a bunch of unnecessary lambdas with the operator package. This is semantically equivalent, but the operator package is faster, and arguably more readable. When the FURB rules are taken out of preview, I will enable it as a ruff check. Pull Request resolved: https://github.com/pytorch/pytorch/pull/116027 Approved by: https://github.com/malfet
This commit is contained in:
committed by
PyTorch MergeBot
parent
2d2016fdf8
commit
6de28e92d2
@ -84,6 +84,7 @@ from torch.testing._internal.common_utils import (
|
||||
import torch.distributed.optim.post_localSGD_optimizer as post_localSGD_optimizer
|
||||
|
||||
from torch.utils.data.distributed import DistributedSampler
|
||||
import operator
|
||||
|
||||
try:
|
||||
import torchvision
|
||||
@ -2167,7 +2168,7 @@ class DistributedTest:
|
||||
dist.ReduceOp.PRODUCT,
|
||||
2,
|
||||
10,
|
||||
reduce((lambda x, y: x * y), [10] * (len(group) - 1), 2),
|
||||
reduce(operator.mul, [10] * (len(group) - 1), 2),
|
||||
)
|
||||
|
||||
@skip_but_pass_in_sandcastle_if(
|
||||
@ -2233,7 +2234,7 @@ class DistributedTest:
|
||||
dist.ReduceOp.PRODUCT,
|
||||
2,
|
||||
10,
|
||||
reduce((lambda x, y: x * y), [10] * (len(group) - 1), 2),
|
||||
reduce(operator.mul, [10] * (len(group) - 1), 2),
|
||||
)
|
||||
|
||||
@skip_but_pass_in_sandcastle_if(
|
||||
@ -2299,7 +2300,7 @@ class DistributedTest:
|
||||
dist.ReduceOp.PRODUCT,
|
||||
2,
|
||||
10,
|
||||
reduce((lambda x, y: x * y), [10] * (len(group) - 1), 2),
|
||||
reduce(operator.mul, [10] * (len(group) - 1), 2),
|
||||
)
|
||||
|
||||
@skip_but_pass_in_sandcastle_if(
|
||||
@ -2821,7 +2822,7 @@ class DistributedTest:
|
||||
dist.ReduceOp.PRODUCT,
|
||||
2,
|
||||
10,
|
||||
reduce((lambda x, y: x * y), [10] * (len(group) - 1), 2),
|
||||
reduce(operator.mul, [10] * (len(group) - 1), 2),
|
||||
)
|
||||
|
||||
@skip_but_pass_in_sandcastle_if(
|
||||
@ -2871,7 +2872,7 @@ class DistributedTest:
|
||||
dist.ReduceOp.PRODUCT,
|
||||
2,
|
||||
10,
|
||||
reduce((lambda x, y: x * y), [10] * (len(group) - 1), 2),
|
||||
reduce(operator.mul, [10] * (len(group) - 1), 2),
|
||||
)
|
||||
|
||||
@skip_if_small_worldsize
|
||||
@ -2921,7 +2922,7 @@ class DistributedTest:
|
||||
dist.ReduceOp.PRODUCT,
|
||||
2,
|
||||
10,
|
||||
reduce((lambda x, y: x * y), [10] * (len(group) - 1), 2),
|
||||
reduce(operator.mul, [10] * (len(group) - 1), 2),
|
||||
)
|
||||
|
||||
@skip_but_pass_in_sandcastle_if(
|
||||
|
Reference in New Issue
Block a user