Skip to content

Fix AdvancedIncSubtensor1 C-compilation with empty indices #1551

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

Merged
merged 1 commit into from
Jul 25, 2025

Conversation

ricardoV94
Copy link
Member

@ricardoV94 ricardoV94 commented Jul 25, 2025

Can't take the min of an empty index. This Op is useless, but depending on how the graph is build / optimizations done, there are no guarantees it will be removed.


📚 Documentation preview 📚: https://pytensor--1551.org.readthedocs.build/en/1551/

@ricardoV94 ricardoV94 added bug Something isn't working C-backend indexing labels Jul 25, 2025
idx_may_be_neg = not (
# Empty idx needs no negative checks
idx_.type.shape[0] == 0
or (isinstance(idx_, Constant) and idx_.data.min() >= 0)
Copy link
Member Author

Choose a reason for hiding this comment

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

we always have static shape for constants, so the check above precludes taking the min of an empty array, which was the original bug

Copy link

codecov bot commented Jul 25, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.49%. Comparing base (12213d0) to head (8379c5a).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1551   +/-   ##
=======================================
  Coverage   81.49%   81.49%           
=======================================
  Files         232      232           
  Lines       53122    53122           
  Branches     9444     9444           
=======================================
+ Hits        43292    43293    +1     
  Misses       7382     7382           
+ Partials     2448     2447    -1     
Files with missing lines Coverage Δ
pytensor/tensor/subtensor.py 89.98% <100.00%> (ø)

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ricardoV94 ricardoV94 merged commit bacdaf6 into pymc-devs:main Jul 25, 2025
74 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working C-backend indexing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants