Skip to content

Update script to find optimizers that potentially need supported opset updates#12330

Merged
skottmckay merged 8 commits intomasterfrom
skottmckay/UpdateOptimizerOpsetVersionCheckScript
Aug 3, 2022
Merged

Update script to find optimizers that potentially need supported opset updates#12330
skottmckay merged 8 commits intomasterfrom
skottmckay/UpdateOptimizerOpsetVersionCheckScript

Conversation

@skottmckay
Copy link
Contributor

Description:

Update to handle multiline declarations for the kernels which are typical these days.
Update to new path for the cpu contrib_op kernel registrations.

Motivation and Context
Fix helper to find optimizers that need updating.

…ical these days.

Update to new path for the cpu contrib_op kernel registrations.
justinchuby
justinchuby previously approved these changes Aug 1, 2022
@justinchuby
Copy link
Contributor

Hi @skottmckay sorry I just left a nit passing by - would you like me to review and approve or do you have reviewers in mind?

@skottmckay
Copy link
Contributor Author

Hi @skottmckay Scott McKay FTE sorry I just left a nit passing by - would you like me to review and approve or do you have reviewers in mind?

Thanks for the comment. I'm happy for you to review. It's a fairly simple change to a helper script we can manually run when the ONNX version is updated.

# look for new match
start = line.find(function_or_declaration)
if start != -1:
cur_line = line
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it make sense to store from where the function starts to save the need for cur_line.find(function_or_declaration)? This way we can do cur_line[len(function_or_declaration): end] and be rid of the pyright error "find" is not a known member of "None"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to store from the '(' so a find isn't needed when appending to results.

if start != -1:
cur_line = line
# include the '(' in case that is the last character in the line
current_args = line[start:].strip()
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like find returns the start position of the substring. line[start:] will include function_or_declaration as well. is this intended?

>>> "abcd".find("bc")
1

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. The script works but only as the first argument wasn't used in the calling code. Reworked it to be a bit more explicit.

have_all_args = cur_line and end != -1
have_all_args = current_args and end != -1

if have_all_args:
Copy link
Contributor

Choose a reason for hiding this comment

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

I would add assert current_args to make the type checker happy

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reworked it so it doesn't complain.

Not a fan of random statement to make a checker happy. That imposes a maintenance cost of wasted time as each developer that sees that line wonders why there's such a meaningless check, potentially removes it as it's just noise, finds the invalid pyright complaint, and changes it back.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks! This is even better

@lgtm-com
Copy link

lgtm-com bot commented Aug 2, 2022

This pull request introduces 1 alert when merging b7a251e into 5d1173f - view on LGTM.com

new alerts:

  • 1 for Variable defined multiple times

@lgtm-com
Copy link

lgtm-com bot commented Aug 2, 2022

This pull request introduces 1 alert when merging 4837a50 into 5d1173f - view on LGTM.com

new alerts:

  • 1 for Variable defined multiple times

have_all_args = cur_line and end != -1
have_all_args = current_args and end != -1

if have_all_args:
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks! This is even better

justinchuby
justinchuby previously approved these changes Aug 2, 2022
@skottmckay skottmckay merged commit a3de1bb into master Aug 3, 2022
@skottmckay skottmckay deleted the skottmckay/UpdateOptimizerOpsetVersionCheckScript branch August 3, 2022 21:37
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.

2 participants