(self)
| 65 | print(out) |
| 66 | |
| 67 | def test(self): |
| 68 | rows = torch.Tensor([0, 0, 1, 1]).int() |
| 69 | cols = torch.Tensor([0, 1, 2, 3]).int() |
| 70 | vals = torch.ones(4).double() |
| 71 | size = [2, 4] |
| 72 | mat = torch.rand(4, 3).double() |
| 73 | mat.requires_grad_() |
| 74 | spmm_fn = MinkowskiSPMMFunction() |
| 75 | out = spmm_fn.apply(rows, cols, vals, size, mat) |
| 76 | print(out) |
| 77 | |
| 78 | loss = out.sum() |
| 79 | loss.backward() |
| 80 | print(mat.grad) |
| 81 | self.assertTrue(gradcheck(spmm_fn, (rows, cols, vals, size, mat))) |
| 82 | |
| 83 | rows = rows.cuda() |
| 84 | cols = cols.cuda() |
| 85 | vals = vals.cuda() |
| 86 | mat = mat.cuda() |
| 87 | mat.requires_grad_() |
| 88 | out = spmm_fn.apply(rows, cols, vals, size, mat) |
| 89 | print(out) |
| 90 | |
| 91 | loss = out.sum() |
| 92 | loss.backward() |
| 93 | print(mat.grad) |
| 94 | self.assertTrue(gradcheck(spmm_fn, (rows, cols, vals, size, mat))) |
| 95 | |
| 96 | def test_average(self): |
| 97 | rows = torch.Tensor([0, 0, 1, 1]).int() |
nothing calls this directly
no test coverage detected