MCPcopy Create free account
hub / github.com/alibaba/euler / _ScatterMaxGrad

Function _ScatterMaxGrad

tf_euler/python/euler_ops/mp_ops.py:53–62  ·  view source on GitHub ↗
(op, grad)

Source from the content-addressed store, hash-verified

51
52@tf.RegisterGradient('MPScatterMax')
53def _ScatterMaxGrad(op, grad):
54 updates = op.inputs[0]
55 indices = op.inputs[1]
56 size = op.inputs[2]
57 out = op.outputs[0]
58 indicators = tf.equal(updates, gather(out, indices))
59 indicators = tf.cast(indicators, updates.dtype)
60 num_selected = scatter_add(indicators, indices, size)
61 indicators = indicators / gather(num_selected, indices)
62 return [indicators * gather(grad, indices), None, None]
63
64
65def scatter_mean(updates, indices, size=None):

Callers

nothing calls this directly

Calls 1

scatter_addFunction · 0.85

Tested by

no test coverage detected