Skip to content

Commit

Permalink
fix old version compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
eaidova committed Sep 27, 2024
1 parent 2fb59ce commit 96d8de4
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions optimum/intel/openvino/modeling_visual_language.py
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,7 @@ def merge_vision_text_embeddings(
inputs_embeds = torch.from_numpy(inputs_embeds) if isinstance(inputs_embeds, np.ndarray) else inputs_embeds
if legacy_processing is None:
legacy_processing = (
hasattr(self.config, "image_seq_len") and
(input_ids == self.config.image_token_index).sum(1).max() < self.config.image_seq_length
) or (input_ids.shape[-1] == 1)

Expand Down Expand Up @@ -842,6 +843,7 @@ def get_multimodal_embeddings(
self, input_ids, pixel_values=None, attention_mask=None, position_ids=None, past_key_values=None, **kwargs
):
legacy_processing = (
hasattr(self.config, "image_seq_len") and
(input_ids == self.config.image_token_index).sum(1).max() < self.config.image_seq_length
) or (input_ids.shape[-1] == 1 and pixel_values is not None)
inputs_embeds, attention_mask, position_ids = super().get_multimodal_embeddings(
Expand Down Expand Up @@ -961,6 +963,7 @@ def get_multimodal_embeddings(
inputs_embeds = self.get_text_embeddings(input_ids, **kwargs)

legacy_processing = (
hasattr(self.config, "image_seq_len") and
(input_ids == self.config.image_token_index).sum(1).max() < self.config.image_seq_length
) or (input_ids.shape[-1] == 1 and pixel_values is not None)
if pixel_values is not None and pixel_values.size(0) > 0:
Expand Down

0 comments on commit 96d8de4

Please sign in to comment.