MCPcopy Create free account
hub / github.com/NVIDIA/TensorRT-LLM / patch_merger_forward

Function patch_merger_forward

tensorrt_llm/tools/multimodal_builder.py:1686–1693  ·  view source on GitHub ↗
(self, image_features, attention_mask)

Source from the content-addressed store, hash-verified

1684
1685 @torch.no_grad
1686 def patch_merger_forward(self, image_features, attention_mask):
1687 h, w = attention_mask.shape[-2:]
1688 bs, n, d = image_features.shape
1689 image_grid = image_features.view(bs, h, w, d).permute(0, 3, 1, 2)
1690 image_features = torch.nn.functional.unfold(image_grid, 2,
1691 stride=2).transpose(1, 2)
1692 image_features = self.merging_layer(image_features)
1693 return image_features
1694
1695 @torch.no_grad
1696 def mm_projector_forward(self, image_features, attention_mask):

Callers

nothing calls this directly

Calls 3

transposeMethod · 0.80
permuteMethod · 0.45
viewMethod · 0.45

Tested by

no test coverage detected