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

Remove useless SpecifyShape #885

Merged
merged 1 commit into from
Jul 8, 2024

Conversation

ricardoV94
Copy link
Member

@ricardoV94 ricardoV94 commented Jul 5, 2024

Description

With improvements in some Op static shape, I see an increase in redundant SpecifyShape that were introduced earlier on, but become irrelevant after more clever Ops were introduced or recreated.

This PR removes useless SpecifyShape when all the specified dims are already encoded in the static shape of the input.

Related Issue

  • Closes #
  • Related to #

Checklist

Type of change

  • New feature / enhancement
  • Bug fix
  • Documentation
  • Maintenance
  • Other (please specify):

Copy link

codecov bot commented Jul 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.00%. Comparing base (31bf682) to head (ac0dc48).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #885   +/-   ##
=======================================
  Coverage   81.00%   81.00%           
=======================================
  Files         170      170           
  Lines       46923    46939   +16     
  Branches    11497    11507   +10     
=======================================
+ Hits        38009    38025   +16     
  Misses       6704     6704           
  Partials     2210     2210           
Files Coverage Δ
pytensor/tensor/rewriting/shape.py 82.02% <100.00%> (+0.52%) ⬆️

Copy link
Member

@jessegrabowski jessegrabowski left a comment

Choose a reason for hiding this comment

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

LGTM

assert ret is None

# SpecifyShape is needed to raise mismatch between static and specified dim
out = ss(x, None, 5, 4)
Copy link
Member

Choose a reason for hiding this comment

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

Beyond the scope of this PR, but SpecifyShape could just eagerly raise in this case?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, there's also a config flag to raise during rewrites when shapes are found to be incompatible in the shape feature. But I don't see why not do it all the time.

Can you open an issue?

@ricardoV94 ricardoV94 merged commit e3d2750 into pymc-devs:main Jul 8, 2024
57 checks passed
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.

2 participants