From 2f65d50001563669bbdf4ed3e6ddf63afc7b1dbb Mon Sep 17 00:00:00 2001
From: "Xue, Zhan" <zhan.xue@intel.com>
Date: Wed, 25 Jun 2025 18:24:56 +0800
Subject: [PATCH] Fix ambiguous boolean evaluation in bert.py

Signed-off-by: Xue, Zhan <zhan.xue@intel.com>
---
 python/llm/src/ipex_llm/transformers/models/bert.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/python/llm/src/ipex_llm/transformers/models/bert.py b/python/llm/src/ipex_llm/transformers/models/bert.py
index 2f1c4f5630e..95002c063d7 100644
--- a/python/llm/src/ipex_llm/transformers/models/bert.py
+++ b/python/llm/src/ipex_llm/transformers/models/bert.py
@@ -119,7 +119,7 @@ def encoder_forward(
     output_hidden_states: Optional[bool] = False,
     return_dict: Optional[bool] = True,
 ):
-    if attention_mask and not attention_mask.any():
+    if attention_mask is not None and not attention_mask.any():
         attention_mask = None
     return BertEncoder.forward(
         self=self,