fold#
- ivy.fold(x, /, mode, shape, *, out=None)[source]#
Refolds the mode-mode unfolding into a tensor of shape shape In other words, refolds the n-mode unfolded tensor into the original tensor of the specified shape.
- Parameters:
input – unfolded tensor of shape
(shape[mode], -1)mode (
int) – the mode of the unfoldingshape (
Union[Shape,NativeShape,Sequence[int]]) – shape of the original tensor before unfoldingout (
Optional[Array], default:None) – optional output array, for writing the result to.
- Return type:
- Returns:
ret – folded_tensor of shape shape
- Array.fold(self, /, mode, shape, *, out=None)[source]#
ivy.Array instance method variant of ivy.fold. This method simply wraps the function, and so the docstring for ivy.fold also applies to this method with minimal changes.
- Parameters:
input – unfolded tensor of shape
(shape[mode], -1)mode (
int) – the mode of the unfoldingshape (
Union[Shape,NativeShape,Sequence[int]]) – shape of the original tensor before unfoldingout (
Optional[Array], default:None) – optional output array, for writing the result to.
- Return type:
Array- Returns:
ret – folded_tensor of shape shape
- Container.fold(self, /, mode, shape, *, out=None)[source]#
ivy.Container instance method variant of ivy.fold.
This method simply wraps the function, and so the docstring for ivy.fold also applies to this method with minimal changes.
- Parameters:
self (
Container) – input tensor to be foldedmode (
Union[int,Container]) – indexing starts at 0, therefore mode is inrange(0, tensor.ndim)shape (
Union[Shape,NativeShape,Sequence[int],Container]) – shape of the original tensor before unfoldingout (
Optional[Container], default:None) – optional output container, for writing the result to. It must have a shape that the inputs broadcast to.------- –
ret – Container of folded tensors
- Return type:
Container