native_array#

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

Convert the input to a native array.

Parameters:
  • x (Union[Array, NativeArray, List[Number], Tuple[Number], ndarray]) – input data, in any form that can be converted to an array. This includes lists, lists of tuples, tuples, tuples of tuples, tuples of lists and ndarrays.

  • dtype (Optional[Union[Dtype, NativeDtype]], default: None) – datatype, optional. Datatype is inferred from the input data.

  • device (Optional[Union[Device, NativeDevice]], default: None) – device on which to place the created array. Default: None.

Return type:

NativeArray

Returns:

ret – A native array interpretation of x.

Examples

With List[Number] input:

>>> x = [1, 2, 3]
>>> x_native = ivy.native_array(x)
>>> print(x_native)
[1 2 3]

With np.ndarray input: >>> y = np.array([4, 5, 6]) >>> y_native = ivy.native_array(y) >>> print(y_native) [4 5 6]

With ivy.Array input: >>> z = ivy.array([7, 8, 9]) >>> z_native = ivy.native_array(z) >>> print(z_native) [7 8 9]

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

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

Parameters:
  • self (Array) – input array.

  • dtype (Optional[Union[Dtype, NativeDtype]], default: None) – datatype, optional. Datatype is inferred from the input data.

  • device (Optional[Union[Device, NativeDevice]], default: None) – device on which to place the created array. Default: None.

Return type:

NativeArray

Returns:

ret – A native array interpretation of self.

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

Container