parameters: (op, grad)
return_statement: return array_ops.pad(grad, paddings), None, None
docstring: Gradient for Slice op.
docstring_summary: Gradient for Slice op.
docstring_tokens: Gradient for Slice op .
function: def _SliceGrad(op, grad):
    """Gradient for Slice op."""
    # Create an Nx2 padding where the first column represents how many
    # zeros are to be prepended for each dimension, and the second
    # column indicates how many zeros are appended.
    #
    # The number of zeros to append is the shape of the input
    # elementwise-subtracted by both the begin vector and sizes vector.
    #
    # Some more reshaping is needed to assemble this tensor with the
    # right dimensions.
    input_vec = op.inputs[0]
    begin_vec = op.inputs[1]
    input_rank = array_ops.rank(input_vec)
    slice_size = array_ops.shape(op.outputs[0])
  
    shape = array_ops.pack([input_rank, 1])
    before_pad = array_ops.reshape(begin_vec, shape)
    after_pad = array_ops.reshape(
        array_ops.shape(input_vec) - slice_size - begin_vec, shape)
    paddings = array_ops.concat(1, [before_pad, after_pad])
    return array_ops.pad(grad, paddings), None, None
function_tokens: def _SliceGrad ( op , grad ) : # Create an Nx2 padding where the first column represents how many # zeros are to be prepended for each dimension, and the second # column indicates how many zeros are appended. # # The number of zeros to append is the shape of the input # elementwise-subtracted by both the begin vector and sizes vector. # # Some more reshaping is needed to assemble this tensor with the # right dimensions. input_vec = op . inputs [ 0 ] begin_vec = op . inputs [ 1 ] input_rank = array_ops . rank ( input_vec ) slice_size = array_ops . shape ( op . outputs [ 0 ] ) shape = array_ops . pack ( [ input_rank , 1 ] ) before_pad = array_ops . reshape ( begin_vec , shape ) after_pad = array_ops . reshape ( array_ops . shape ( input_vec ) - slice_size - begin_vec , shape ) paddings = array_ops . concat ( 1 , [ before_pad , after_pad ] ) return array_ops . pad ( grad , paddings ) , None , None