(sp_format, input_sizes)
| 78 | ], |
| 79 | ) |
| 80 | def test_sparse_dot(sp_format, input_sizes): |
| 81 | pytest.importorskip("cupyx") |
| 82 | |
| 83 | if sp_format == "csr": |
| 84 | sp_matrix = cupyx.scipy.sparse.csr_matrix |
| 85 | elif sp_format == "csc": |
| 86 | sp_matrix = cupyx.scipy.sparse.csc_matrix |
| 87 | dtype = "f" |
| 88 | density = 0.3 |
| 89 | rng = cupy.random.default_rng() |
| 90 | x_shape, x_chunks = input_sizes["x_shape"], input_sizes["x_chunks"] |
| 91 | y_shape, y_chunks = input_sizes["y_shape"], input_sizes["y_chunks"] |
| 92 | x = rng.random(x_shape, dtype=dtype) |
| 93 | y = rng.random(y_shape, dtype=dtype) |
| 94 | x[x < 1 - density] = 0 |
| 95 | y[y < 1 - density] = 0 |
| 96 | z = x.dot(y) |
| 97 | |
| 98 | da_x = da.from_array(x, chunks=x_chunks, asarray=False, fancy=False) |
| 99 | da_y = da.from_array(y, chunks=y_chunks, asarray=False, fancy=False) |
| 100 | da_x = da_x.map_blocks(sp_matrix, meta=sp_matrix(cupy.array([0], dtype=dtype))) |
| 101 | da_y = da_y.map_blocks(sp_matrix, meta=sp_matrix(cupy.array([0], dtype=dtype))) |
| 102 | da_z = da.dot(da_x, da_y).compute() |
| 103 | |
| 104 | assert cupyx.scipy.sparse.isspmatrix(da_z) |
| 105 | assert_eq(z, da_z.todense()) |
nothing calls this directly
no test coverage detected