From 24a2bedb7807bfbb6f2a2897da48425798b82213 Mon Sep 17 00:00:00 2001 From: Aurelius84 Date: Mon, 5 Sep 2022 17:17:01 +0800 Subject: [PATCH] [API] Fix slice bool infershape BUG (#45737) --- python/paddle/fluid/variable_index.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/paddle/fluid/variable_index.py b/python/paddle/fluid/variable_index.py index dcbb7d7fb4..a0a778759b 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): -- GitLab