jax.lax.scatter_apply#
- jax.lax.scatter_apply(operand, scatter_indices, func, dimension_numbers, *, update_shape=(), indices_are_sorted=False, unique_indices=False, mode=None)[source]#
Scatter-apply 运算符。
封装 XLA 的 Scatter 运算符,其中
operand
中的值被func(operand)
替换,重复索引会导致func
的多次应用。Scatter 的语义很复杂,其 API 将来可能会发生变化。 对于大多数用例,您应该首选 JAX 数组上的
jax.numpy.ndarray.at
属性,它使用熟悉的 NumPy 索引语法。请注意,在当前的实现中,
scatter_apply
与自动微分不兼容。- 参数:
operand (Array) – 应该应用 scatter 的数组
scatter_indices (Array) – 一个数组,给出了 operand 中要应用 updates 中每个更新的索引。
dimension_numbers (ScatterDimensionNumbers) – 一个 lax.ScatterDimensionNumbers 对象,描述了 operand、start_indices、updates 和输出的维度之间的关系。
update_shape (Shape) – 给定索引处的更新形状。
indices_are_sorted (bool) – 是否已知 scatter_indices 已排序。 如果为 true,则可能会提高某些后端上的性能。
unique_indices (bool) –
operand
中要更新的元素是否保证彼此不重叠。 如果为 true,则可能会提高某些后端上的性能。 JAX 不会检查此承诺:如果当unique_indices
为True
时,更新的元素重叠,则行为未定义。mode (str | GatherScatterMode | None) – 如何处理越界索引:当设置为“clip”时,索引将被钳制,以便切片在边界内,当设置为“fill”或“drop”时,越界更新将被删除。 当设置为“promise_in_bounds”时,越界索引的行为是实现定义的。
- 返回:
一个数组,包含在给定索引处将 func 应用于 operand 的结果。
- 返回类型: