partial_fold#

ivy.partial_fold(x, /, mode, shape, skip_begin=1, *, out=None)[source]#

Re-folds a partially unfolded tensor.

Parameters:
  • x (Union[Array, NativeArray]) – a partially unfolded tensor

  • mode (int) – indexing starts at 0, therefore mode is in range(0, tensor.ndim)

  • shape (Union[Shape, NativeShape, Sequence[int]]) – the shape of the original full tensor (including skipped dimensions)

  • skip_begin (int, default: 1) – number of dimensions left untouched at the beginning

  • out (Optional[Array], default: None) – optional output array, for writing the result to.

Return type:

Array

Returns:

ret – partially re-folded tensor

Array.partial_fold(self, /, mode, shape, skip_begin=1, *, out=None)[source]#

ivy.Array instance method variant of ivy.partial_fold. This method simply wraps the function, and so the docstring for ivy.partial_fold also applies to this method with minimal changes.

Parameters:
  • x – a partially unfolded tensor

  • mode (int) – indexing starts at 0, therefore mode is in range(0, tensor.ndim)

  • shape (Union[Shape, NativeShape, Sequence[int]]) – the shape of the original full tensor (including skipped dimensions)

  • skip_begin (Optional[int], default: 1) – number of dimensions left untouched at the beginning

  • out (Optional[Array], default: None) – optional output array, for writing the result to.

Return type:

Array

Returns:

partially re-folded tensor

Container.partial_fold(self, /, mode, shape, skip_begin=1, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

ivy.Container instance method variant of ivy.partial_fold.

This method simply wraps the function, and so the docstring for ivy.partial_fold also applies to this method with minimal changes.

Parameters:
  • self (Union[Array, NativeArray]) – a partially unfolded tensor

  • mode (Union[int, Container]) – indexing starts at 0, therefore mode is in range(0, tensor.ndim)

  • shape (Union[Shape, NativeShape, Sequence[int], Container]) – the shape of the original full tensor (including skipped dimensions)

  • skip_begin (Optional[Union[int, Container]], default: 1) – number of dimensions left untouched at the beginning

  • out (Optional[Container], default: None) – optional output container, for writing the result to. It must have a shape that the inputs broadcast to.

Return type:

Container

Returns:

ret – partially re-folded tensor