Skip to content
fn

scatter_prod_op

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

Scatter with multiplicative reduction.

Math

out[i]=base[i]⋅∏j:idx[j]=isrc[j]. \text{out}[i] = \text{base}[i] \cdot \prod_{j : \text{idx}[j] = i} \text{src}[j] .

Parameters

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

Returns

TensorImplPtr

Same shape and dtype as base.

Notes

Each operand's gradient is grad at its position times the product of the other operands there — out / operand where the operand is not zero, and computed without that division where it is, so a zero operand gets the others' product rather than NaN.