get_tensor_from_selected_rows

paddle.fluid.layers.nn. get_tensor_from_selected_rows ( x, name=None ) [source]

This operator gets tensor data from input with SelectedRows type, and outputs a LoDTensor.

input x is SelectedRows:
   x.rows = [0, 5, 5, 4, 19]
   x.height = 20
   x.value = [[1, 1] [2, 2] [2, 2] [3, 3] [6, 6]]

Output is LoDTensor:
   out.shape = [5, 2]
   out.data = [[1, 1],
               [2, 2],
               [2, 2],
               [3, 3],
               [6, 6]]
Parameters
  • x (SelectedRows) – Input with SelectedRows type. The data type is float32, float64, int32 or int64.

  • name (str, optional) – The default value is None. Normally there is no need for user to set this property. For more information, please refer to Name .

Returns

LoDTensor transformed from SelectedRows. The data type is same with input.

Return type

Variable

Examples

import paddle.fluid as fluid
b = fluid.default_main_program().global_block()
input = b.create_var(name="X", dtype="float32", persistable=True, type=fluid.core.VarDesc.VarType.SELECTED_ROWS)
out = fluid.layers.get_tensor_from_selected_rows(input)