diff --git a/python/paddle/fluid/variable_index.py b/python/paddle/fluid/variable_index.py index dcbb7d7fb47735089bb151cd8998c36139c94594..a0a778759b0300f0b6165aa1f4525b07e86322b6 100644 --- a/python/paddle/fluid/variable_index.py +++ b/python/paddle/fluid/variable_index.py @@ -315,8 +315,8 @@ def get_value_for_bool_tensor(var, item): return paddle.empty(var_shape, dtype=var.dtype) from .layers.control_flow import cond - return cond(paddle.logical_not(item.any()), lambda: idx_empty(var), - lambda: idx_not_empty(var, item)) + return cond(item.any(), lambda: idx_not_empty(var, item), + lambda: idx_empty(var)) def _getitem_impl_(var, item):