Skip to content

Unstrictify expr in the bounds inference in a single pass#8687

Closed
vksnk wants to merge 3 commits intomainfrom
vksnk/unstrict-one
Closed

Unstrictify expr in the bounds inference in a single pass#8687
vksnk wants to merge 3 commits intomainfrom
vksnk/unstrict-one

Conversation

@vksnk
Copy link
Member

@vksnk vksnk commented Jul 11, 2025

This is to address #8686.

There is a reproducer in a bug report, but I'm not sure what would be a good way to add it? just a correctness test and if it hangs it hangs?

@vksnk vksnk requested a review from abadams July 11, 2025 17:58
@abadams
Copy link
Member

abadams commented Jul 14, 2025

It bothers me that I don't understand why the existing behavior is exponential. I'm going to investigate more today

@abadams
Copy link
Member

abadams commented Jul 14, 2025

Ok I'm glad I investigated. This is not just a strict float problem - it's a problem with all pure intrinsics that get lowered in bounds inference, e.g. widening_add. The issue is that this line evaluates the bounds of the args: https://github.com/halide/Halide/blob/main/src/Bounds.cpp#L1211

But then later the intrinsic may get lowered into another form and then recursively reanalyzed, computing the bounds of the args again. If many pure intrinsics are nested, this has exponential complexity because you double the work at each call node.

abadams added a commit that referenced this pull request Jul 14, 2025
@vksnk vksnk closed this Jul 14, 2025
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