supports_inplace_updates#
- ivy.supports_inplace_updates(x, /)[source]#
Return if in-place operations are supported for x’s data type.
Determine whether in-place operations are supported for x’s data type, by the current backend framework setting.
- Parameters:
x (
Union
[Array
,NativeArray
]) – Input variable for whose data type we check whether the current backend framework supports in-place operations.- Return type:
bool
- Returns:
ret – Value depends on whether in-place operations are supported for data type of x.
- Raises:
IvyException – If x isn’t a class instance of ivy.Array or ivy.NativeArray, an exception will be raised.
This function is nestable, and therefore also accepts :code:'ivy.Container' –
instance in place of the argument. –
Examples
With
ivy.Array
input and default backend set as numpy:>>> x = ivy.array([0, 1, 2]) >>> y = ivy.supports_inplace_updates(x) >>> print(y) True
With
ivy.Container
input and backend set as torch:>>> x = ivy.Container(a=ivy.array([5., 6.]), b=ivy.array([7., 8.])) >>> y = ivy.supports_inplace_updates(x) >>> print(y) { a: True, b: True }
With ivy.Array input and backend set as “tensorflow”:
>>> x = ivy.array([1., 4.2, 2.2]) >>> ret = x.supports_inplace_updates() >>> print(ret) False
- Array.supports_inplace_updates(self, /)[source]#
ivy.Array instance method variant of ivy.supports_inplace_updates. This method simply wraps the function, and so the docstring for ivy.supports_inplace_updates also applies to this method with minimal changes.
- Parameters:
self (
Array
) – The input array whose elements’ data type is to be checked.- Return type:
bool
- Returns:
ret – Bool value depends on whether the currently active backend framework supports in-place operations with argument’s data type.
Examples
With
ivy.Array
input and default backend set as numpy:>>> x = ivy.array([0, 1, 2]) >>> ret = x.supports_inplace_updates() >>> print(ret) True
With ivy.Array input and backend set as “tensorflow”:
>>> x = ivy.array([1., 4.2, 2.2]) >>> ret = x.supports_inplace_updates() >>> print(ret) False
- Container.supports_inplace_updates(self, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#
ivy.Container instance method variant of ivy.supports_inplace_updates. This method simply wraps the static function, and so the docstring for the static variant also applies to this method with minimal changes.
- Parameters:
self (
Container
) – An ivy.Container whose elements are data types supported by Ivy.key_chains (
Optional
[Union
[List
[str
],Dict
[str
,str
],Container
]], default:None
) – The key-chains to apply or not apply the method to. Default isNone
.to_apply (
Union
[bool
,Container
], default:True
) – If True, the method will be applied to key_chains, otherwise key_chains will be skipped. Default isTrue
.prune_unapplied (
Union
[bool
,Container
], default:False
) – Whether to prune key_chains for which the function was not applied. Default isFalse
.map_sequences (
Union
[bool
,Container
], default:False
) – Whether to also map method to sequences (lists, tuples). Default isFalse
.
- Return type:
Container
- Returns:
ret – An ivy.Container instance of bool values. True if nodes of the Container support in-place operations. False otherwise.
Examples
With
ivy.Container
input and backend set as torch:>>> x = ivy.Container(a=ivy.array([5., 6.]), b=ivy.array([7., 8.])) >>> ret = x.supports_inplace_updates() >>> print(ret) { a: True, b: True }
With
ivy.Container
input and backend set as jax:>>> x = ivy.Container(a=ivy.array([5.]), b=ivy.array([7.])) >>> ret = x.supports_inplace_updates() >>> print(ret) { a: False, b: False }