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

Function _gradient_function

tensorflow/python/eager/backprop.py:116–138  ·  view source on GitHub ↗

Calls the gradient function of the op. Args: op_name: the name of the op to be differentiated. attr_tuple: the attrs, as a tuple. num_inputs: the number of inputs to the op. inputs: inputs to the original operation. outputs: outputs to the original operation. out_grads: gr

(op_name, attr_tuple, num_inputs, inputs, outputs,
                       out_grads, skip_input_indices)

Source from the content-addressed store, hash-verified

114
115
116def _gradient_function(op_name, attr_tuple, num_inputs, inputs, outputs,
117 out_grads, skip_input_indices):
118 """Calls the gradient function of the op.
119
120 Args:
121 op_name: the name of the op to be differentiated.
122 attr_tuple: the attrs, as a tuple.
123 num_inputs: the number of inputs to the op.
124 inputs: inputs to the original operation.
125 outputs: outputs to the original operation.
126 out_grads: gradients of the operation wrt its outputs.
127 skip_input_indices: a tuple that is passed to the gradient function,
128 indicating which inputs to skip calculating the gradient for
129
130 Returns:
131 The gradients with respect to the inputs of the function, as a list.
132 """
133 mock_op = _MockOp(attr_tuple, inputs, outputs, op_name, skip_input_indices)
134 grad_fn = ops._gradient_registry.lookup(op_name) # pylint: disable=protected-access
135 if grad_fn is None:
136 return [None] * num_inputs
137
138 return grad_fn(mock_op, *out_grads)
139
140
141pywrap_tensorflow.TFE_Py_RegisterGradientFunction(_gradient_function)

Callers

nothing calls this directly

Calls 3

_MockOpClass · 0.85
grad_fnFunction · 0.70
lookupMethod · 0.45

Tested by

no test coverage detected