[NPU] Fix glm 4.6v (#29381)
This commit is contained in:
@@ -8,8 +8,6 @@ This patch restructures the computation to stay within 8 dimensions, following
|
|||||||
the same pattern as the Qwen VL NPU patch.
|
the same pattern as the Qwen VL NPU patch.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from typing import Optional
|
|
||||||
|
|
||||||
import torch
|
import torch
|
||||||
import torchvision.transforms.v2.functional as tvF
|
import torchvision.transforms.v2.functional as tvF
|
||||||
from transformers.image_processing_utils import BatchFeature
|
from transformers.image_processing_utils import BatchFeature
|
||||||
@@ -42,7 +40,7 @@ def npu_wrapper_glm46v_preprocess(func):
|
|||||||
images: list["torch.Tensor"],
|
images: list["torch.Tensor"],
|
||||||
do_resize: bool,
|
do_resize: bool,
|
||||||
size: SizeDict,
|
size: SizeDict,
|
||||||
interpolation: Optional["tvF.InterpolationMode"],
|
resample: "PILImageResampling | tvF.InterpolationMode | int | None",
|
||||||
do_rescale: bool,
|
do_rescale: bool,
|
||||||
rescale_factor: float,
|
rescale_factor: float,
|
||||||
do_normalize: bool,
|
do_normalize: bool,
|
||||||
@@ -74,7 +72,7 @@ def npu_wrapper_glm46v_preprocess(func):
|
|||||||
stacked_images = self.resize(
|
stacked_images = self.resize(
|
||||||
stacked_images,
|
stacked_images,
|
||||||
size=SizeDict(height=resized_height, width=resized_width),
|
size=SizeDict(height=resized_height, width=resized_width),
|
||||||
interpolation=interpolation,
|
resample=resample,
|
||||||
)
|
)
|
||||||
resized_images_grouped[shape] = stacked_images
|
resized_images_grouped[shape] = stacked_images
|
||||||
|
|
||||||
@@ -161,7 +159,7 @@ def npu_wrapper_glm46v_video_preprocess(func):
|
|||||||
do_convert_rgb: bool = True,
|
do_convert_rgb: bool = True,
|
||||||
do_resize: bool = True,
|
do_resize: bool = True,
|
||||||
size: SizeDict | None = None,
|
size: SizeDict | None = None,
|
||||||
interpolation: PILImageResampling = PILImageResampling.BICUBIC,
|
resample: "PILImageResampling | tvF.InterpolationMode | int | None" = PILImageResampling.BICUBIC,
|
||||||
do_rescale: bool = True,
|
do_rescale: bool = True,
|
||||||
rescale_factor: float = 1 / 255.0,
|
rescale_factor: float = 1 / 255.0,
|
||||||
do_normalize: bool = True,
|
do_normalize: bool = True,
|
||||||
@@ -193,7 +191,7 @@ def npu_wrapper_glm46v_video_preprocess(func):
|
|||||||
stacked_videos = self.resize(
|
stacked_videos = self.resize(
|
||||||
stacked_videos,
|
stacked_videos,
|
||||||
size=SizeDict(height=resized_height, width=resized_width),
|
size=SizeDict(height=resized_height, width=resized_width),
|
||||||
interpolation=interpolation,
|
resample=resample,
|
||||||
)
|
)
|
||||||
stacked_videos = stacked_videos.view(
|
stacked_videos = stacked_videos.view(
|
||||||
B, T, C, resized_height, resized_width
|
B, T, C, resized_height, resized_width
|
||||||
|
|||||||
Reference in New Issue
Block a user