Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upInfer range from body of `ForN` loops + packed loops #187
Conversation
bvssvni
added some commits
May 18, 2016
This comment has been minimized.
This comment has been minimized.
|
Updated #116 |
bvssvni
changed the title
Infer range from body of `ForN` loops
Infer range from body of `ForN` loops + packed loops
May 18, 2016
bvssvni
merged commit 24cf158
into
PistonDevelopers:master
May 18, 2016
bvssvni
deleted the
bvssvni:infer
branch
May 18, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
bvssvni commentedMay 18, 2016
•
edited
Closes #181
This PR adds support for range inference and packed versions of loops.
For example:
Notice that there is no range information in the loop, and 3 indices are specified at once. Such notation is common in mathematics, because this information can be inferred from the body of the loop.
What happens behind the scene is Dyon first expanding the packed loop into 3 loops:
Then it runs an inference on the body for
k, and since neitheriorjis declared in that loop, it infers the range to[0, len(tensor[i][j])), by cloning and truncating the AST itemtensor[i][j][k]to where it finds the index.This process is repeated for
j, which gets the range[0, len(tensor[i])).Then again for
i, which gets the range[0, len(tensor)).Now we have the full loops:
You can also write ranges in the packed version, and depend on previous index:
The inference and packed versions also works for sum/all/any/max/min/sift loops.
The
minandmaxloops went through a breaking change to make them nicer under composition. See #181 for more information.