jax.lax.scatter_add#

jax.lax.scatter_add(operand, scatter_indices, updates, dimension_numbers, *, indices_are_sorted=False, unique_indices=False, mode=None)[源代码]#

Scatter-add 运算符。

包装 XLA 的 Scatter 运算符,其中使用加法来组合来自 operand 的更新和值。

scatter 的语义很复杂,并且其 API 在未来可能会更改。对于大多数用例,您应该首选 JAX 数组上的 jax.numpy.ndarray.at 属性,该属性使用熟悉的 NumPy 索引语法。

参数:
  • operand (ArrayLike) – 应用分散操作的数组。

  • scatter_indices (ArrayLike) – 一个数组,它给出了 operand 中每个 updates 中的更新应该应用到的索引。

  • updates (ArrayLike) – 应该分散到 operand 上的更新。

  • dimension_numbers (ScatterDimensionNumbers) – 一个 lax.ScatterDimensionNumbers 对象,描述了 operandscatter_indicesupdates 和输出的维度如何关联。

  • indices_are_sorted (bool) – scatter_indices 是否已知是已排序的。如果为 true,可能会提高某些后端的性能。

  • unique_indices (bool) – operand 中要更新的元素是否保证彼此不重叠。如果为 true,可能会提高某些后端的性能。JAX 不会检查此承诺:如果当 unique_indicesTrue 时,更新的元素重叠,则行为是未定义的。

  • mode (str | GatherScatterMode | None | None) – 如何处理越界索引:当设置为 ‘clip’ 时,索引会被钳制,以便切片在边界内;当设置为 ‘fill’ 或 ‘drop’ 时,会丢弃越界更新。当设置为 ‘promise_in_bounds’ 时,越界索引的行为是实现定义的。

返回:

一个包含 operand 和分散更新的总和的数组。

返回类型:

Array