def sg_pool1d(tensor, opt):
    r"""Performs the 1-D pooling on the `tensor`.
    
    Args:
      tensor: A 3-D `Tensor` (automatically passed by decorator).
      opt:
        size: A positive `integer` representing `[kernel width]`.
          Default is 2.
        stride: A positive `integer`. The number of entries by which
          the filter is moved right at each step. Default is 2.
        avg: Boolean. If True, average pooling is applied. Otherwise, max pooling.
        name: If provided, replace current tensor's name.

    Returns:
        A tensor

    """

    # default stride and pad
    opt += tf.sg_opt(stride=2, pad='VALID')
    opt += tf.sg_opt(size=opt.stride)

    if opt.avg:
        out = tf.nn.avg_pool(tensor.sg_expand_dims(axis=2),
                             (1, opt.size, 1, 1), (1, opt.stride, 1, 1), opt.pad)
    else:
        out = tf.nn.max_pool(tensor.sg_expand_dims(axis=2),
                             (1, opt.size, 1, 1), (1, opt.stride, 1, 1), opt.pad)

    return tf.identity(out.sg_squeeze(axis=2), name=opt.name)
r"""Performs the 1-D pooling on the `tensor`.
    
    Args:
      tensor: A 3-D `Tensor` (automatically passed by decorator).
      opt:
        size: A positive `integer` representing `[kernel width]`.
          Default is 2.
        stride: A positive `integer`. The number of entries by which
          the filter is moved right at each step. Default is 2.
        avg: Boolean. If True, average pooling is applied. Otherwise, max pooling.
        name: If provided, replace current tensor's name.

    Returns:
        A tensor