ANSHUMAN87 commented on a change in pull request #7435:
URL: https://github.com/apache/tvm/pull/7435#discussion_r578600737
##########
File path: python/tvm/relay/op/nn/nn.py
##########
@@ -2148,6 +2148,39 @@ def sparse_transpose(x):
return expr.TupleWrapper(_make.sparse_transpose(x[0], x[1], x[2]), 3)
+# pylint: disable=no-else-return,inconsistent-return-statements
+def sparse_add(dense_mat, sparse_mat):
+ r"""
+ Computes the matrix addition of `dense_mat` and `sparse_mat`, where
`dense_mat` is
+ a dense matrix and `sparse_mat` is a sparse (either BSR or CSR) namedtuple
with
+ fields `data`, `indices`, and `indptr`.
+
+ .. math::
+
+ \mbox{sparse_add}(dense_mat, sparse_mat)[m, n] =
\mbox{add}(\mbox{as_dense}(S), (D))[m, n]
+
+ where `as_dense` returns dense equivalent of the given S(sparse matrix)
+ while performing addition with given D(dense matrix).
+
+ Parameters
+ ----------
+ dense_mat : tvm.relay.Expr
+ The input dense matrix for the matrix multiplication
+
+ sparse_mat : Union[namedtuple, Tuple[ndarray, ndarray, ndarray]].
+ The input sparse matrix for the matrix multiplication.
+
+ Returns
+ -------
+ result: tvm.relay.Expr
+ The computed result.
Review comment:
Okay i get it. I thought you were referring to operation examples :)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]