From c1e45a114e05a221288052701c0026b7d2d51811 Mon Sep 17 00:00:00 2001 From: zyfncg Date: Sat, 7 May 2022 18:53:23 +0800 Subject: [PATCH] fix the problem of slice infer shape (#42568) --- python/paddle/fluid/variable_index.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/python/paddle/fluid/variable_index.py b/python/paddle/fluid/variable_index.py index 83a569aacc9..7d1bbf8162c 100644 --- a/python/paddle/fluid/variable_index.py +++ b/python/paddle/fluid/variable_index.py @@ -306,8 +306,9 @@ def get_value_for_bool_tensor(var, item): return paddle.empty(var_shape, dtype=var.dtype) from .layers.control_flow import cond - return cond(item.any(), lambda: idx_not_empty(var, item), - lambda: idx_empty(var)) + return cond( + paddle.logical_not(item.any()), lambda: idx_empty(var), + lambda: idx_not_empty(var, item)) def _getitem_impl_(var, item): -- GitLab