Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ppocr/modeling/heads/rec_parseq_head.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ def forward_test(self, memory, max_length=None):
temp = paddle.triu(
x=paddle.ones(shape=[num_steps, num_steps], dtype="bool"), diagonal=2
)
posi = np.where(temp.cpu().numpy() == True)
posi = paddle.where(temp == True)
query_mask[posi] = 0
Comment on lines +368 to 369
Copy link

Copilot AI Nov 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The replacement of np.where with paddle.where is incorrect. When called with only a condition argument, np.where(condition) returns a tuple of arrays (one per dimension), while paddle.where(condition) returns a single tensor with shape [N, rank]. This breaks the indexing operation on line 369 query_mask[posi] = 0. Consider using paddle.nonzero(temp).T which returns indices in a format compatible with tuple-style indexing, or use paddle.nonzero(temp) and adjust the indexing accordingly.

Suggested change
posi = paddle.where(temp == True)
query_mask[posi] = 0
posi = paddle.nonzero(temp).T
query_mask[tuple(posi)] = 0

Copilot uses AI. Check for mistakes.
bos = paddle.full(shape=(bs, 1), fill_value=self.bos_id).astype("int64")
for i in range(self.refine_iters):
Expand Down
Loading