The gradient of scalar multiplication with NaN-suppression.
(op, grad)
| 1200 | |
| 1201 | @ops.RegisterGradient("MulNoNan") |
| 1202 | def _MulNoNanGrad(op, grad): |
| 1203 | """The gradient of scalar multiplication with NaN-suppression.""" |
| 1204 | x = op.inputs[0] |
| 1205 | y = op.inputs[1] |
| 1206 | if (isinstance(grad, ops.Tensor) and |
| 1207 | _ShapesFullySpecifiedAndEqual(x, y, grad)): |
| 1208 | return gen_math_ops.mul_no_nan(grad, y), gen_math_ops.mul_no_nan(x, grad) |
| 1209 | assert x.dtype.base_dtype == y.dtype.base_dtype, (x.dtype, " vs. ", y.dtype) |
| 1210 | sx = array_ops.shape(x) |
| 1211 | sy = array_ops.shape(y) |
| 1212 | rx, ry = gen_array_ops.broadcast_gradient_args(sx, sy) |
| 1213 | return (array_ops.reshape( |
| 1214 | math_ops.reduce_sum(gen_math_ops.mul_no_nan(grad, y), rx), sx), |
| 1215 | array_ops.reshape( |
| 1216 | math_ops.reduce_sum(gen_math_ops.mul_no_nan(x, grad), ry), sy)) |
| 1217 | |
| 1218 | |
| 1219 | @ops.RegisterGradient("Div") |
nothing calls this directly
no test coverage detected