def sg_float(tensor, opt):
    r"""Casts a tensor to floatx.
    
    See `tf.cast()` in tensorflow.

    Args:
      tensor: A `Tensor` or `SparseTensor` (automatically given by chain).
      opt:
        name : If provided, it replaces current tensor's name

    Returns:
      A `Tensor` or `SparseTensor` with same shape as `tensor`.
    """
    return tf.cast(tensor, tf.sg_floatx, name=opt.name)
r"""Casts a tensor to floatx.
    
    See `tf.cast()` in tensorflow.

    Args:
      tensor: A `Tensor` or `SparseTensor` (automatically given by chain).
      opt:
        name : If provided, it replaces current tensor's name

    Returns:
      A `Tensor` or `SparseTensor` with same shape as `tensor`.