Repository navigation
Add inductive Funcs - #9717
Draft
abadams wants to merge 11 commits into
Draft
Add inductive Funcs#9717abadams wants to merge 11 commits into
abadams wants to merge 11 commits into
Conversation
A Func may now be defined in terms of itself at earlier values of some of
its pure Vars, with the recursion guarded by a select that names the base
case, e.g.
Func f(Int(32), "f");
f(x) = select(x <= 0, in(0), in(x) + f(x - 1));
Unlike the equivalent RDom scan, such a Func can be computed at its
consumer, slid, and folded down to the few values the recurrence still
reads. A Func that refers to itself must be declared with an explicit type.
- Function classifies the Func and each of its Vars as inductive, and gives
inductive Vars a new DimType, InductiveVar, which can't be parallelized,
vectorized, or reordered against another loop derived from the same Var.
- Bounds inference expands the region required of an inductive Func to
reach its base case (Inductive.cpp).
- Inductive Funcs can't be inlined or be pipeline outputs. An inductive
update's RVars must be nested inside its inductive Vars.
- Ring buffering rewrites a Func's calls to itself inside its own stores.
Extracted from abadams/inductive_benchmarks, which builds on PR #8878.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…t the loop min A window that warms up on the first iteration of a loop computes a larger region on that iteration only, so storage folding measures that region's extent at the loop min rather than over the whole loop. Otherwise a cascade of inductive Funcs sliding over a split dimension needs a fold factor larger than the window it keeps. Add tests of cascades of second-order inductive Funcs, folded, and sliding over a split dimension. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Each section is a second-order recurrence over the samples, written as an inductive Func. The sections slide over the samples, and the last three values of each are kept in registers. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
expand_to_include_base_case ran BaseCaseSolver, a tree visitor, over the result of substitute_in_all_lets, which is exponential in the depth of a let chain whose values reuse earlier lets. Have the solver track the enclosing lets instead, rewrapping the ones each condition or recursive argument uses. Lets whose values refer to the Func are checked where they are used, once per select arm. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…into abadams/inductive_funcs
…adams/inductive_funcs
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## abadams/slide_directive #9717 +/- ##
==========================================================
Coverage ? 72.96%
==========================================================
Files ? 268
Lines ? 84625
Branches ? 20846
==========================================================
Hits ? 61743
Misses ? 16289
Partials ? 6593 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Member
|
If any of this code is @stevenraphael's, you should add a |
Member
Author
|
Yes, the squashed commit into main is going to need a co-authored-by. I think this is Steven and my code all mixed together at this point. |
Much of the inductive Funcs implementation comes from #8878. Co-authored-by: Steven Raphael <stevenraphael44@gmail.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Member
Author
|
To guard against forgetting to do that I added an empty commit with a co-authored-by in it so that it automatically gets added to the final squashed commit. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is basically #8878 but on top of the rewrite of sliding window, which makes inductive funcs behave better.
Copilot says:
Stacked on #9633 (
abadams/slide_directive), which is stacked on #9648. Opened as a draft to get CI coverage.Adds inductive Funcs: pure definitions that refer to themselves at earlier values of some of their pure Vars, with the recursion guarded by a select that names the base case:
Unlike the equivalent RDom scan, such a Func can be computed at its consumer, slid, and folded down to the few values the recurrence still reads.
Functionclassifies the Func and each of its Vars as inductive. Inductive Vars get a newDimType::InductiveVar, which can't be parallelized, vectorized, or reordered against another loop derived from the same Var.Inductive.cpp).apps/iir_cascade: a cascade of second-order IIR sections written as inductive Funcs, each sliding over the samples and keeping its last three values in registers.Much of this code comes from @stevenraphael's #8878. He is credited as a co-author on the commits.