Gradient for TensorArrayConcat. Args: op: Forward TensorArrayConcat op. grad: Gradient `Tensor` to TensorArrayConcat. Returns: A flow `Tensor`, which can be used in control dependencies to force the write of `grad` to the gradient `TensorArray`.
(op, grad, unused_lengths_grad)
| 196 | @ops.RegisterGradient("TensorArrayConcatV2") |
| 197 | @ops.RegisterGradient("TensorArrayConcatV3") |
| 198 | def _TensorArrayConcatGrad(op, grad, unused_lengths_grad): |
| 199 | """Gradient for TensorArrayConcat. |
| 200 | |
| 201 | Args: |
| 202 | op: Forward TensorArrayConcat op. |
| 203 | grad: Gradient `Tensor` to TensorArrayConcat. |
| 204 | |
| 205 | Returns: |
| 206 | A flow `Tensor`, which can be used in control dependencies to |
| 207 | force the write of `grad` to the gradient `TensorArray`. |
| 208 | """ |
| 209 | # Note: the forward flow dependency in the call to grad() is necessary for |
| 210 | # the case of dynamic sized TensorArrays. When creating the gradient |
| 211 | # TensorArray, the final size of the forward array must be known. |
| 212 | # For this we need to wait until it has been created by depending on |
| 213 | # the input flow of the original op. |
| 214 | handle = op.inputs[0] |
| 215 | flow = op.inputs[1] |
| 216 | lengths = op.outputs[1] |
| 217 | dtype = op.get_attr("dtype") |
| 218 | grad_source = _GetGradSource(grad) |
| 219 | g = (tensor_array_ops.TensorArray(dtype=dtype, handle=handle, flow=flow, |
| 220 | colocate_with_first_write_call=False) |
| 221 | .grad(source=grad_source, flow=flow)) |
| 222 | u_g = g.split(grad, lengths=lengths) |
| 223 | # handle, flow_in |
| 224 | return [None, u_g.flow] |
| 225 | |
| 226 | |
| 227 | @ops.RegisterGradient("TensorArraySplit") |
nothing calls this directly
no test coverage detected