aesara.tensor.inc_subtensor#
- 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
ornp.add.at(x, indices, y)
, depending on the value ofignore_duplicates
.- Parameters:
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
andy
to be views of a single underlying array even while working in-place. For correct results,x
andy
must not be overlapping views; if they overlap, the result of thisOp
will generally be incorrect. This value has no effect ifinplace=False
.ignore_duplicates – This determines whether or not
x[indices] += y
is used ornp.add.at(x, indices, y)
. When the special duplicates handling ofnp.add.at
isn’t required, setting this option toTrue
(i.e. usingx[indices] += y
) can resulting in faster compiled graphs.
Examples
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)