|
| 1 | +SparseFillEmptyRows |
| 2 | +====================== |
| 3 | + |
| 4 | + |
| 5 | +.. meta:: |
| 6 | + :description: Learn about SparseFillEmptyRows-16 - a sparse operation, which |
| 7 | + can be performed on four required input tensors. |
| 8 | + |
| 9 | +**Versioned name**: *SparseFillEmptyRows-16* |
| 10 | + |
| 11 | +**Category**: *Sparse* |
| 12 | + |
| 13 | +**Short description**: Fills empty rows of an input sparse tensor with a default value. |
| 14 | + |
| 15 | +**Detailed description**: |
| 16 | + |
| 17 | +Operation SparseFillEmptyRows is an implementation of ``tf.raw_ops.SparseFillEmptyRows`` for 2D sparse tensors only. |
| 18 | + |
| 19 | +The input sparse tensor is represented by the three inputs: |
| 20 | + |
| 21 | +* ``indices`` |
| 22 | +* ``values`` |
| 23 | +* ``dense_shape`` |
| 24 | + |
| 25 | +For each row in the input 2D sparse tensor, this operator checks if the row is empty. If the row is empty, the operator adds an entry with the specified default value at index `[row, 0]`. The input may have empty columns at the end, which will not be affected by this operation. |
| 26 | + |
| 27 | +The output sparse tensor will be in row-major order and will have the same dense shape as the `dense_shape` input, but with updated `output_indices` and `output_values`. |
| 28 | + |
| 29 | +This operator also returns a boolean vector indicating which rows were filled with the default value: ``empty_row_indicator[i] = True`` if row ``i`` was an empty row. |
| 30 | + |
| 31 | +**Attributes**: SparseFillEmptyRows-16 operation has no attributes. |
| 32 | + |
| 33 | +**Inputs**: |
| 34 | + |
| 35 | +* **1**: ``values`` 1D tensor containing the values of type *T* to be inserted at the specified indices. **Required.** |
| 36 | +* **2**: ``dense_shape`` 1D tensor of type *T_IDX* indicating the shape of the 2D dense tensor. **Required.** |
| 37 | +* **3**: ``indices`` 2D tensor of type *T_IDX* and non-negative values indicating the positions at which ``values`` are placed in the sparse tensor. **Required.** |
| 38 | + It is of shape ``[M, 2]``, where: |
| 39 | + |
| 40 | + * ``M`` is the same as the length of the ``values`` input. |
| 41 | + * The second dimension is always 2, as only 2D sparse tensors are supported. |
| 42 | + |
| 43 | +* **4**: ``default_value`` a scalar of type *T* to be inserted into the empty rows. **Required.** |
| 44 | + |
| 45 | +**Outputs**: |
| 46 | + |
| 47 | +* **1**: ``output_indices`` 2D tensor of type *T_IDX* indicating the positions at which ``output_values`` are placed in the sparse tensor. |
| 48 | + It is of shape ``[M', 2]``, where: |
| 49 | + |
| 50 | + * ``M'`` is the length of the updated ``output_values``. |
| 51 | + * The second dimension is always 2, as only 2D sparse tensors are supported. |
| 52 | + |
| 53 | +* **2**: ``output_values`` 1D tensor containing the values of type *T* to be inserted at the specified indices. |
| 54 | +* **3**: ``empty_row_indicator`` 1D tensor of type ``boolean`` indicating True for rows which were empty before executing the operation. |
| 55 | + |
| 56 | +**Types** |
| 57 | + |
| 58 | +* *T*: any numeric type. |
| 59 | +* *T_IDX*: ``int32`` or ``int64``. |
| 60 | + |
| 61 | +**Example** |
| 62 | + |
| 63 | +*Example 1: sparse tensor input with shape [5, 6].* |
| 64 | + |
| 65 | +Input sparse tensor: |
| 66 | + |
| 67 | +* ``indices = [[0, 1], [0, 3], [2, 0], [3, 1]]`` |
| 68 | +* ``values = [a, b, c, d]`` |
| 69 | +* ``dense_shape = [5, 6]`` |
| 70 | + |
| 71 | +Rows 1 and 4 are empty. The output sparse tensor will be: |
| 72 | + |
| 73 | +* ``output_indices = [[0, 1], [0, 3], [1, 0], [2, 0], [3, 1], [4, 0]]`` |
| 74 | +* ``output_values = [a, b, default_value, c, d, default_value]`` |
| 75 | +* ``empty_row_indicator = [False, True, False, False, True]`` |
| 76 | + |
| 77 | +The output sparse tensor will be in row-major order and will have the same dense shape as the `dense_shape` input. |
| 78 | + |
| 79 | +.. code-block:: xml |
| 80 | +
|
| 81 | + <layer ... type="SparseFillEmptyRows" ... > |
| 82 | + <input> |
| 83 | + <port id="0" precision="FP32"> <!-- values are: [1, 3] --> |
| 84 | + <dim>2</dim> |
| 85 | + </port> |
| 86 | + <port id="1" precision="I32"> <!-- dense_shape value is: [3, 3] --> |
| 87 | + <dim>2</dim> |
| 88 | + </port> |
| 89 | + <port id="2" precision="I32"> <!-- indices value is: [[0, 0], [2, 2]] --> |
| 90 | + <dim>2</dim> |
| 91 | + <dim>2</dim> |
| 92 | + </port> |
| 93 | + <port id="3" precision="FP32"> <!-- default_value is: 42 --> |
| 94 | + <dim>0</dim> |
| 95 | + </port> |
| 96 | + </input> |
| 97 | + <output> |
| 98 | + <port id="4" precision="I32"> <!-- output_indices --> |
| 99 | + <dim>3</dim> |
| 100 | + <dim>2</dim> |
| 101 | + </port> |
| 102 | + <port id="5" precision="FP32"> <!-- output_values --> |
| 103 | + <dim>3</dim> |
| 104 | + </port> |
| 105 | + <port id="6" precision="BOOL"> <!-- empty_row_indicator --> |
| 106 | + <dim>3</dim> |
| 107 | + </port> |
| 108 | + </output> |
| 109 | + </layer> |
0 commit comments