empty_like#

ivy.empty_like(x, /, *, dtype=None, device=None, out=None)[source]#

Return an uninitialized array with the same shape as an input array x.

Parameters:
  • x (Union[Array, NativeArray]) – input array from which to derive the output array shape.

  • dtype (Optional[Union[Dtype, NativeDtype]], default: None) – output array data type. If dtype is None, the output array data type must be inferred from x. Default: None.

  • device (Optional[Union[Device, NativeDevice]], default: None) – device on which to place the created array. If device is None, the output array device must be inferred from x. Default: None.

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

Return type:

Array

Returns:

ret – an array having the same shape as x and containing uninitialized data.

This function conforms to the Array API Standard. This docstring is an extension of the docstring in the standard.

Both the description and the type hints above assumes an array input for simplicity, but this function is nestable, and therefore also accepts ivy.Container instances in place of any of the arguments.

Array.empty_like(self, /, *, dtype=None, device=None, out=None)[source]#

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

Parameters:
  • self (Array) – input array from which to derive the output array shape.

  • dtype (Optional[Union[Dtype, NativeDtype]], default: None) – output array data type. If dtype is None, the output array data type must be inferred from self. Default: None.

  • device (Optional[Union[Device, NativeDevice]], default: None) – device on which to place the created array. If device is None, the output array device must be inferred from self. Default: None.

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

Return type:

Array

Returns:

ret – an array having the same shape as self and containing uninitialized data.

Container.empty_like(self, /, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, *, dtype=None, device=None, out=None)[source]#
Return type:

Container