Gradient for gather op.
(op, grad)
| 1874 | |
| 1875 | @ops.RegisterGradient("ResourceGather") |
| 1876 | def _GatherGrad(op, grad): |
| 1877 | """Gradient for gather op.""" |
| 1878 | # Build appropriately shaped IndexedSlices |
| 1879 | handle = op.inputs[0] |
| 1880 | indices = op.inputs[1] |
| 1881 | params_shape = variable_shape(handle) |
| 1882 | size = array_ops.expand_dims(array_ops.size(indices), 0) |
| 1883 | values_shape = array_ops.concat([size, params_shape[1:]], 0) |
| 1884 | values = array_ops.reshape(grad, values_shape) |
| 1885 | indices = array_ops.reshape(indices, size) |
| 1886 | return (ops.IndexedSlices(values, indices, params_shape), None) |
| 1887 | |
| 1888 | |
| 1889 | def _to_proto_fn(v, export_scope=None): |
nothing calls this directly
no test coverage detected