ONNX: upsample subgraph fusion added#16573
ONNX: upsample subgraph fusion added#16573alalek merged 1 commit intoopencv:3.4from ashishkrshrivastava:opencvonnx
Conversation
@dkurt , do both opencv and opencv_extra branches need to have same name ? |
|
@ashishkrshrivastava, by default yes. If you already have one - add it's name to PR description |
Here, In ONNX resize node example ROI is empty, and hence ONNX model can contain an empty constant node. I am getting an empty node when exporting pytorch model containing I think we can add some dummy data or can remove the node. [SOLVED] i have removed the node at finalize function. |
Please rebase patch on latest commits from 3.4 branch: ( looks like it conflicts with #16472 - also please split related "Resize" test on smaller parts ) |
Okay, thanks. Let me do that. |
|
@dkurt , I just encountered a problem while loading
Here, So, it is neither node nor output of some node, I guess. What do you suggest about it? |
|
@ashishkrshrivastava, I'd like to recommend to move it to separate issue / PR if you do not mind. |
@dkurt, Are you talking about moving only this issue to another issue/PR or everything ? |
|
okay. for these two issues we dont need to worry about softamx fusion. |
|
@ashishkrshrivastava, thank you! |
|
@dkurt , In issue 16475 Unet model is obtained using Pytorch version (1.3) while modifications in this PR are according to Pytorch version (1.4). should I make changes according to version 1.3 or it is fine to continue with version 1.4(latest) ? I am able to load Unet exported using version 1.4 with current modifications. |
|
@ashishkrshrivastava, If this PR can fix the issues - let's focus on current state. We need to be user oriented and if one have 1.4 version - we need to fix it here. |
| opencv_onnx::TensorProto tensor_proto = constant_node->attribute(0).t(); | ||
| nodes_attributes.push_back(getMatFromTensor(tensor_proto)); | ||
| } | ||
| } |
There was a problem hiding this comment.
Sequence of our subgraph is
Shape Constant Gather Cast Constant Mul Cast Floor Shape Constant Gather Cast Constant Mul Cast Floor Unsqueeze Unsqueeze
While matchedNodesIds contain vector ids of nodes
Shape Gather Cast Mul Cast Floor Shape Gather Cast Mul Cast Floor Unsqueeze Unsqueeze
i.e. without constant.
so this loop is searching for consant nodes that are missing from matchedNodeIds because we need to extract data from those constant nodes.
|
@ashishkrshrivastava excuse me, can u explain how can i use your fix in OpenCV 4.2.0 ? |
|
@BadMachine, you need to build OpenCV from source. The fix has been merged after OpenCV 4.2.0 |
|
@dkurt Thanks for your answer! PS: I know it should be in issue section, just for u know |
|
@BadMachine, Please do not use closed PRs for bug reports - open a new issue including build flags and error logs (but not a screenshot). |


Merge with extra: opencv/opencv_extra#707
resolves #16323
resolves #16475
resolves #14713
opencv_extra=opencvonnxPull Request Readiness Checklist
Patch to opencv_extra has the same branch name.
This PR adds
Subgraph fusion for

upsamplelayer when exported from pytorch 1.3If model is exported using pytorch 1.2, it does not produce two extra

castlayers afterGatherlayer.The additions I made are according to latest version of Pytorch.