set_inplace_mode#

ivy.set_inplace_mode(mode='lenient')[source]#

Set the memory management behavior for in-place updates in Ivy.

By default, Ivy creates new arrays in the backend for in-place updates. However, this behavior can be controlled by the user using the ‘inplace_mode’ parameter.

Parameters:

mode (str) –

The mode for memory management during in-place updates. - ‘lenient’: (Default) In this mode, new arrays will be created during

in-place updates to avoid breaking existing code. This is the default behavior.

  • ’strict’: In this mode, an error will be raised if the

    ’inplace_update’ function is called in a backend that doesn’t support inplace updates natively.

Return type:

None

Returns:

None

Examples

>>> set_inplace_mode('lenient')
>>> ivy.inplace_mode
'lenient'
>>> set_inplace_mode('strict')
>>> ivy.inplace_mode
'strict'

Note

Enabling strict mode can help users have more control over memory management but may lead to errors if the backend doesn’t support inplace updates natively.