MCPcopy Create free account
hub / github.com/dask/dask / test_sparse_dot

Function test_sparse_dot

dask/array/tests/test_cupy_sparse.py:80–105  ·  view source on GitHub ↗
(sp_format, input_sizes)

Source from the content-addressed store, hash-verified

78 ],
79)
80def 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())

Callers

nothing calls this directly

Calls 5

assert_eqFunction · 0.90
randomMethod · 0.45
dotMethod · 0.45
map_blocksMethod · 0.45
computeMethod · 0.45

Tested by

no test coverage detected