Skip to content

Commit 71aff69

Browse files
authored
fix bugs on windows, default convert to int64 (PaddlePaddle#1016)
1 parent 398473b commit 71aff69

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

paddlenlp/taskflow/dependency_parsing.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -412,15 +412,15 @@ def convert_example(example, vocabs, fix_len=20):
412412
return [
413413
pad_sequence(
414414
[np.array(
415-
ids[:fix_len], dtype=int) for ids in words],
415+
ids[:fix_len], dtype=np.int64) for ids in words],
416416
fix_len=fix_len)
417417
]
418418

419419

420420
def flat_words(words, pad_index=0):
421421
mask = words != pad_index
422-
lens = np.sum(mask.astype(int), axis=-1)
423-
position = np.cumsum(lens + (lens == 0).astype(int), axis=1) - 1
422+
lens = np.sum(mask.astype(np.int64), axis=-1)
423+
position = np.cumsum(lens + (lens == 0).astype(np.int64), axis=1) - 1
424424
lens = np.sum(lens, -1)
425425
words = words.ravel()[np.flatnonzero(words)]
426426

@@ -433,7 +433,7 @@ def flat_words(words, pad_index=0):
433433

434434
max_len = words.shape[1]
435435

436-
mask = (position >= max_len).astype(int)
436+
mask = (position >= max_len).astype(np.int64)
437437
position = position * np.logical_not(mask) + mask * (max_len - 1)
438438
return words, position
439439

0 commit comments

Comments
 (0)