codeislife99 commented on a change in pull request #7126:
URL: https://github.com/apache/tvm/pull/7126#discussion_r550279440
##########
File path: python/tvm/relay/op/transform.py
##########
@@ -1320,3 +1320,83 @@ def adv_index(inputs):
Output tensor.
"""
return _make.adv_index(Tuple(inputs))
+
+
+def sparse_fill_empty_rows(sparse_indices, sparse_values, dense_shape,
default_value):
+ """
+ Fill first column of the empty rows with default values for a sparse array.
+ It returns a TupleWrapper with four outputs
+
+ Parameters
+ ----------
+ sparse_indices : relay.Expr
+ A 2-D tensor[N, n_dim] of integers containing location of sparse
values, where N is the
+ number of sparse values and n_dim is the number of dimensions of the
dense_shape
+
+ sparse_values : relay.Expr
+ A 1-D tensor[N] containing the sparse values for the sparse indices.
+
+ dense_shape : relay.Expr
+ A list of integers. Shape of the dense output tensor.
+
+ default_value : relay.Expr
+ A 0-D tensor containing the default value for the remaining locations.
+ Defaults to 0.
+
+ Returns
+ -------
+ new_sparse_indices : relay.Expr
+ A 2-D tensor[N + dense_shape[0], n_dim] of integers containing
location of new sparse
+ indices where N is the number of sparse values. It is filled with -1
at irrelevant indices
+ which will be sliced in a future op discarding non-useful elements.
This is done since the
+ real rows of new_sparse_indices depends on the input.
+
+ empty_row_indicator : relay.Expr
+ A 1-D Boolean tensor[dense_shape[0]] indicating whether the particular
row is empty
+
+ new_sparse_values : relay.Expr
+ A 1-D tensor[dense_shape[0]] containing the sparse values for the
sparse indices. It is
+ filled with -1 at to_be_discarded indices
Review comment:
Done.
----------------------------------------------------------------
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]