MCPcopy Create free account
hub / github.com/chenhaoxing/DiffusionInst / NestedTensor

Class NestedTensor

diffusioninst/util/misc.py:287–307  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

285
286
287class NestedTensor(object):
288 def __init__(self, tensors, mask: Optional[Tensor]):
289 self.tensors = tensors
290 self.mask = mask
291
292 def to(self, device):
293 # type: (Device) -> NestedTensor # noqa
294 cast_tensor = self.tensors.to(device)
295 mask = self.mask
296 if mask is not None:
297 assert mask is not None
298 cast_mask = mask.to(device)
299 else:
300 cast_mask = None
301 return NestedTensor(cast_tensor, cast_mask)
302
303 def decompose(self):
304 return self.tensors, self.mask
305
306 def __repr__(self):
307 return str(self.tensors)
308
309
310def nested_tensor_from_tensor_list(tensor_list: List[Tensor]):

Callers 3

toMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected