MCPcopy Index your code
hub / github.com/Project-MONAI/MONAI / set_array

Method set_array

monai/data/meta_tensor.py:372–392  ·  view source on GitHub ↗

Copies the elements from src into self tensor and returns self. The src tensor must be broadcastable with the self tensor. It may be of a different data type or reside on a different device. See also: `https://pytorch.org/docs/stable/generated/torch.Tensor.copy_.htm

(self, src, non_blocking: bool = False, *_args, **_kwargs)

Source from the content-addressed store, hash-verified

370 return convert_data_type(self, output_type=output_type, dtype=dtype, device=device, wrap_sequence=True)[0]
371
372 def set_array(self, src, non_blocking: bool = False, *_args, **_kwargs):
373 """
374 Copies the elements from src into self tensor and returns self.
375 The src tensor must be broadcastable with the self tensor.
376 It may be of a different data type or reside on a different device.
377
378 See also: `https://pytorch.org/docs/stable/generated/torch.Tensor.copy_.html`
379
380 Args:
381 src: the source tensor to copy from.
382 non_blocking: if True and this copy is between CPU and GPU, the copy may occur
383 asynchronously with respect to the host. For other cases, this argument has no effect.
384 _args: currently unused parameters.
385 _kwargs: currently unused parameters.
386 """
387 converted: torch.Tensor = convert_to_tensor(src, track_meta=False, wrap_sequence=True)
388 try:
389 return self.copy_(converted, non_blocking=non_blocking)
390 except RuntimeError: # skip the shape checking
391 self.data = converted
392 return self
393
394 @property
395 def array(self):

Callers 1

arrayMethod · 0.95

Calls 1

convert_to_tensorFunction · 0.90

Tested by

no test coverage detected