Skip to content

Commit 2e487ed

Browse files
authored
Fix DataCollatorWithPadding for force transform into np.64 (#4861)
1 parent 093dd7e commit 2e487ed

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

paddlenlp/data/data_collator.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,10 @@ def __call__(self, features: List[Dict[str, Any]]) -> Dict[str, Any]:
204204
if "label_ids" in batch:
205205
batch["labels"] = batch["label_ids"]
206206
del batch["label_ids"]
207+
# To fix windows bug for paddle inference dtype error
208+
# InvalidArgumentError: The type of data we are trying to retrieve does not match the type of data currently contained in the container
209+
if self.return_tensors == "np":
210+
batch = {k: np.array(v, dtype=np.int64) for k, v in batch.items()}
207211
return batch
208212

209213

0 commit comments

Comments
 (0)