diff --git a/src/transformers/tokenization_utils_base.py b/src/transformers/tokenization_utils_base.py index beff5ed2f4..91966ba319 100644 --- a/src/transformers/tokenization_utils_base.py +++ b/src/transformers/tokenization_utils_base.py @@ -781,7 +781,7 @@ class BatchEncoding(UserDict): # This check catches things like APEX blindly calling "to" on all inputs to a module # Otherwise it passes the casts down and casts the LongTensor containing the token idxs # into a HalfTensor - if isinstance(device, str) or isinstance(device, torch.device): + if isinstance(device, str) or isinstance(device, torch.device) or isinstance(device, int): self.data = {k: v.to(device=device) for k, v in self.data.items()} else: logger.warning(