Skip to content

Commit 294858f

Browse files
[Fix] support stride and speed up (#3414)
* support stride and speed up * refine
1 parent 85f03fe commit 294858f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

paddleseg/models/losses/ohem_cross_entropy_loss.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,10 @@ def forward(self, logit, label):
7676
threshold = self.thresh
7777
if self.min_kept > 0:
7878
index = prob.argsort()
79-
threshold_index = index[min(len(index), self.min_kept) - 1]
79+
if hasattr(paddle.Tensor, "contiguous"):
80+
threshold_index = index[min(len(index), self.min_kept) - 1].contiguous()
81+
else:
82+
threshold_index = index[min(len(index), self.min_kept) - 1]
8083
threshold_index = int(threshold_index)
8184
if prob[threshold_index] > self.thresh:
8285
threshold = prob[threshold_index]

0 commit comments

Comments
 (0)