Skip to content

Commit

Permalink
Rename
Browse files Browse the repository at this point in the history
Signed-off-by: DarkLight1337 <[email protected]>
  • Loading branch information
DarkLight1337 committed Dec 30, 2024
1 parent e7aa0f1 commit 642dcc2
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion vllm/model_executor/models/llava.py
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ def apply(
result = super().apply(prompt_text, mm_data, hf_processor_mm_kwargs)

mm_items = self._to_mm_items(mm_data)
mm_item_counts = mm_items.get_item_counts()
mm_item_counts = mm_items.get_all_counts()
mm_kwargs = result["mm_kwargs"]

# We reimplement the functionality of MLlavaProcessor from
Expand Down
2 changes: 1 addition & 1 deletion vllm/model_executor/models/phi3v.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ def get_replacement_phi3v(item_idx: int):

return [_IMAGE_TOKEN_ID] * num_tokens + [bos_token_id]

num_images = mm_items.get_item_count("image", strict=False)
num_images = mm_items.get_count("image", strict=False)

return [
PromptReplacement(
Expand Down
4 changes: 2 additions & 2 deletions vllm/multimodal/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ class MultiModalDataItems(UserDict[str, ModalityDataItems[Any, Any]]):
corresponds to a list.
"""

def get_item_count(self, modality: str, *, strict: bool = True) -> int:
def get_count(self, modality: str, *, strict: bool = True) -> int:
"""
Get the number of data items belonging to a modality.
Expand All @@ -186,7 +186,7 @@ def get_item_count(self, modality: str, *, strict: bool = True) -> int:

return self[modality].get_count()

def get_item_counts(self) -> Mapping[str, int]:
def get_all_counts(self) -> Mapping[str, int]:
"""Get the number of items belonging to each modality."""
return {m: items.get_count() for m, items in self.items()}

Expand Down
8 changes: 4 additions & 4 deletions vllm/multimodal/processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ def _apply_hf_processor_missing(
cached items; instead, we rely on our own prompt replacement logic
for the full text.
"""
mm_missing_counts = mm_missing_data_items.get_item_counts()
mm_missing_counts = mm_missing_data_items.get_all_counts()

prompt_ids, _ = self._apply_hf_processor(
prompt_text=prompt_text,
Expand Down Expand Up @@ -844,7 +844,7 @@ def _cached_apply_hf_processor(
mm_merged_field_items[modality] = merged_modal_items_lst

if self.enable_sanity_checks:
mm_missing_counts = mm_missing_data_items.get_item_counts()
mm_missing_counts = mm_missing_data_items.get_all_counts()
assert all(
item_count == mm_missing_counts[modality]
for modality, item_count in mm_missing_next_idx.items()), dict(
Expand All @@ -857,7 +857,7 @@ def _cached_apply_hf_processor(
)

if self.enable_sanity_checks:
mm_item_counts = mm_data_items.get_item_counts()
mm_item_counts = mm_data_items.get_all_counts()

for modality, item_count in mm_item_counts.items():
for item_idx in range(item_count):
Expand Down Expand Up @@ -967,7 +967,7 @@ def apply(

# If HF processor already inserts placeholder tokens,
# there is no need for us to insert them
mm_item_counts = mm_items.get_item_counts()
mm_item_counts = mm_items.get_all_counts()
all_placeholders = self._find_placeholders(prompt_repls, prompt_ids,
mm_item_counts)

Expand Down

0 comments on commit 642dcc2

Please sign in to comment.