import torch


def to_gpu(x):
    """Place tensor on GPU (if available)
    """
    x = x.contiguous()

    if torch.cuda.is_available():
        x = x.cuda(non_blocking=True)

    return torch.autograd.Variable(x)