Skip to content
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

Reorganize contrib op schemas #10494

Merged
merged 16 commits into from
Feb 9, 2022
Merged

Reorganize contrib op schemas #10494

merged 16 commits into from
Feb 9, 2022

Conversation

snnn
Copy link
Member

@snnn snnn commented Feb 8, 2022

Description:

  1. Use ONNX_MS_OPERATOR_SET_SCHEMA macro to replace ONNX_CONTRIB_OPERATOR_SCHEMA. This is to keep consistent with modern ONNX code. It would be easier for us to copy/move operator definitions between ONNX and ONNX Runtime. See Enable non-static schema registration onnx/onnx#894 for why the new macro is better
  2. Put deprecated ONNX operators into a separated file. Currently contrib_defs.cc is too long. One function has thousands of lines.

This change will reduce binary size about 2KB for normal Windows build. It has no impact on ort minimal build.

Motivation and Context

  • Why is this change required? What problem does it solve?

Reduce usages of static variables. And reduce binary size.

  • If it fixes an open issue, please link to the issue here.

@yufenglee
Copy link
Member

ONNX_CONTRIB_OPERATOR_SCHEMA(MaxpoolWithMask)

why not use MACRO for those operators?


Refers to: onnxruntime/core/graph/contrib_ops/contrib_defs.cc:1539 in 53c1ed8. [](commit_id = 53c1ed8, deletion_comment = False)

@snnn
Copy link
Member Author

snnn commented Feb 8, 2022

@yufenglee , I'm unfamiliar with the operators. I can do it. Do you want me to do it?

onnxruntime/core/graph/contrib_ops/ms_opset.h Outdated Show resolved Hide resolved
@@ -3443,15 +2889,10 @@ It's an extension of Gelu. It takes the sum of input A and bias input B as the i
}
#endif

RegisterNhwcSchemas();
Copy link
Contributor

Choose a reason for hiding this comment

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

Does removing this provide any advantage? I thought it gave a nice way to see what contrib schemas are registered.

Copy link
Member Author

@snnn snnn Feb 9, 2022

Choose a reason for hiding this comment

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

Adding comments to ms_opset.h has the same effect. Currently we either register all the operators, or none of them. Splitting would be needed when we want to add a new macro to control which part of contrib ops should be registered. At this moment, it is not needed.

fn(GetOpSchema<ONNX_OPERATOR_SET_SCHEMA_CLASS_NAME(Microsoft, 1, NGramRepeatBlock)>());
fn(GetOpSchema<ONNX_OPERATOR_SET_SCHEMA_CLASS_NAME(Microsoft, 1, Pad)>());
fn(GetOpSchema<ONNX_OPERATOR_SET_SCHEMA_CLASS_NAME(Microsoft, 1, QAttention)>());
fn(GetOpSchema<ONNX_OPERATOR_SET_SCHEMA_CLASS_NAME(Microsoft, 1, QEmbedLayerNormalization)>());
Copy link
Member

@yufenglee yufenglee Feb 9, 2022

Choose a reason for hiding this comment

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

move those 2 to quant section? you may do it in next PR

Copy link
Member

@yufenglee yufenglee left a comment

Choose a reason for hiding this comment

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

:shipit:

@snnn snnn merged commit 7a2bf3c into master Feb 9, 2022
@snnn snnn deleted the snnn/schema branch February 9, 2022 17:31
@skottmckay
Copy link
Contributor

Does the parsing to disable kernels for a reduced ops build need updating? It looks for existing macro names, so https://github.com/microsoft/onnxruntime/blob/master/tools/ci_build/op_registration_utils.py may need updating.

@snnn
Copy link
Member Author

snnn commented Feb 9, 2022

@skottmckay I think it parses kernel registrations, not op schemas ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants