MCPcopy Create free account
hub / github.com/Project-MONAI/MONAI / stack

Function stack

monai/transforms/utils_pytorch_numpy_unification.py:414–423  ·  view source on GitHub ↗

`np.stack` with equivalent implementation for torch. Args: x: array/tensor. dim: dimension along which to perform the stack (referred to as `axis` by numpy).

(x: Sequence[NdarrayTensor], dim: int)

Source from the content-addressed store, hash-verified

412
413
414def stack(x: Sequence[NdarrayTensor], dim: int) -> NdarrayTensor:
415 """`np.stack` with equivalent implementation for torch.
416
417 Args:
418 x: array/tensor.
419 dim: dimension along which to perform the stack (referred to as `axis` by numpy).
420 """
421 if isinstance(x[0], np.ndarray):
422 return np.stack(x, dim) # type: ignore
423 return torch.stack(x, dim) # type: ignore
424
425
426def mode(x: NdarrayTensor, dim: int = -1, to_long: bool = True) -> NdarrayTensor:

Callers 4

__call__Method · 0.90
convert_box_to_pointsFunction · 0.90
profile_ctxMethod · 0.85
__iter__Method · 0.85

Calls

no outgoing calls

Tested by 1

__call__Method · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…