marko1616 commited on
Commit
f44b5e1
1 Parent(s): e190b08

Update modeling_chatglm.py

Browse files

Should not get a new attention_mask while images is empty.

Files changed (1) hide show
  1. modeling_chatglm.py +1 -1
modeling_chatglm.py CHANGED
@@ -976,7 +976,7 @@ class ChatGLMForConditionalGeneration(ChatGLMPreTrainedModel):
976
  # only last token for input_ids if past is not None
977
  if position_ids is None:
978
  position_ids = self.get_position_ids(input_ids, device=input_ids.device)
979
- if attention_mask is not None:
980
  image_size: int = self.config.vision_config['image_size']
981
  patch_size: int = self.config.vision_config['patch_size']
982
  num_patches = (image_size // patch_size // 2) ** 2
 
976
  # only last token for input_ids if past is not None
977
  if position_ids is None:
978
  position_ids = self.get_position_ids(input_ids, device=input_ids.device)
979
+ if attention_mask is not None and not is_empty(images):
980
  image_size: int = self.config.vision_config['image_size']
981
  patch_size: int = self.config.vision_config['patch_size']
982
  num_patches = (image_size // patch_size // 2) ** 2