Skip to content

Split layer dispatch into functions in ONNXImporter#20453

Merged
alalek merged 5 commits intoopencv:3.4from
rogday:onnx_importer_fix
Jul 28, 2021
Merged

Split layer dispatch into functions in ONNXImporter#20453
alalek merged 5 commits intoopencv:3.4from
rogday:onnx_importer_fix

Conversation

@rogday
Copy link
Copy Markdown
Member

@rogday rogday commented Jul 23, 2021

I encountered strange behavior of model diagnostic tool when I was registering a custom layer: the tool indicated that the layer was probably missing, when we can know for sure; this change will enable easier debug and cleaner implementation of model diagnostics.

Pull Request Readiness Checklist

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

  • 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

@rogday rogday marked this pull request as draft July 23, 2021 12:19
@alalek
Copy link
Copy Markdown
Member

alalek commented Jul 23, 2021

Need to rebase to resolve conflicts after #20450

@rogday rogday marked this pull request as ready for review July 23, 2021 16:02
Copy link
Copy Markdown
Contributor

@asmorkalov asmorkalov left a comment

Choose a reason for hiding this comment

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

👍

typedef void (ONNXImporter::*ONNXImporterNodeParser)(LayerParams& layerParams, opencv_onnx::NodeProto node_proto);
typedef std::map<std::string, ONNXImporterNodeParser> DispatchMap;

void parseMaxPool (LayerParams& layerParams, opencv_onnx::NodeProto node_proto);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

opencv_onnx::NodeProto

"const reference" to avoid unnecessary objects copying.

Only some of handlers need local own instances to provide modifications (these code parts looks bad).

@alalek alalek merged commit cff0168 into opencv:3.4 Jul 28, 2021
@@ -62,7 +62,7 @@ class ONNXImporter
public:

ONNXImporter(Net& net, const char *onnxFile)
: dstNet(net)
: dstNet(net), dispatch(buildDispatchMap())
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We need PR to master branch with merge of these changes and "diagnostic run" mode.

@alalek alalek mentioned this pull request Jul 30, 2021
@rogday rogday deleted the onnx_importer_fix branch October 7, 2021 13:15
@alalek alalek mentioned this pull request Oct 15, 2021
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