[Model][QwenVL] Replace torch.repeat_interleave with faster np.repeat (#28964)
Signed-off-by: Lukas Geiger <lukas.geiger94@gmail.com>
This commit is contained in:
@@ -128,12 +128,7 @@ def batch_make_image_embeddings(
|
||||
visual = model.visual
|
||||
|
||||
pixel_values_on_device = pixel_values.to(visual.device, dtype=visual.dtype)
|
||||
image_grid_thw_on_device = image_grid_thw.to(
|
||||
visual.device, dtype=torch.int64
|
||||
)
|
||||
return visual(
|
||||
pixel_values_on_device, grid_thw=image_grid_thw_on_device
|
||||
).cpu()
|
||||
return visual(pixel_values_on_device, grid_thw=image_grid_thw).cpu()
|
||||
|
||||
image_embeds = torch.concat(llm.apply_model(get_image_embeds))
|
||||
|
||||
@@ -217,12 +212,7 @@ def batch_make_video_embeddings(
|
||||
visual = model.visual
|
||||
|
||||
pixel_values_on_device = pixel_values.to(visual.device, dtype=visual.dtype)
|
||||
video_grid_thw_on_device = video_grid_thw.to(
|
||||
visual.device, dtype=torch.int64
|
||||
)
|
||||
return visual(
|
||||
pixel_values_on_device, grid_thw=video_grid_thw_on_device
|
||||
).cpu()
|
||||
return visual(pixel_values_on_device, grid_thw=video_grid_thw).cpu()
|
||||
|
||||
video_embeds = torch.concat(llm.apply_model(get_image_embeds))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user