[NPU] Fix glm 4.6v (#29381)

This commit is contained in:
zhaozx-cn
2026-07-01 15:13:48 +08:00
committed by GitHub
parent 40594bd381
commit 721350656d
@@ -8,8 +8,6 @@ This patch restructures the computation to stay within 8 dimensions, following
the same pattern as the Qwen VL NPU patch.
"""
from typing import Optional
import torch
import torchvision.transforms.v2.functional as tvF
from transformers.image_processing_utils import BatchFeature
@@ -42,7 +40,7 @@ def npu_wrapper_glm46v_preprocess(func):
images: list["torch.Tensor"],
do_resize: bool,
size: SizeDict,
interpolation: Optional["tvF.InterpolationMode"],
resample: "PILImageResampling | tvF.InterpolationMode | int | None",
do_rescale: bool,
rescale_factor: float,
do_normalize: bool,
@@ -74,7 +72,7 @@ def npu_wrapper_glm46v_preprocess(func):
stacked_images = self.resize(
stacked_images,
size=SizeDict(height=resized_height, width=resized_width),
interpolation=interpolation,
resample=resample,
)
resized_images_grouped[shape] = stacked_images
@@ -161,7 +159,7 @@ def npu_wrapper_glm46v_video_preprocess(func):
do_convert_rgb: bool = True,
do_resize: bool = True,
size: SizeDict | None = None,
interpolation: PILImageResampling = PILImageResampling.BICUBIC,
resample: "PILImageResampling | tvF.InterpolationMode | int | None" = PILImageResampling.BICUBIC,
do_rescale: bool = True,
rescale_factor: float = 1 / 255.0,
do_normalize: bool = True,
@@ -193,7 +191,7 @@ def npu_wrapper_glm46v_video_preprocess(func):
stacked_videos = self.resize(
stacked_videos,
size=SizeDict(height=resized_height, width=resized_width),
interpolation=interpolation,
resample=resample,
)
stacked_videos = stacked_videos.view(
B, T, C, resized_height, resized_width