-
-
Notifications
You must be signed in to change notification settings - Fork 55.6k
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
cv::cuda::reduce bug #6148
cv::cuda::reduce bug #6148
Conversation
Please tell whether this solves the problem or not. |
I am getting the following error ( buildbot ):
Can anyone tell me what it is? |
756bb84
to
cea37a4
Compare
I fixed that error. Please tell me whether this solves the problem or not. |
Please tell me whether it fixes the problem or not. |
@@ -101,7 +101,7 @@ namespace grid_reduce_to_vec_detail | |||
|
|||
__shared__ work_elem_type smem[cn][BLOCK_SIZE]; | |||
|
|||
const int y = blockIdx.x; | |||
const int y = blockIdx.x*cols; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In generic case dst
matrix will not be contiguous, so this index is not valid.
Original solution (dst.create(1, rows);
) was used to create contiguous matrix, so that it can be accessed by 1D index.
So, a simpler fix will be to transpose dst and return. Should I do that, or should I modify the code, so that it works for a columnar matrix? |
I guess, it will be better to use |
088678d
to
77707f8
Compare
Okay. I will do that. |
@@ -189,6 +189,7 @@ __host__ void gridReduceToColumn_(const SrcPtr& src, GpuMat_<ResType>& dst, cons | |||
shrinkPtr(mask), | |||
rows, cols, | |||
StreamAccessor::getStream(stream)); | |||
dst.reshape(dst.channels(), rows); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reshape
method creates new Mat object. You need to use something like dst = dst.reshape(...);
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops. Fixed that.
77707f8
to
41bfe8d
Compare
@@ -189,6 +189,7 @@ __host__ void gridReduceToColumn_(const SrcPtr& src, GpuMat_<ResType>& dst, cons | |||
shrinkPtr(mask), | |||
rows, cols, | |||
StreamAccessor::getStream(stream)); | |||
dst = dst.reshape(dst.channels(), rows); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please explicitly cast the reshape
result to GpuMat_
:
dst = GpuMat_<ResType>(dst.reshape(dst.channels(), rows));
Otherwise compilation fails.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ohh okay. Thanks for mentioning. Changed that and pushed.
41bfe8d
to
e3d3f90
Compare
Please fix failing tests:
|
e3d3f90
to
bbdd4b6
Compare
I think it is because GpuMat is not continuous. So I used |
@@ -183,12 +183,14 @@ __host__ void gridReduceToColumn_(const SrcPtr& src, GpuMat_<ResType>& dst, cons | |||
CV_Assert( getRows(mask) == rows && getCols(mask) == cols ); | |||
|
|||
dst.create(1, rows); | |||
cuda::createContinuous(rows, 1, dst.type(), dst); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case you need to remove dst.create
and dst.reshape
calls. They are redundant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah yeah. I got that. Made a final push. Hope this works :).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But, it is mentioned in the link below that the last param will change only if it has the same type and size. What does that mean? Should I create it and then createContinuous?
http://docs.opencv.org/2.4/modules/gpu/doc/data_structures.html#gpu-createcontinuous
bbdd4b6
to
cfdb3b5
Compare
The same tests still fails. You need to update the tests itself, since currently they are targeted for previous code version (with 1 x rows matrix). Please check |
All checks have passed. I didn't modify tests. How come none of the tests fail, as they are targeted for previous code version? Tell me what to do next. |
BTW, public buildbot doesn't run CUDA tests. You need to build and run them manually on your machine. |
Ohh okay. I will do that. Can you tell me where I can find the test scripts? |
There is command-line sample for test launch a few comments above |
cfdb3b5
to
1051349
Compare
Please tell me whether this fixes the problem or not. |
There is still failures in https://github.com/Itseez/opencv/blob/master/modules/cudaarithm/test/test_reductions.cpp#L880 |
What is the use of createMat with useRoi? It just creates the mat and chooses ROI of the given size after creation and returns it. |
Is this snippet fine? Or should I use false instead of useRoi. |
I think it will be better to remove
|
Okay. Should I do the same for CUDA_TEST_P(Reduce, Rows) ? Because I didn't modify any of reduce_to_row methods. |
No, only for CUDA_TEST_P(Reduce, Cols). |
b3db97d
to
c332a97
Compare
Please let me know if this fixes the problem. |
Now it fails with
|
c332a97
to
60891d9
Compare
I thought it is a problem with createContinuous. So I used reshape instead. But I have no idea why the output sizes don't match. Tell me if I am thinking in the right direction. |
No, |
Probably in that line : https://github.com/Itseez/opencv/blob/master/modules/cudaarithm/src/cuda/reduce.cu#L140 |
Ohh yeah. Found that. The functions are improperly wrapped. I will change that and push. |
33fe56f
to
f4d0a63
Compare
I am getting a build fail in Win 10 x64 VS2015. Please tell me what is the problem with my code. |
This failure is not related to this patch |
Ohh okay. Then what should I do? Should I leave it as it is and it will get fixed later? |
This build was restarted and completed successfully. |
Thanks :) |
Now it fails in sanity checks (
I think it will be better to reshape the output image back to 1 row matrix before sanity check: |
f4d0a63
to
c539f46
Compare
c539f46
to
f4f1561
Compare
Please let me know if this works fine. Or should I change anything else? |
Now it works OK. Thank you for your contribution! |
👍 |
Okay. Thanks for your guidance :) |
Fixes #6126.