MCPcopy Create free account
hub / github.com/RozDavid/UnScene3D / NestedTensor

Class NestedTensor

models/misc.py:25–45  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23
24
25class NestedTensor(object):
26 def __init__(self, tensors, mask: Optional[Tensor]):
27 self.tensors = tensors
28 self.mask = mask
29
30 def to(self, device):
31 # type: (Device) -> NestedTensor # noqa
32 cast_tensor = self.tensors.to(device)
33 mask = self.mask
34 if mask is not None:
35 assert mask is not None
36 cast_mask = mask.to(device)
37 else:
38 cast_mask = None
39 return NestedTensor(cast_tensor, cast_mask)
40
41 def decompose(self):
42 return self.tensors, self.mask
43
44 def __repr__(self):
45 return str(self.tensors)
46
47
48def nested_tensor_from_tensor_list(tensor_list: List[Tensor]):

Callers 3

toMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected