MCPcopy Create free account
hub / github.com/OpenDriveLab/ReSim / NestedTensor

Class NestedTensor

SwissArmyTransformer/examples/yolos/util/misc.py:283–303  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 3

toMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected