File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed
python/paddle/fluid/layers Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change 4949 'reorder_lod_tensor_by_rank' ,
5050 'ParallelDo' ,
5151 'Print' ,
52+ 'has_data' ,
5253]
5354
5455
@@ -1562,3 +1563,33 @@ def reorder_lod_tensor_by_rank(x, rank_table):
15621563 'RankTable' : [rank_table ]},
15631564 outputs = {'Out' : [out ]})
15641565 return out
1566+
1567+
1568+ def has_data (x , cond = None , ** ignored ):
1569+ """
1570+ **Less than**
1571+
1572+ This layer returns the truth value of whether the variable contains data.
1573+
1574+ Args:
1575+ x(Variable): Operand of *has_data*
1576+ cond(Variable|None): Optional output variable to store the result of *has_data*
1577+
1578+ Returns:
1579+ Variable: The tensor variable storing the output of *has_data*.
1580+
1581+ Examples:
1582+ .. code-block:: python
1583+
1584+ less = fluid.layers.has_data(x=label)
1585+ """
1586+ helper = LayerHelper ("has_data" , ** locals ())
1587+ if cond is None :
1588+ cond = helper .create_tmp_variable (dtype = 'bool' )
1589+ cond .stop_gradient = True
1590+
1591+ helper .append_op (
1592+ type = 'has_data' ,
1593+ inputs = {'X' : [x ]},
1594+ outputs = {'Out' : [cond ]})
1595+ return cond
You can’t perform that action at this time.
0 commit comments