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

Function _EagerPyFuncGrad

tensorflow/python/ops/script_ops.py:327–342  ·  view source on GitHub ↗

Computes the gradient of an EagerPyFunc.

(op, *dy)

Source from the content-addressed store, hash-verified

325# TODO(akshayka): Implement higher-order derivatives.
326@ops.RegisterGradient("EagerPyFunc")
327def _EagerPyFuncGrad(op, *dy):
328 """Computes the gradient of an EagerPyFunc."""
329
330 token = op.get_attr("token")
331
332 def eagerly_executed_grad(*dy):
333 tape, eager_inputs, eager_outputs = tape_cache.pop(compat.as_bytes(token))
334 return tape.gradient(eager_outputs, eager_inputs, output_gradients=dy)
335
336 with ops.control_dependencies(op.outputs):
337 return _internal_py_func(
338 func=eagerly_executed_grad,
339 inp=dy,
340 Tout=[tensor.dtype for tensor in op.inputs],
341 eager=True,
342 is_grad_func=True)
343
344
345@tf_export("py_function")

Callers

nothing calls this directly

Calls 3

_internal_py_funcFunction · 0.85
get_attrMethod · 0.45
control_dependenciesMethod · 0.45

Tested by

no test coverage detected