mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
[BE] Format uncategorized Python files with ruff format
(#132576)
Remove patterns `**`, `test/**`, and `torch/**` in `tools/linter/adapters/pyfmt_linter.py` and run `lintrunner`. Pull Request resolved: https://github.com/pytorch/pytorch/pull/132576 Approved by: https://github.com/ezyang, https://github.com/Skylion007 ghstack dependencies: #132574
This commit is contained in:
committed by
PyTorch MergeBot
parent
c35061c542
commit
4226ed1585
@ -689,9 +689,7 @@ class TestIndexing(TestCase):
|
||||
[[0, 2, 3], slice(None), [1, 3, 4]],
|
||||
# [...]
|
||||
# less dim, ellipsis
|
||||
[
|
||||
[0, 2],
|
||||
],
|
||||
[[0, 2]],
|
||||
[[0, 2], slice(None)],
|
||||
[[0, 2], Ellipsis],
|
||||
[[0, 2], slice(None), Ellipsis],
|
||||
@ -776,9 +774,7 @@ class TestIndexing(TestCase):
|
||||
[[0], [1, 2, 4], slice(None)],
|
||||
[[0], [1, 2, 4], Ellipsis],
|
||||
[[0], [1, 2, 4], Ellipsis, slice(None)],
|
||||
[
|
||||
[1],
|
||||
],
|
||||
[[1]],
|
||||
[[0, 2, 1], [3], [4]],
|
||||
[[0, 2, 1], [3], [4], slice(None)],
|
||||
[[0, 2, 1], [3], [4], Ellipsis],
|
||||
@ -951,21 +947,10 @@ class TestIndexing(TestCase):
|
||||
# and verifies consistency with CPU result
|
||||
t = torch.zeros((5, 2))
|
||||
t_dev = t.to(device)
|
||||
indices = [
|
||||
torch.tensor([0, 1, 2, 3]),
|
||||
torch.tensor(
|
||||
[
|
||||
1,
|
||||
]
|
||||
),
|
||||
]
|
||||
indices = [torch.tensor([0, 1, 2, 3]), torch.tensor([1])]
|
||||
indices_dev = [i.to(device) for i in indices]
|
||||
values0d = torch.tensor(1.0)
|
||||
values1d = torch.tensor(
|
||||
[
|
||||
1.0,
|
||||
]
|
||||
)
|
||||
values1d = torch.tensor([1.0])
|
||||
|
||||
out_cuda = t_dev.index_put_(indices_dev, values0d.to(device), accumulate=True)
|
||||
out_cpu = t.index_put_(indices, values0d, accumulate=True)
|
||||
@ -979,21 +964,13 @@ class TestIndexing(TestCase):
|
||||
t_dev = t.to(device)
|
||||
|
||||
indices = [
|
||||
torch.tensor(
|
||||
[
|
||||
0,
|
||||
]
|
||||
),
|
||||
torch.tensor([0]),
|
||||
torch.arange(3)[:, None],
|
||||
torch.arange(2)[None, :],
|
||||
]
|
||||
indices_dev = [i.to(device) for i in indices]
|
||||
values1d = torch.tensor([-1.0, -2.0])
|
||||
values2d = torch.tensor(
|
||||
[
|
||||
[-1.0, -2.0],
|
||||
]
|
||||
)
|
||||
values2d = torch.tensor([[-1.0, -2.0]])
|
||||
|
||||
out_cuda = t_dev.index_put_(indices_dev, values1d.to(device), accumulate=True)
|
||||
out_cpu = t.index_put_(indices, values1d, accumulate=True)
|
||||
@ -1012,9 +989,7 @@ class TestIndexing(TestCase):
|
||||
self.assertTrue(not t1.is_contiguous())
|
||||
self.assertTrue(not t2.is_contiguous())
|
||||
|
||||
indices = [
|
||||
torch.tensor([0, 1]),
|
||||
]
|
||||
indices = [torch.tensor([0, 1])]
|
||||
indices_dev = [i.to(device) for i in indices]
|
||||
value = torch.randn(2, 2)
|
||||
out_cuda = t1.index_put_(indices_dev, value.to(device), accumulate=True)
|
||||
|
Reference in New Issue
Block a user