You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Before carrying out the multiplication, _sparse_dot_dense and _sparse_dot_sparse check whether the result is zero and take a shortcut. However, if the out parameter is specified, this shortcut will just return the output matrix unchanged instead of setting it to zero. Edit: Basically, the out_scalar parameter is completely ignored. Second edit: Actually, there's another issue due to the inconsistent way in which output arrays are handled. spmm does not accept an out parameter, so correctly an exception is thrown if one is provided. spmmd does allow for one; however, it always acts as if out_scalar=0 (so the default None corresponds to 0 in this case). sparse_dot just ignores the out_scalar parameter. sparse_?_mm and sparse_?_mv also allows for the output, and this case the out_scalar is converted using _mkl_scalar, i.e., the default None corresponds to 1 in this case. I think there are only two ways to resolve this inconsistency in the general dot_product_mkl interface:
The backwards-compatible one is to check for out_scalar different from None or 0 in the spmmd case and throw an exception, plus add this to the documentation.
The consistency-oriented one is to change the default value of out_scalar from None to 0 and add the exception conditioned on it not being 0.
importsparse_dot_mkl, scipy.sparse, numpyoutput=numpy.random.rand(3, 3)
sparse_dot_mkl._sparse_dense._sparse_dot_dense(
numpy.array([[1., 2., 3.], [4., 5., 6.], [7., 8., 9.]]),
scipy.sparse.csr_matrix((3, 3)),
out=output,
out_scalar=0
)
# now out is still the random matrixsparse_dot_mkl._sparse_sparse._sparse_dot_sparse(
scipy.sparse.csr_matrix((3, 3)),
scipy.sparse.csr_matrix((3, 3)),
out=output,
dense=True,
out_scalar=0
)
# and also now
The text was updated successfully, but these errors were encountered:
projekter
added a commit
to projekter/sparse_dot
that referenced
this issue
Nov 6, 2024
Before carrying out the multiplication,
_sparse_dot_dense
and_sparse_dot_sparse
check whether the result is zero and take a shortcut. However, if theout
parameter is specified, this shortcut will just return the output matrix unchanged instead of setting it to zero.Edit: Basically, the
out_scalar
parameter is completely ignored.Second edit: Actually, there's another issue due to the inconsistent way in which output arrays are handled.
spmm
does not accept anout
parameter, so correctly an exception is thrown if one is provided.spmmd
does allow for one; however, it always acts as ifout_scalar=0
(so the defaultNone
corresponds to0
in this case). sparse_dot just ignores theout_scalar
parameter.sparse_?_mm
andsparse_?_mv
also allows for the output, and this case theout_scalar
is converted using_mkl_scalar
, i.e., the defaultNone
corresponds to1
in this case. I think there are only two ways to resolve this inconsistency in the generaldot_product_mkl
interface:out_scalar
different fromNone
or0
in thespmmd
case and throw an exception, plus add this to the documentation.out_scalar
fromNone
to0
and add the exception conditioned on it not being0
.The text was updated successfully, but these errors were encountered: