Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Added Steps support in DNN Slice layer#19546

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
alalek merged 3 commits intoopencv:3.4fromLupusSanctus:am/slice_steps
Mar 26, 2021

Conversation

@LupusSanctus
Copy link

@LupusSanctusLupusSanctus commentedFeb 16, 2021
edited by alalek
Loading

Merge with extra:opencv/opencv_extra#854

Fixes#18920: addedsteps parameter support for Slice layer

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or other license that is incompatible with OpenCV
  • The PR is proposed to proper branch
  • There is reference to original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake
force_builders=Custom,Custom Win,Custom Macbuild_image:Custom=ubuntu-openvino-2021.2.0:20.04build_image:Custom Win=openvino-2021.1.0build_image:Custom Mac=openvino-2021.2.0test_modules:Custom=dnn,python2,python3,javatest_modules:Custom Win=dnn,python2,python3,javatest_modules:Custom Mac=dnn,python2,python3,javabuildworker:Custom=linux-1# disabled due high memory usage: test_opencl:Custom=ONtest_opencl:Custom=OFFtest_bigdata:Custom=1test_filter:Custom=*

gurki and dmMaze reacted with heart emoji
@alalekalalek assignedsl-sergei and unassignedsl-sergeiFeb 20, 2021
@LupusSanctusLupusSanctusforce-pushed theam/slice_steps branch 2 times, most recently from96eaa99 toaf88ecfCompareFebruary 28, 2021 21:51
@LupusSanctus
Copy link
Author

@alalek, the code was corrected in accordance with comments. Is it needed to rebase this patch on 3.4 branch?

@alalek
Copy link
Member

Is it needed to rebase this patch on 3.4 branch

We will backport it separately later (there is some CUDA-specific code).

LupusSanctus reacted with thumbs up emoji

@asmorkalov
Copy link
Contributor

/cc@asenyaev

asenyaev reacted with thumbs up emoji

@LupusSanctusLupusSanctus changed the base branch frommaster to3.4March 9, 2021 20:41
@LupusSanctus
Copy link
Author

@alalek, rebased on 3.4 branch.

Copy link
Member

@alalekalalek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Thank you for update!

outputs[i][j] =normalize_axis_range(sliceRanges[i][j], inpShape[j]).size();

if (! sliceSteps.empty() && sliceSteps[i][j] >1)
outputs[i][j] = (outputs[i][j] + sliceSteps[i][j] -1) / sliceSteps[i][j];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Please add out of range checks forsliceSteps[i][j] access.

LupusSanctus reacted with thumbs up emoji
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@alalek, checks were added.

Comment on lines 627 to 630
if (dim +1 < dimsNum)
getSliceRecursive(inpMat, inpIdx, sliceRanges, sliceSteps, dim +1, dimsNum, outputs, outIdx);
else
outputs.at<float>(outIdx.data()) = inpMat.at<float>(inpIdx.data());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

IMHO, provided implementation is really slow.

I believe we should have optimized case for 2D (the last 2 dims) processing at least.

LupusSanctus reacted with thumbs up emoji
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@alalek, yes, but if it's ok with you, let's separate this optimization activity and implement it not in this scope.

Comment on lines 651 to 656
DictValuesteps_dict = layerParams.get("steps");
for (int i =0; i <steps_dict.size(); ++i)
{
if (steps.get<int>(i) !=1)
if (steps_dict.get<int>(i) !=1) {
CV_Error(Error::StsNotImplemented,
"Slice layer only supports steps = 1");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Do we want to support this case?

Copy link
Author

@LupusSanctusLupusSanctusMar 25, 2021
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@alalek, this case could be useful for opset9, which doesn't support step!=1, however, it means that initially onnx model could not be generated with step value != 1, hence, this check is useless.
Just in case, I've checked the model from theissue (which relates to the PR, where this code block was added), there is no step parameter (in opset9 slice layer "no step parameter" => step=1). Removed this code block.

Comment on lines 626 to 627
if (backend == DNN_BACKEND_OPENCV)
applyTestTag(target == DNN_TARGET_OPENCL ? CV_TEST_TAG_DNN_SKIP_OPENCL : CV_TEST_TAG_DNN_SKIP_OPENCL_FP16);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Implementation should fallback on CPU code instead of test skipping.

LupusSanctus reacted with thumbs up emoji
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@alalek, corrected.

@alalekalalek merged commit3e48a91 intoopencv:3.4Mar 26, 2021
@OlivierLDff
Copy link
Contributor

OlivierLDff commentedMar 26, 2021
edited
Loading

Hi, is there any plan to merge this in master?
I merged it in my fork to try to load yolov5 dnn. This work but i have different result in i run the inference on cpu or with cuda backend.
Have you tried CUDA backend with this and yolov5 model?
The result are coherent with OPENCV backend, but with CUDA result are a bit "off" and are scaled x2.
Should i open an issue, or is this something known?
Thanks for the great work.

@alalek
Copy link
Member

This patch will be merged to master, but without the CUDA part (CUDA code path will fallback on CPU - it works, but slow)

@OlivierLDff
Copy link
Contributor

Ok, is there any issue i can follow about this?
Why no CUDA? is there any plan? As you said CPU backend doesn't fit real time application.

@alalek
Copy link
Member

Fallback CUDA-CPU-CUDA is slow due to data transfers and synchronization points.

Currently CUDA optimizations are maintained by community, so feel free to propose a patch after the merge to master (wait for "(4.x) Merge 3.4" regular PR).

@alalekalalek mentioned this pull requestMar 27, 2021
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@dkurtdkurtdkurt left review comments

@alalekalalekalalek approved these changes

+1 more reviewer

@sl-sergeisl-sergeisl-sergei approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

@sl-sergeisl-sergei

Projects

None yet

Milestone

4.5.2

Development

Successfully merging this pull request may close these issues.

6 participants

@LupusSanctus@alalek@asmorkalov@OlivierLDff@dkurt@sl-sergei

[8]ページ先頭

©2009-2025 Movatter.jp