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)
| 115 | @ops.RegisterGradient("TensorArrayWriteV2") |
| 116 | @ops.RegisterGradient("TensorArrayWriteV3") |
| 117 | def _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") |
nothing calls this directly
no test coverage detected