We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8f94917 commit 1c29504Copy full SHA for 1c29504
test/regressions/test_index_and_index_put.py
@@ -119,3 +119,16 @@ def test_flip_float8(self):
119
b_cpu = torch.flip(a_cpu, [0]).to(torch.float32)
120
b_xpu = torch.flip(a_xpu, [0]).cpu().to(torch.float32)
121
self.assertEqual(b_cpu, b_xpu)
122
+
123
+ def test_index_add_empty(self):
124
+ x_cpu = torch.zeros([128], dtype=torch.int32)
125
+ idx_cpu = torch.tensor([], dtype=torch.int32)
126
+ src_cpu = torch.tensor([], dtype=torch.int32)
127
+ y_cpu = x_cpu.index_add(0, idx_cpu, src_cpu)
128
129
+ x_xpu = x_cpu.xpu()
130
+ idx_xpu = idx_cpu.xpu()
131
+ src_xpu = src_cpu.xpu()
132
+ y_xpu = x_xpu.index_add(0, idx_xpu, src_xpu)
133
134
+ self.assertEqual(y_xpu.cpu(), y_cpu)
0 commit comments