Why is one faster than another?

  Kiến thức lập trình

Slower
num_gt_lesions = len(torch.unique(gt_label_cc)[torch.unique(gt_label_cc) != 0])

Faster:

    num_gt_lesions = torch.unique(gt_label_cc)
    num_gt_lesions = len(num_gt_lesions[num_gt_lesions != 0])

the gt_label_cc is a connected components mask for a large 3d volume. It is slower by 0.2s on average.

Not sure why this is happening honestly.

LEAVE A COMMENT