Skip to content

Commit 8ab6a84

Browse files
Apply suggestions from code review
Co-authored-by: Ilyas Moutawwakil <57442720+IlyasMoutawwakil@users.noreply.github.com>
1 parent c08b95d commit 8ab6a84

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

optimum/intel/openvino/modeling_visual_language.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1243,7 +1243,7 @@ def merge_vision_text_embeddings(
12431243

12441244
# Whether to turn off right padding
12451245
# 1. Create a mask to know where special image tokens are
1246-
special_image_token_mask = torch.tensor(input_ids == image_token_index)
1246+
special_image_token_mask = input_ids == image_token_index
12471247
# special_image_token_mask: [bsz, seqlen]
12481248
num_special_image_tokens = torch.sum(special_image_token_mask, dim=-1)
12491249
# num_special_image_tokens: [bsz]
@@ -1336,7 +1336,7 @@ def merge_vision_text_embeddings(
13361336
final_attention_mask |= image_to_overwrite
13371337
position_ids = (final_attention_mask.cumsum(-1) - 1).masked_fill_((final_attention_mask == 0), 1)
13381338
else:
1339-
special_image_mask = torch.tensor((input_ids == image_token_index)).unsqueeze(-1).expand_as(inputs_embeds)
1339+
special_image_mask = (input_ids == image_token_index).unsqueeze(-1).expand_as(inputs_embeds)
13401340
image_features = image_features.to(inputs_embeds.dtype)
13411341
final_embedding = inputs_embeds.masked_scatter(special_image_mask, image_features)
13421342
final_attention_mask = attention_mask

0 commit comments

Comments
 (0)