-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove extra dim in cpu mode at scatter #1282
Conversation
Signed-off-by: lizz <lizz@sensetime.com>
Codecov Report
@@ Coverage Diff @@
## master #1282 +/- ##
==========================================
- Coverage 68.42% 68.42% -0.01%
==========================================
Files 160 160
Lines 10610 10616 +6
Branches 1938 1940 +2
==========================================
+ Hits 7260 7264 +4
Misses 2975 2975
- Partials 375 377 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
@innerlee I tested mmdet and it will report an error for the following reasons: class Scatter:
@staticmethod
def forward(target_gpus, input):
input_device = get_input_device(input)
streams = None
if input_device == -1 and target_gpus != [-1]:
# Perform CPU to GPU copies in a background stream
streams = [_get_stream(device) for device in target_gpus]
# input shape=(1,3,100,100)
# outputs shape=(1,3,100,100)
outputs = scatter(input, target_gpus, streams)
# Synchronize with the copy stream
if streams is not None:
synchronize_stream(outputs, target_gpus, streams)
return tuple(outputs) # (3,100,100), Because the batch dimension is missing, subsequent inferences will report an error. |
@hhaAndroid do you know where the batch dim was added in gpu code? |
The collate function output of dataloader includes the batch dimension. |
Okay so we should make the behavior of collate consistent across cpu/gpu, right? |
No, your understanding is wrong. The |
Where is the extra dim added for gpu tensors? |
Sorry, I am late in replying, I will provide you with a detailed description document. |
Cool, if you got extra time, please take a look at this bug open-mmlab/mmocr#327. Checkout that branch and run this line https://github.com/open-mmlab/mmocr/pull/327/files#diff-2f44c053cce5ce1b42ec4cd7d50aca219b338cefe5aa8831813d6f4020fca740R14 |
hi @innerlee @hhaAndroid , is there any progress? |
Not really. Currently I do not have bandwidth to handle this issue. You may check if anyone in mmdet team want to take a look |
got it |
Solved by #1621 |
Motivation
Currently the cpu version of scatter will add an extra dim for tensors, which causes problems such as in open-mmlab/mmocr#327
Modification
Remove the extra dim
BC-breaking (Optional)
YES
Downstream repos might be affected. Please check mmdet, mmaction2 and mmpose before merge. Please check their tests and also demos in cpu mode.
Checklist