This repository has been archived by the owner on Mar 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reduce HungarianMatcher's space complexity.
The memory reduction factor of the cost matrix is sum(#target objects) / max(#target objects). That is achieved by no longer computing and storing matching costs between predictions and targets at different positions inside the batch. More exactly the original matrix of shape [batch_size * queries, sum(#target objects)] is shrinked to a tensor of shape [batch_size, queries, max(#target objects)]. Besides allowing much larger batch sizes, tested on the table structure recognition task using the Table Transformer (TATR) (125 queries, 7 classes) with pubmed data, this change also results a) on CUDA at all batch sizes and on CPU with small batchs in a small but meaningful speedup, b) on CPU with larger batch sizes in much higher speedups. The processing time decrease computed as (1 - new_time / old_time) is shown below in various configuration: Batch | Device size | cuda cpu ------------------ 1 8.2% 1.6% 2 1.6% 9.3% 3 1.6% 7.7% 4 0.9% 11.2% 5 0.8% 13.9% 6 0.9% 15.5% 7 0.9% 23.1% 8 47.1% 16 70.6% 32 88.3% 64 95.0%
- Loading branch information
1 parent
3af9fa8
commit eff320f
Showing
3 changed files
with
138 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters