Thanks! It was an np.array that used np.uint8 for booleans and that got automatically converted into torch.uint8 later when doing var.to(device), var being this np.array of type np.uint8. It was hard to trace as the numpy array was saved off to H5PY file and I only loaded this array from file using dataloader. Converting from np.uint8 to np.bool before doing var.to(device) solved the problem.