[Multimodal] Avoid extra d2d for encoder cudagraph with fused input norm (#56711)

Signed-off-by: Isotr0py <Isotr0py@outlook.com>
This commit is contained in:
Isotr0py
2026-09-28 21:04:01 +08:00
committed by GitHub
parent 7ba3df63cb
commit 522101f6ed
4 changed files with 29 additions and 6 deletions
@@ -195,6 +195,10 @@ class IdentityInputNorm(nn.Module):
``visual_dtype`` here.
"""
@property
def input_dtype(self) -> torch.dtype | None:
return None
def forward(
self, pixel_values: torch.Tensor, visual_dtype: torch.dtype
) -> torch.Tensor:
@@ -251,6 +255,10 @@ class FusedMMInputNorm(CustomOp):
self.register_buffer("weight", (rescale_factor / std).to(device))
self.register_buffer("bias", (-mean / std).to(device))
@property
def input_dtype(self) -> torch.dtype | None:
return torch.uint8
# ------------------------------------------------------------------
# Internal helpers shared by the platform-specific forward_* methods
# ------------------------------------------------------------------