aesara.tensor.inc_subtensor(x, y, inplace=False, set_instead_of_inc=False, tolerate_inplace_aliasing=False, ignore_duplicates=False)[source]#

Update the value of an indexed array by a given amount.

This is equivalent to x[indices] += y or, indices, y), depending on the value of ignore_duplicates.

  • x – The symbolic result of a Subtensor operation.

  • y – The amount by which to increment the array.

  • inplace – Don’t use. Aesara will do in-place operations itself, when possible.

  • set_instead_of_inc – If True, do a set_subtensor instead.

  • tolerate_inplace_aliasing – Allow x and y to be views of a single underlying array even while working in-place. For correct results, x and y must not be overlapping views; if they overlap, the result of this Op will generally be incorrect. This value has no effect if inplace=False.

  • ignore_duplicates – This determines whether or not x[indices] += y is used or, indices, y). When the special duplicates handling of isn’t required, setting this option to True (i.e. using x[indices] += y) can resulting in faster compiled graphs.


To replicate the expression r[10:] += 5:

..code-block:: python

r = ivector() new_r = inc_subtensor(r[10:], 5)

To replicate the expression r[[0, 1, 0]] += 5:

..code-block:: python

r = ivector() new_r = inc_subtensor(r[10:], 5, ignore_duplicates=True)