import torch


def to(input, dtype):
    """Convert input to dtype."""
    if dtype == 'long':
        dtype = torch.long
    elif dtype == 'uint8':
        dtype = torch.uint8
    elif dtype == 'float32':
        dtype = torch.float32
    return input.to(dtype)