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

Function _TensorArrayWriteGrad

tensorflow/python/ops/tensor_array_grad.py:117–137  ·  view source on GitHub ↗

Gradient for TensorArrayWrite. Args: op: Forward TensorArrayWrite op. flow: Gradient `Tensor` flow to TensorArrayWrite. Returns: A grad `Tensor`, the gradient created in an upstream ReadGrad or PackGrad.

(op, flow)

Source from the content-addressed store, hash-verified

115@ops.RegisterGradient("TensorArrayWriteV2")
116@ops.RegisterGradient("TensorArrayWriteV3")
117def _TensorArrayWriteGrad(op, flow):
118 """Gradient for TensorArrayWrite.
119
120 Args:
121 op: Forward TensorArrayWrite op.
122 flow: Gradient `Tensor` flow to TensorArrayWrite.
123
124 Returns:
125 A grad `Tensor`, the gradient created in an upstream ReadGrad or PackGrad.
126 """
127 # handle is the output store_handle of TensorArrayReadGrad or
128 # the handle output of TensorArrayWriteGrad. we must use this one.
129 handle = op.inputs[0]
130 index = op.inputs[1]
131 dtype = op.get_attr("T")
132 grad_source = _GetGradSource(flow)
133 g = (tensor_array_ops.TensorArray(dtype=dtype, handle=handle, flow=flow,
134 colocate_with_first_write_call=False)
135 .grad(source=grad_source, flow=flow))
136 grad = g.read(index)
137 return [None, None, grad, flow]
138
139
140@ops.RegisterGradient("TensorArrayGather")

Callers

nothing calls this directly

Calls 5

_GetGradSourceFunction · 0.85
TensorArrayMethod · 0.80
get_attrMethod · 0.45
gradMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected