mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +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
@ -2980,17 +2980,17 @@ class TestBinaryUfuncs(TestCase):
|
||||
@onlyCPU
|
||||
@dtypes(torch.float)
|
||||
def test_cdiv(self, device, dtype):
|
||||
self._test_cop(torch.div, lambda x, y: x / y, dtype, device)
|
||||
self._test_cop(torch.div, operator.truediv, dtype, device)
|
||||
|
||||
@onlyCPU
|
||||
@dtypes(torch.float)
|
||||
def test_cremainder(self, device, dtype):
|
||||
self._test_cop(torch.remainder, lambda x, y: x % y, dtype, device)
|
||||
self._test_cop(torch.remainder, operator.mod, dtype, device)
|
||||
|
||||
@onlyCPU
|
||||
@dtypes(torch.float)
|
||||
def test_cmul(self, device, dtype):
|
||||
self._test_cop(torch.mul, lambda x, y: x * y, dtype, device)
|
||||
self._test_cop(torch.mul, operator.mul, dtype, device)
|
||||
|
||||
@onlyCPU
|
||||
@dtypes(torch.float)
|
||||
|
||||
Reference in New Issue
Block a user