MCPcopy Create free account
hub / github.com/InternRobotics/G2VLM / masked_max

Function masked_max

eval_code/recons/models/moge/utils3d/torch/utils.py:307–313  ·  view source on GitHub ↗

Similar to torch.max, but with mask

(input: torch.Tensor, mask: torch.BoolTensor, dim: int = None, keepdim: bool = False)

Source from the content-addressed store, hash-verified

305
306
307def masked_max(input: torch.Tensor, mask: torch.BoolTensor, dim: int = None, keepdim: bool = False) -> Union[torch.Tensor, Tuple[torch.Tensor, torch.Tensor]]:
308 """Similar to torch.max, but with mask
309 """
310 if dim is None:
311 return torch.where(mask, input, torch.tensor(-torch.inf, dtype=input.dtype, device=input.device)).max()
312 else:
313 return torch.where(mask, input, torch.tensor(-torch.inf, dtype=input.dtype, device=input.device)).max(dim=dim, keepdim=keepdim)
314
315
316def bounding_rect(mask: torch.BoolTensor):

Callers 1

bounding_rectFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected