Skip to content
fn

scatter_amax_op

→TensorImplPtr
int scatter_amax_op(const int & base, const int & indices, const int & src, int dim)

Scatter with element-wise max reduction at duplicate indices.

Math

At each output slot ii, the result is the maximum among base[i] and all src[j] with indices[j] == i.

See Also

scatter_amin_op : Same pattern with min reduction.

Parameters

base, indices, src, dim
Same semantics as scatter_add_op.

Returns

TensorImplPtr

Reduced tensor, same shape and dtype as base.

Notes

Backward flows only through "winning" elements: ∂/∂src[j]=grad[idx[j]]\partial / \partial \text{src}[j] = \text{grad}[\text{idx}[j]] when src[j]=out[idx[j]]\text{src}[j] = \text{out}[\text{idx}[j]], else 00; ∂/∂base[i]=grad[i]\partial / \partial \text{base}[i] = \text{grad}[i] when base[i]=out[i]\text{base}[i] = \text{out}[i], else 00. Ties distribute the gradient equally to all winners (matches the reference framework).