-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
[Tracking Issue] Padded Layout Transformations #12261
Labels
tir
any TIR core issues which don’t fit into other tir: labels (include/tvm/tir, src/tir)
type:rfc-tracking
RFC progress tracking. Ref: https://github.com/apache/tvm-rfcs
Comments
Lunderberg
added
the
type:rfc-tracking
RFC progress tracking. Ref: https://github.com/apache/tvm-rfcs
label
Aug 1, 2022
This was referenced Aug 1, 2022
junrushao
pushed a commit
that referenced
this issue
Aug 2, 2022
) This PR adds `tvm.testing.CompareBeforeAfter`, a generalization of the `BaseBeforeAfter` utility previously used in `test_tir_transform_simplify.py`, which performs unit tests that perform a transformation on a TIR function and compare the results to an expected TIR output. This arose when minimizing the boilerplate required for unit tests in the implementation of #12261.
Lunderberg
added a commit
that referenced
this issue
Sep 19, 2022
Implementation of API in `tvm.tir.schedule` for layout transformations with padding, as part of #12261, item "Insert pad value into generated TIR, using `tir::if_then_else`, `builtin::assume`, and `builtin::undef`". Following the RFC discussion in apache/tvm-rfcs#77 (comment) and apache/tvm-rfcs#77 (comment), this commit preferentially rewrites the loops that surround a padded transformation where possible, in order to express padding in terms of `tir::if_then_else`.
Lunderberg
added a commit
to Lunderberg/tvm
that referenced
this issue
Sep 21, 2022
This commit adds a new sub-analyzer, `TransitiveComparisonAnalyzer`, which attempts to apply multiple known comparisons to prove an unknown. For example, `a <= b` and `b <= c` imply that `a <= c`. These simplifications are necessary for simplifying conditionals resulting from padded layout transformations (apache#12261). While some of these conditions may be proven using `ConstIntBoundAnalyzer` or `IntSetAnalyzer`, each has some limitations. `ConstIntBoundAnalyzer` can only compare against a constant, `IntSetAnalyzer` internally calls `RewriteSimplifier` which can result in infinite recursion, and neither can handle not-equal conditions because it would require tracking multiple intervals per expression. Therefore, introducing a new sub-analyzer for these simplifications.
Lunderberg
added a commit
to Lunderberg/tvm
that referenced
this issue
Sep 21, 2022
This commit adds a new sub-analyzer, `TransitiveComparisonAnalyzer`, which attempts to apply multiple known comparisons to prove an unknown. For example, `a <= b` and `b <= c` imply that `a <= c`. These simplifications are necessary for simplifying conditionals resulting from padded layout transformations (apache#12261). While some of these conditions may be proven using `ConstIntBoundAnalyzer` or `IntSetAnalyzer`, each has some limitations. `ConstIntBoundAnalyzer` can only compare against a constant, `IntSetAnalyzer` internally calls `RewriteSimplifier` which can result in infinite recursion, and neither can handle not-equal conditions because it would require tracking multiple intervals per expression. Therefore, introducing a new sub-analyzer for these simplifications.
Lunderberg
added a commit
to Lunderberg/tvm
that referenced
this issue
Sep 22, 2022
This commit adds a new sub-analyzer, `TransitiveComparisonAnalyzer`, which attempts to apply multiple known comparisons to prove an unknown. For example, `a <= b` and `b <= c` imply that `a <= c`. These simplifications are necessary for simplifying conditionals resulting from padded layout transformations (apache#12261). While some of these conditions may be proven using `ConstIntBoundAnalyzer` or `IntSetAnalyzer`, each has some limitations. `ConstIntBoundAnalyzer` can only compare against a constant, `IntSetAnalyzer` internally calls `RewriteSimplifier` which can result in infinite recursion, and neither can handle not-equal conditions because it would require tracking multiple intervals per expression. Therefore, introducing a new sub-analyzer for these simplifications.
Lunderberg
added a commit
to Lunderberg/tvm
that referenced
this issue
Sep 26, 2022
This commit adds a new sub-analyzer, `TransitiveComparisonAnalyzer`, which attempts to apply multiple known comparisons to prove an unknown. For example, `a <= b` and `b <= c` imply that `a <= c`. These simplifications are necessary for simplifying conditionals resulting from padded layout transformations (apache#12261). While some of these conditions may be proven using `ConstIntBoundAnalyzer` or `IntSetAnalyzer`, each has some limitations. `ConstIntBoundAnalyzer` can only compare against a constant, `IntSetAnalyzer` internally calls `RewriteSimplifier` which can result in infinite recursion, and neither can handle not-equal conditions because it would require tracking multiple intervals per expression. Therefore, introducing a new sub-analyzer for these simplifications.
Lunderberg
added a commit
to Lunderberg/tvm
that referenced
this issue
Sep 29, 2022
Previously, rewrites of boolean expressions were handled directly within `RewriteSimplifier` visitors. This commit extracts the handling of `And`, `Or`, and `Not` nodes into an independent internal utility. The `RewriteBooleanOperators` utility can simplifies these nodes, assuming that the arguments to these expressions are already simplified. (e.g. Finding the negation of `(a < b)` without needing to recurse into `a` or `b`.) This will be used as part of additional simplifications required by [buffer layout padding](apache#12261). Because no external functionality is added or changed by this refactor, this commit does not introduce any additional unit tests.
Lunderberg
added a commit
to Lunderberg/tvm
that referenced
this issue
Oct 3, 2022
Previously, `RewriteSimplifier` inspected the top branch of each `And` and `Or` node, but didn't perform simplifications that would require inspection across branches nested structures. This commit introduces `SimplifyAsAndOfOrs`, which converts to an internal representation as conjunctive normal form, performs simplifications while in that form, then converts back to a `PrimExpr`. This utility is designed for data-propagation simplifications as part of apache#12261. To avoid increasing the CPU load unnecesarily, this utility is only used on an opt-in basis, either using `RewriteSimplifer::SetEnabledFeatures` when called directly, or using `PassContext` when used as part of `tir::transform::Simplify`.
Lunderberg
added a commit
to Lunderberg/tvm
that referenced
this issue
Oct 4, 2022
This commit adds a new sub-analyzer, `TransitiveComparisonAnalyzer`, which attempts to apply multiple known comparisons to prove an unknown. For example, `a <= b` and `b <= c` imply that `a <= c`. These simplifications are necessary for simplifying conditionals resulting from padded layout transformations (apache#12261). While some of these conditions may be proven using `ConstIntBoundAnalyzer` or `IntSetAnalyzer`, each has some limitations. `ConstIntBoundAnalyzer` can only compare against a constant, `IntSetAnalyzer` internally calls `RewriteSimplifier` which can result in infinite recursion, and neither can handle not-equal conditions because it would require tracking multiple intervals per expression. Therefore, introducing a new sub-analyzer for these simplifications.
csullivan
pushed a commit
that referenced
this issue
Oct 7, 2022
This commit adds a new sub-analyzer, `TransitiveComparisonAnalyzer`, which attempts to apply multiple known comparisons to prove an unknown. For example, `a <= b` and `b <= c` imply that `a <= c`. These simplifications are necessary for simplifying conditionals resulting from padded layout transformations (#12261). While some of these conditions may be proven using `ConstIntBoundAnalyzer` or `IntSetAnalyzer`, each has some limitations. `ConstIntBoundAnalyzer` can only compare against a constant, `IntSetAnalyzer` internally calls `RewriteSimplifier` which can result in infinite recursion, and neither can handle not-equal conditions because it would require tracking multiple intervals per expression. Therefore, introducing a new sub-analyzer for these simplifications. * Change mutable reference to mutable pointer * Remove nullptr default on Impl unique_ptr In g++ 7, defining a default constructor attempts to define the destructor, which fails because `Impl` is an incomplete type. As far as I should tell, the destructor should only be defined at the point where `~TransitiveComparisonAnalyzer` is defined, at which point `Impl` has a full definition. This issue does not occur in g++ 10. * Require opt-in for CPU-intensive simplifications * Document the intent of using bitflags * Rename "Feature" to "Extension" * Use TVM_DLL on new public member functions * Remove duplicate BaseBeforeAfter.transform definition * Explicitly enable extension for unit tests that require it * Fix accidentally duplicate test case * Improve TryCompareFromLHS documentation * Update wording to distinguish `knowns_` and `scoped_knowns_` * Better documentation for Key enum * Document the normalization of LT/GT * Removed unused PrimExpr temp * Call out modifications of the `compared_to_x` contents * Pointed to `Comparison::Comparison` for normalization details * Updated to clarify right/RHS. * Rename TryCompareFromLHS to DFSFromLHS
Lunderberg
added a commit
to Lunderberg/tvm
that referenced
this issue
Oct 7, 2022
Previously, `RewriteSimplifier` inspected the top branch of each `And` and `Or` node, but didn't perform simplifications that would require inspection across branches nested structures. This commit introduces `SimplifyAsAndOfOrs`, which converts to an internal representation as conjunctive normal form, performs simplifications while in that form, then converts back to a `PrimExpr`. This utility is designed for data-propagation simplifications as part of apache#12261. To avoid increasing the CPU load unnecesarily, this utility is only used on an opt-in basis, either using `RewriteSimplifer::SetEnabledFeatures` when called directly, or using `PassContext` when used as part of `tir::transform::Simplify`.
This was referenced Oct 10, 2022
Lunderberg
added a commit
to Lunderberg/tvm
that referenced
this issue
Oct 11, 2022
Implements `tvm::arith::NarrowPredicateExpression`, a utility that removes free parameters from a boolean expression, such that the resulting expression being true implies that the original expression is true. For example, the predicate `(0 <= i+f) && (i+f < 16)`, where `f` is a free parameter on the range `0 <= f < 2)`, can be narrowed to the expression `(0 <= i+0) && (i+2 < 16)`. In effect, `NarrowPredicateExpression` functions as a context-sentive `tvm::tir::Substitute`, where the value substituted is selected such that the resulting expression errs on the side of being false. This is an internal utility used as part of the simplifications for layout transformations ([tracking issue link](apache#12261)).
csullivan
pushed a commit
that referenced
this issue
Oct 13, 2022
Previously, `RewriteSimplifier` inspected the top branch of each `And` and `Or` node, but didn't perform simplifications that would require inspection across branches nested structures. This commit introduces `SimplifyAsAndOfOrs`, which converts to an internal representation as conjunctive normal form, performs simplifications while in that form, then converts back to a `PrimExpr`. This utility is designed for data-propagation simplifications as part of #12261. To avoid increasing the CPU load unnecesarily, this utility is only used on an opt-in basis, either using `RewriteSimplifer::SetEnabledFeatures` when called directly, or using `PassContext` when used as part of `tir::transform::Simplify`. * [Arith][UnitTest] Unittests displaying desired behavior * Corrected example in analyzer.h * Added underscore for private members * Rename Cleanup() to RemoveTrueFalse() * Added comments for conversion to internal representation * Updated comment in test case * Preferentially order clauses according to first occurrence * Added more unit tests
Lunderberg
added a commit
to Lunderberg/tvm
that referenced
this issue
Oct 14, 2022
Implements `tvm::arith::NarrowPredicateExpression`, a utility that removes free parameters from a boolean expression, such that the resulting expression being true implies that the original expression is true. For example, the predicate `(0 <= i+f) && (i+f < 16)`, where `f` is a free parameter on the range `0 <= f < 2)`, can be narrowed to the expression `(0 <= i+0) && (i+2 < 16)`. In effect, `NarrowPredicateExpression` functions as a context-sentive `tvm::tir::Substitute`, where the value substituted is selected such that the resulting expression errs on the side of being false. This is an internal utility used as part of the simplifications for layout transformations ([tracking issue link](apache#12261)).
Lunderberg
added a commit
to Lunderberg/tvm
that referenced
this issue
Oct 19, 2022
Implements `tvm::arith::NarrowPredicateExpression`, a utility that removes free parameters from a boolean expression, such that the resulting expression being true implies that the original expression is true. For example, the predicate `(0 <= i+f) && (i+f < 16)`, where `f` is a free parameter on the range `0 <= f < 2)`, can be narrowed to the expression `(0 <= i+0) && (i+2 < 16)`. In effect, `NarrowPredicateExpression` functions as a context-sentive `tvm::tir::Substitute`, where the value substituted is selected such that the resulting expression errs on the side of being false. This is an internal utility used as part of the simplifications for layout transformations ([tracking issue link](apache#12261)).
areusch
added
the
needs-triage
PRs or issues that need to be investigated by maintainers to find the right assignees to address it
label
Oct 19, 2022
jwfromm
pushed a commit
that referenced
this issue
Oct 27, 2022
Implements `tvm::arith::NarrowPredicateExpression`, a utility that removes free parameters from a boolean expression, such that the resulting expression being true implies that the original expression is true. For example, the predicate `(0 <= i+f) && (i+f < 16)`, where `f` is a free parameter on the range `0 <= f < 2)`, can be narrowed to the expression `(0 <= i+0) && (i+2 < 16)`. In effect, `NarrowPredicateExpression` functions as a context-sentive `tvm::tir::Substitute`, where the value substituted is selected such that the resulting expression errs on the side of being false. This is an internal utility used as part of the simplifications for layout transformations ([tracking issue link](#12261)).
xinetzone
pushed a commit
to daobook/tvm
that referenced
this issue
Nov 10, 2022
Implements `tvm::arith::NarrowPredicateExpression`, a utility that removes free parameters from a boolean expression, such that the resulting expression being true implies that the original expression is true. For example, the predicate `(0 <= i+f) && (i+f < 16)`, where `f` is a free parameter on the range `0 <= f < 2)`, can be narrowed to the expression `(0 <= i+0) && (i+2 < 16)`. In effect, `NarrowPredicateExpression` functions as a context-sentive `tvm::tir::Substitute`, where the value substituted is selected such that the resulting expression errs on the side of being false. This is an internal utility used as part of the simplifications for layout transformations ([tracking issue link](apache#12261)).
driazati
removed
the
needs-triage
PRs or issues that need to be investigated by maintainers to find the right assignees to address it
label
Nov 16, 2022
driazati
added
the
tir
any TIR core issues which don’t fit into other tir: labels (include/tvm/tir, src/tir)
label
Nov 16, 2022
xinetzone
pushed a commit
to daobook/tvm
that referenced
this issue
Nov 25, 2022
…che#12264) This PR adds `tvm.testing.CompareBeforeAfter`, a generalization of the `BaseBeforeAfter` utility previously used in `test_tir_transform_simplify.py`, which performs unit tests that perform a transformation on a TIR function and compare the results to an expected TIR output. This arose when minimizing the boilerplate required for unit tests in the implementation of apache#12261.
xinetzone
pushed a commit
to daobook/tvm
that referenced
this issue
Nov 25, 2022
Implementation of API in `tvm.tir.schedule` for layout transformations with padding, as part of apache#12261, item "Insert pad value into generated TIR, using `tir::if_then_else`, `builtin::assume`, and `builtin::undef`". Following the RFC discussion in apache/tvm-rfcs#77 (comment) and apache/tvm-rfcs#77 (comment), this commit preferentially rewrites the loops that surround a padded transformation where possible, in order to express padding in terms of `tir::if_then_else`.
xinetzone
pushed a commit
to daobook/tvm
that referenced
this issue
Nov 25, 2022
…he#12863) This commit adds a new sub-analyzer, `TransitiveComparisonAnalyzer`, which attempts to apply multiple known comparisons to prove an unknown. For example, `a <= b` and `b <= c` imply that `a <= c`. These simplifications are necessary for simplifying conditionals resulting from padded layout transformations (apache#12261). While some of these conditions may be proven using `ConstIntBoundAnalyzer` or `IntSetAnalyzer`, each has some limitations. `ConstIntBoundAnalyzer` can only compare against a constant, `IntSetAnalyzer` internally calls `RewriteSimplifier` which can result in infinite recursion, and neither can handle not-equal conditions because it would require tracking multiple intervals per expression. Therefore, introducing a new sub-analyzer for these simplifications. * Change mutable reference to mutable pointer * Remove nullptr default on Impl unique_ptr In g++ 7, defining a default constructor attempts to define the destructor, which fails because `Impl` is an incomplete type. As far as I should tell, the destructor should only be defined at the point where `~TransitiveComparisonAnalyzer` is defined, at which point `Impl` has a full definition. This issue does not occur in g++ 10. * Require opt-in for CPU-intensive simplifications * Document the intent of using bitflags * Rename "Feature" to "Extension" * Use TVM_DLL on new public member functions * Remove duplicate BaseBeforeAfter.transform definition * Explicitly enable extension for unit tests that require it * Fix accidentally duplicate test case * Improve TryCompareFromLHS documentation * Update wording to distinguish `knowns_` and `scoped_knowns_` * Better documentation for Key enum * Document the normalization of LT/GT * Removed unused PrimExpr temp * Call out modifications of the `compared_to_x` contents * Pointed to `Comparison::Comparison` for normalization details * Updated to clarify right/RHS. * Rename TryCompareFromLHS to DFSFromLHS
xinetzone
pushed a commit
to daobook/tvm
that referenced
this issue
Nov 25, 2022
…#12972) Previously, `RewriteSimplifier` inspected the top branch of each `And` and `Or` node, but didn't perform simplifications that would require inspection across branches nested structures. This commit introduces `SimplifyAsAndOfOrs`, which converts to an internal representation as conjunctive normal form, performs simplifications while in that form, then converts back to a `PrimExpr`. This utility is designed for data-propagation simplifications as part of apache#12261. To avoid increasing the CPU load unnecesarily, this utility is only used on an opt-in basis, either using `RewriteSimplifer::SetEnabledFeatures` when called directly, or using `PassContext` when used as part of `tir::transform::Simplify`. * [Arith][UnitTest] Unittests displaying desired behavior * Corrected example in analyzer.h * Added underscore for private members * Rename Cleanup() to RemoveTrueFalse() * Added comments for conversion to internal representation * Updated comment in test case * Preferentially order clauses according to first occurrence * Added more unit tests
xinetzone
pushed a commit
to daobook/tvm
that referenced
this issue
Nov 25, 2022
Implements `tvm::arith::NarrowPredicateExpression`, a utility that removes free parameters from a boolean expression, such that the resulting expression being true implies that the original expression is true. For example, the predicate `(0 <= i+f) && (i+f < 16)`, where `f` is a free parameter on the range `0 <= f < 2)`, can be narrowed to the expression `(0 <= i+0) && (i+2 < 16)`. In effect, `NarrowPredicateExpression` functions as a context-sentive `tvm::tir::Substitute`, where the value substituted is selected such that the resulting expression errs on the side of being false. This is an internal utility used as part of the simplifications for layout transformations ([tracking issue link](apache#12261)).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
tir
any TIR core issues which don’t fit into other tir: labels (include/tvm/tir, src/tir)
type:rfc-tracking
RFC progress tracking. Ref: https://github.com/apache/tvm-rfcs
This issue is to track progress for padded layout transformations
New TIR Op,
tir::builtin::assume
([TIR] Add tir::builtin::assume #12267)New lowering transform, remove
tir::builtin::assume
([TIR] Add tir::builtin::assume #12267)New TIR Op,
tir::builtin::undef
([TIR] Add tir::builtin::undef #12266)New lowering transform, remove
tir::builtin::undef
([TIR] Add tir::builtin::undef #12266)Enhancements to
transform_layout
tir.schedule.transform_layout
, rewrite loop structure if possible, mimicking TE functionality. (Implemented for padded transforms in [TIR] Implement API for padded layout transformations #12720, still to implement for un-padded transforms)tir::if_then_else
,builtin::assume
, andbuiltin::undef
([TIR] Implement API for padded layout transformations #12720)New utility, reorder loops according to buffer layout
Should be implemented as wrapper function around
Schedule.transform_block_layout
.Enhancement, DomainTouched
Must track a predicate for which this touch occurs, and any known values for this touch.
Enhancement, Remove No Op
Should identify writes that are later overwritten or deallocated without affecting the observable outputs.
Enhancement, Simplify ([TIR][Analysis][Arith] Implement basic data-flow analysis #13130)
Should remove conditional statements that are provable using known contents of a buffer.
New transform, Hoist Expression. ([TIR] HoistExpression, generalization of HoistIfThenElse #11592)
New primitive, remove branching through overcompute
New primitive, remove overcompute through branching
cc @Hzfengsy @junrushao
The text was updated successfully, but these errors were encountered: