MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / _reduce_sum_grad

Function _reduce_sum_grad

tensorflow/python/ops/nccl_ops.py:150–170  ·  view source on GitHub ↗

The gradients for input `Operation` of `reduce_sum`. Args: op: The `sum send` `Operation` that we are differentiating. grad: Gradient with respect to the output of the `reduce_sum` op. Returns: The gradient with respect to the input of `reduce_sum` op. Raises: LookupError: I

(op, grad)

Source from the content-addressed store, hash-verified

148
149@ops.RegisterGradient('NcclReduce')
150def _reduce_sum_grad(op, grad):
151 """The gradients for input `Operation` of `reduce_sum`.
152
153 Args:
154 op: The `sum send` `Operation` that we are differentiating.
155 grad: Gradient with respect to the output of the `reduce_sum` op.
156
157 Returns:
158 The gradient with respect to the input of `reduce_sum` op.
159
160 Raises:
161 LookupError: If the reduction attribute of op is not `sum`.
162 """
163 if op.get_attr('reduction') != b'sum':
164 raise LookupError('No gradient defined for NcclReduce except sum.')
165 _check_device(grad, expected=op.device)
166
167 with ops.device(op.device):
168 result = gen_nccl_ops.nccl_broadcast(input=grad, shape=grad.shape)
169
170 return [result] * len(op.inputs)
171
172
173def broadcast(tensor):

Callers

nothing calls this directly

Calls 3

_check_deviceFunction · 0.85
get_attrMethod · 0.45
deviceMethod · 0.45

Tested by

no test coverage detected