KEMBAR78
Improve performance of canonicalize_bool_expr by isuruf · Pull Request #135621 · pytorch/pytorch · GitHub
Skip to content

Conversation

@isuruf
Copy link
Collaborator

@isuruf isuruf commented Sep 10, 2024

[ghstack-poisoned]
@pytorch-bot
Copy link

pytorch-bot bot commented Sep 10, 2024

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/135621

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit d71d51a with merge base b7eb725 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

"""
def integer_coefficient(x):
if isinstance(x, sympy.Integer):
if x.is_Integer:
Copy link
Contributor

Choose a reason for hiding this comment

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

It's surprising to me that the attribute test is faster than isinstance; is this because there's some metaclass shenanigans in sympy or something?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

isinstance is slow regardless of metaclass complexity. If you know you have a sympy.Expr, attribute test is faster.

[ghstack-poisoned]
elif isinstance(x, sympy.Mul):
return math.prod([abs(int(arg)) for arg in x.args if isinstance(arg, sympy.Integer)])
elif x.is_Mul:
return abs(int(x.args[0])) if x.args[0].is_Integer else 1
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess your point here is that if there are multiple integral factors they're guaranteed to have already been folded

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yep. Added a comment mentioning this.

Copy link
Contributor

@ezyang ezyang left a comment

Choose a reason for hiding this comment

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

Not sure why tests are failing though

[ghstack-poisoned]
pytorchmergebot pushed a commit that referenced this pull request Sep 11, 2024
Pull Request resolved: #135622
Approved by: https://github.com/ezyang
ghstack dependencies: #135621
pytorchmergebot pushed a commit that referenced this pull request Sep 11, 2024
Pull Request resolved: #135652
Approved by: https://github.com/ezyang
ghstack dependencies: #135621, #135622
yushangdi pushed a commit that referenced this pull request Sep 12, 2024
yushangdi pushed a commit that referenced this pull request Sep 12, 2024
Pull Request resolved: #135622
Approved by: https://github.com/ezyang
ghstack dependencies: #135621
yushangdi pushed a commit that referenced this pull request Sep 12, 2024
Pull Request resolved: #135652
Approved by: https://github.com/ezyang
ghstack dependencies: #135621, #135622
tolleybot pushed a commit to tolleybot/pytorch that referenced this pull request Sep 14, 2024
tolleybot pushed a commit to tolleybot/pytorch that referenced this pull request Sep 14, 2024
tolleybot pushed a commit to tolleybot/pytorch that referenced this pull request Sep 14, 2024
Chao1Han pushed a commit to Chao1Han/pytorch that referenced this pull request Sep 20, 2024
Chao1Han pushed a commit to Chao1Han/pytorch that referenced this pull request Sep 20, 2024
Chao1Han pushed a commit to Chao1Han/pytorch that referenced this pull request Sep 20, 2024
@github-actions github-actions bot deleted the gh/isuruf/82/head branch October 12, 2024 02:07
KnAwnime pushed a commit to KnAwnime/Biblioteka that referenced this pull request Oct 16, 2024
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.

4 participants