(create_func, nnz, shape, nz_dim)
| 143 | @pytest.mark.parametrize("nnz", [1, 14]) |
| 144 | @pytest.mark.parametrize("nz_dim", [None, 3]) |
| 145 | def test_spspdiv(create_func, nnz, shape, nz_dim): |
| 146 | dev = F.ctx() |
| 147 | A = create_func(shape, nnz, dev, nz_dim) |
| 148 | |
| 149 | perm = torch.randperm(A.nnz, device=dev) |
| 150 | rperm = torch.argsort(perm) |
| 151 | B = spmatrix(A.indices()[:, perm], A.val[perm], A.shape) |
| 152 | C = div(A, B) |
| 153 | assert not C.has_duplicate() |
| 154 | assert torch.allclose(C.val, A.val / B.val[rperm], atol=1e-05) |
| 155 | assert torch.allclose(C.indices(), A.indices(), atol=1e-05) |
| 156 | |
| 157 | # No need to test backward here, since it is handled by Pytorch |
nothing calls this directly
no test coverage detected