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

Support for elementary bounds inference #516

Open
skeqiqevian opened this issue Oct 6, 2023 · 0 comments
Open

Support for elementary bounds inference #516

skeqiqevian opened this issue Oct 6, 2023 · 0 comments
Assignees
Labels
C: Language The semantics of the language S: Available Available to be worked upon

Comments

@skeqiqevian
Copy link
Collaborator

For a particular scope of code, we would like to determine all the possible reads/writes that may be made. For example, in the following code snippet:

x: i8[N+1]
for io in seq(0, N/32):
  for ii in seq(0, 32):
    x[32*io + ii] = 0.0
    x[32*io + ii + 1] = 0.0

we would like to infer that within the ii loop, x is read at [32*io, 32*io + 32]. This functionality would be useful in

  • automating stage_mem so that we don't have to manually specify the window we want to stage.
  • implementing Halide's version of compute_root. Exo can currently implement very simple versions, but in general needs bounds inference to reasonably abstract.

I think Exo already has the capabilities to do this. The task can be reduced to bounding individual index expressions (32*io + ii) within a particular scope (the ii loop). Essentially, we want to decompose the index expression into base + offset component where base can't be bounded within integer constants, but offset can. In the example above, base = 32 * io and offset = ii, which we can bound to be in [0, 32). Our output is of the form [base + lo, base + hi).

This can be achieved by using liveness analysis to determine which index variables are defined outside of the scope (and hence we can't reason about) and which index variables are defined within the scope (and can be reasoned about). After that, we can leverage existing interval analysis from simplify to reason about the latter.

@skeqiqevian skeqiqevian added C: Language The semantics of the language S: Available Available to be worked upon labels Oct 6, 2023
@skeqiqevian skeqiqevian self-assigned this Oct 6, 2023
@skeqiqevian skeqiqevian changed the title Bounds Inference Support for elementary bounds inference Oct 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: Language The semantics of the language S: Available Available to be worked upon
Projects
None yet
Development

No branches or pull requests

1 participant