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 | None) – 如何处理越界索引:当设置为 ‘clip’ 时,索引将被钳制,以便切片在界限内;当设置为 ‘fill’ 或 ‘drop’ 时,越界更新将被删除。当设置为 ‘promise_in_bounds’ 时,越界索引的行为是实现定义的。
- 返回:
一个数组,包含在给定索引处将 func 应用于 operand 的结果。
- 返回类型: