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
]]) – datatype, optional. Datatype is inferred from the input data. (default:None
)device (
Optional
[Union
[Device
,NativeDevice
]]) – device on which to place the created array. Default:None
. (default:None
)
- Return type:
NativeArray
- Returns:
ret – A native array interpretation of x.
Examples
With
List[Number]
input:>>> x = [1, 2, 3] >>> x_native = native_array(x) >>> print(x_native) [1. 2. 3.]
With
np.ndarray
input: >>> y = np.array([4, 5, 6]) >>> y_native = native_array(y) >>> print(y_native) [4. 5. 6.]With
ivy.Array
input: >>> z = ivy.array([7, 8, 9]) >>> z_native = native_array(z) >>> print(z_native) [7. 8. 9.]
- Array.native_array(self, /, *, dtype=None, device=None)#
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
]]) – datatype, optional. Datatype is inferred from the input data. (default:None
)device (
Optional
[Union
[Device
,NativeDevice
]]) – device on which to place the created array. Default:None
. (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)#
- Return type:
Container