From f1b4e4d5439b52beedf243c57fba5aed840196a7 Mon Sep 17 00:00:00 2001 From: zyfncg Date: Tue, 7 Jun 2022 15:40:51 +0800 Subject: [PATCH] fix the problem of slice infer shape (#42568) (#43246) --- 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 257ddc96d9c87..c61e19036ccec 100644 --- a/python/paddle/fluid/variable_index.py +++ b/python/paddle/fluid/variable_index.py @@ -306,8 +306,9 @@ def idx_empty(var): 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):