Skip to content

Commit 1c29504

Browse files
committed
Add simple test case
1 parent 8f94917 commit 1c29504

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

test/regressions/test_index_and_index_put.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,16 @@ def test_flip_float8(self):
119119
b_cpu = torch.flip(a_cpu, [0]).to(torch.float32)
120120
b_xpu = torch.flip(a_xpu, [0]).cpu().to(torch.float32)
121121
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

Comments
 (0)