Skip to content

Fuse Upsample from PyTorch 1.2 - #16710

Closed
dkurt wants to merge 1 commit into
opencv:3.4from
dkurt:dnn_upsample_pytorch_1.2
Closed

dkurt wants to merge 1 commit into
opencv:3.4from
dkurt:dnn_upsample_pytorch_1.2

Conversation

@dkurt

@dkurt dkurt commented Mar 1, 2020 •

Copy link
Copy Markdown
Member

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

resolves #16323
resolves #16660

Merge with extra: opencv/opencv_extra#716

  • I agree to contribute to the project under OpenCV (BSD) 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 Mac
build_image:Custom=ubuntu-openvino-2020.1.0:16.04
build_image:Custom Win=openvino-2020.1.0
build_image:Custom Mac=openvino-2020.1.0

test_modules:Custom=dnn,python2,python3,java
test_modules:Custom Win=dnn,python2,python3,java
test_modules:Custom Mac=dnn,python2,python3,java

buildworker:Custom=linux-1
# disabled due high memory usage: test_opencl:Custom=ON
test_opencl:Custom=OFF
test_bigdata:Custom=1
test_filter:Custom=*

@dkurt dkurt changed the title Fuse Upsample from Pytorch 1.2 Fuse Upsample from PyTorch 1.2 Mar 1, 2020
@dkurt
dkurt force-pushed the dnn_upsample_pytorch_1.2 branch from 4e91057 to d995d5f Compare March 1, 2020 16:22
@dkurt
dkurt force-pushed the dnn_upsample_pytorch_1.2 branch from d995d5f to 04c215f Compare March 1, 2020 17:08
@dkurt

dkurt commented Mar 1, 2020

Copy link
Copy Markdown
Member Author

@ashishkrshrivastava, please review this PR. It adds one more fusion in case of no Cast op in Upsample subgraph (#16323 (comment)) from PyTorch 1.2.

float scaleH = getMatFromTensor(tensor_proto).at<float>(0);
Mat scaleH = getMatFromTensor(tensor_proto);
CV_Assert(scaleH.total() == 1);
scaleH.convertTo(scaleH, CV_32F);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It was needed. graph created by Pytorch 1.2 has scales as int64 datatypes whereas Pytorch 1.4 has scales as float32.

@ashishkrshrivastava ashishkrshrivastava Mar 3, 2020 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@dkurt , these changes are needed to complete PR #16709 , so should I wait for this PR to get merged then I will rebase or I should add these changes to PR #16709 ?

subgraphs.push_back(makePtr<ResizeSubgraph2>(true));
subgraphs.push_back(makePtr<UpsampleSubgraph>(false));
subgraphs.push_back(makePtr<ResizeSubgraph1>(false));
subgraphs.push_back(makePtr<ResizeSubgraph2>(false));

@ashishkrshrivastava ashishkrshrivastava Mar 2, 2020 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If we deal Mul-cast according to these changes( Gather-cast) then we will have to check 12 subgraphs ?
for example -

subgraphs.push_back(makePtr<ResizeSubgraph2>(true, true));
subgraphs.push_back(makePtr<ResizeSubgraph2>(true, false));

And if we deal Mul-cast the way it is in PR #16709 and Gather-cast according to these changes then we would be doing similar thing in two different ways.
If you say, I can make changes in PR #16709 similar to this PR, otherwise maybe you can add changes for Mul-cast here in this PR similar to Gather-cast?

@dkurt dkurt mentioned this pull request Mar 3, 2020
6 tasks done
@dkurt dkurt closed this Mar 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants