MCPcopy Index your code
hub / github.com/UX-Decoder/Semantic-SAM / NestedTensor

Class NestedTensor

semantic_sam/utils/misc.py:42–62  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

40 return maxes
41
42class NestedTensor(object):
43 def __init__(self, tensors, mask: Optional[Tensor]):
44 self.tensors = tensors
45 self.mask = mask
46
47 def to(self, device):
48 # type: (Device) -> NestedTensor # noqa
49 cast_tensor = self.tensors.to(device)
50 mask = self.mask
51 if mask is not None:
52 assert mask is not None
53 cast_mask = mask.to(device)
54 else:
55 cast_mask = None
56 return NestedTensor(cast_tensor, cast_mask)
57
58 def decompose(self):
59 return self.tensors, self.mask
60
61 def __repr__(self):
62 return str(self.tensors)
63
64def nested_tensor_from_tensor_list(tensor_list: List[Tensor]):
65 # TODO make this more general

Callers 3

toMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected