-
-
Notifications
You must be signed in to change notification settings - Fork 55.9k
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
dnn: add more CANN operators to support SAM #23550
Conversation
…unsqueeze; support layernorm fusion variances; support getting 1d desc
@@ -20,11 +21,13 @@ class LayerNormLayerImpl CV_FINAL : public LayerNormLayer | |||
|
|||
// opencv attr | |||
hasBias = params.get<bool>("hasBias", false); | |||
is1D = params.get<bool>("is1D", false); |
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.
If I'm not mistaken, in case of 1D cv::Mat
it has N rows and 1 column (Nx1
). So with axis = 0
it should be correct. I think using such shortcut from MVN is enough:
opencv/modules/dnn/src/layers/mvn_layer.cpp
Lines 331 to 346 in 2ff16d4
if ( inpBlob.total() == newRows ) | |
{ | |
// MVN is applied to single values at an every row. | |
if (shift.empty()) | |
{ | |
outBlob.setTo(0); | |
} | |
else | |
{ | |
for ( i = 0; i < newRows; i++ ) | |
{ | |
outMat.row(i).setTo(((float*)shift.data)[i]); | |
} | |
} | |
return; | |
} |
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.
@dkurt, in 4.x there is no support for 1D. In 5.x I have added support for 1D and 0D matrices. 1D matrix of N elements may be interpreted (if you ignore Mat::dims) as 1xN 2D matrix, i.e. it's a single-row matrix, not single-column
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.
My point is that instead of extra is1D
flag there is a check that let skip layer compute because output values will be all zeros.
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.
The 1d flag is introduced for other backends to avoid incorrect shape inference. Let me try to bypass this...
Lets say axis=-1 and the shape of scale mat is still 2d; that stands for a 1d scale and bias tensor.
This PR is too out-of-date. Created a new PR #24756 in place of this one. |
What's about Mod layer?
|
Sure, let me do it in a new PR. |
This PR is based on #23491. Need to merge #23491 first then rebase this PR.
To-do list:
Pull Request Readiness Checklist
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.