move the batch to device Args: device (torch.device, str): torch device Returns: DataProto: the current DataProto
(self, device)
| 314 | return cls(batch=tensor_dict, non_tensor_batch=non_tensors, meta_info=meta_info) |
| 315 | |
| 316 | def to(self, device) -> 'DataProto': |
| 317 | """move the batch to device |
| 318 | |
| 319 | Args: |
| 320 | device (torch.device, str): torch device |
| 321 | |
| 322 | Returns: |
| 323 | DataProto: the current DataProto |
| 324 | |
| 325 | """ |
| 326 | if self.batch is not None: |
| 327 | self.batch = self.batch.to(device) |
| 328 | return self |
| 329 | |
| 330 | def select(self, batch_keys=None, non_tensor_batch_keys=None, meta_info_keys=None, deepcopy=False) -> 'DataProto': |
| 331 | """Select a subset of the DataProto via batch_keys and meta_info_keys |
no outgoing calls