Revision tags: llvmorg-21-init, llvmorg-19.1.7, llvmorg-19.1.6, llvmorg-19.1.5, llvmorg-19.1.4, llvmorg-19.1.3 |
|
#
f18c3e4e |
| 23-Oct-2024 |
Matthias Springer <me@m-sp.org> |
[mlir][Transforms] Dialect Conversion: Simplify materialization fn result type (#113031)
This commit simplifies the result type of materialization functions.
Previously: `std::optional<Value>`
N
[mlir][Transforms] Dialect Conversion: Simplify materialization fn result type (#113031)
This commit simplifies the result type of materialization functions.
Previously: `std::optional<Value>`
Now: `Value`
The previous implementation allowed 3 possible return values:
- Non-null value: The materialization function produced a valid
materialization.
- `std::nullopt`: The materialization function failed, but another
materialization can be attempted.
- `Value()`: The materialization failed and so should the dialect
conversion. (Previously: Dialect conversion can roll back.)
This commit removes the last variant. It is not particularly useful
because the dialect conversion will fail anyway if all other
materialization functions produced `std::nullopt`.
Furthermore, in contrast to type conversions, at least one
materialization callback is expected to succeed. In case of a failing
type conversion, the current dialect conversion can roll back and try a
different pattern. This also used to be the case for materializations,
but that functionality was removed with #107109: failed materializations
can no longer trigger a rollback. (They can just make the entire dialect
conversion fail without rollback.) With this in mind, it is even less
useful to have an additional error state for materialization functions.
This commit is in preparation of merging the 1:1 and 1:N type
converters. Target materializations will have to return multiple values
instead of a single one. With this commit, we can keep the API simple:
`SmallVector<Value>` instead of `std::optional<SmallVector<Value>>`.
Note for LLVM integration: All 1:1 materializations should return
`Value` instead of `std::optional<Value>`. Instead of `std::nullopt`
return `Value()`.
show more ...
|
Revision tags: llvmorg-19.1.2, llvmorg-19.1.1, llvmorg-19.1.0 |
|
#
6634d44e |
| 09-Sep-2024 |
Amy Wang <kai.ting.wang@huawei.com> |
[MLIR][Transform] Allow stateInitializer and stateExporter for applyTransforms (#101186)
This is discussed in RFC:
https://discourse.llvm.org/t/rfc-making-the-constructor-of-the-transformstate-cl
[MLIR][Transform] Allow stateInitializer and stateExporter for applyTransforms (#101186)
This is discussed in RFC:
https://discourse.llvm.org/t/rfc-making-the-constructor-of-the-transformstate-class-protected/80377
show more ...
|
Revision tags: llvmorg-19.1.0-rc4, llvmorg-19.1.0-rc3 |
|
#
84cc1865 |
| 05-Aug-2024 |
Nikhil Kalra <nikhil.kalra@gmail.com> |
[mlir] Support DialectRegistry extension comparison (#101119)
`PassManager::run` loads the dependent dialects for each pass into the
current context prior to invoking the individual passes. If the
[mlir] Support DialectRegistry extension comparison (#101119)
`PassManager::run` loads the dependent dialects for each pass into the
current context prior to invoking the individual passes. If the
dependent dialect is already loaded into the context, this should be a
no-op. However, if there are extensions registered in the
`DialectRegistry`, the dependent dialects are unconditionally registered
into the context.
This poses a problem for dynamic pass pipelines, however, because they
will likely be executing while the context is in an immutable state
(because of the parent pass pipeline being run).
To solve this, we'll update the extension registration API on
`DialectRegistry` to require a type ID for each extension that is
registered. Then, instead of unconditionally registered dialects into a
context if extensions are present, we'll check against the extension
type IDs already present in the context's internal `DialectRegistry`.
The context will only be marked as dirty if there are net-new extension
types present in the `DialectRegistry` populated by
`PassManager::getDependentDialects`.
Note: this PR removes the `addExtension` overload that utilizes
`std::function` as the parameter. This is because `std::function` is
copyable and potentially allocates memory for the contained function so
we can't use the function pointer as the unique type ID for the
extension.
Downstream changes required:
- Existing `DialectExtension` subclasses will need a type ID to be
registered for each subclass. More details on how to register a type ID
can be found here:
https://github.com/llvm/llvm-project/blob/8b68e06731e0033ed3f8d6fe6292ae671611cfa1/mlir/include/mlir/Support/TypeID.h#L30
- Existing uses of the `std::function` overload of `addExtension` will
need to be refactored into dedicated `DialectExtension` classes with
associated type IDs. The attached `std::function` can either be inlined
into or called directly from `DialectExtension::apply`.
---------
Co-authored-by: Mehdi Amini <joker.eph@gmail.com>
show more ...
|
Revision tags: llvmorg-19.1.0-rc2, llvmorg-19.1.0-rc1, llvmorg-20-init |
|
#
2c1ae801 |
| 19-Jun-2024 |
donald chen <chenxunyu1993@gmail.com> |
[mlir][side effect] refactor(*): Include more precise side effects (#94213)
This patch adds more precise side effects to the current ops with memory
effects, allowing us to determine which OpOperan
[mlir][side effect] refactor(*): Include more precise side effects (#94213)
This patch adds more precise side effects to the current ops with memory
effects, allowing us to determine which OpOperand/OpResult/BlockArgument
the
operation reads or writes, rather than just recording the reading and
writing
of values. This allows for convenient use of precise side effects to
achieve
analysis and optimization.
Related discussions:
https://discourse.llvm.org/t/rfc-add-operandindex-to-sideeffect-instance/79243
show more ...
|
Revision tags: llvmorg-18.1.8, llvmorg-18.1.7, llvmorg-18.1.6, llvmorg-18.1.5, llvmorg-18.1.4, llvmorg-18.1.3 |
|
#
5a9bdd85 |
| 20-Mar-2024 |
Oleksandr "Alex" Zinenko <zinenko@google.com> |
[mlir] split transform interfaces into a separate library (#85221)
Transform interfaces are implemented, direction or via extensions, in
libraries belonging to multiple other dialects. Those dialec
[mlir] split transform interfaces into a separate library (#85221)
Transform interfaces are implemented, direction or via extensions, in
libraries belonging to multiple other dialects. Those dialects don't
need to depend on the non-interface part of the transform dialect, which
includes the growing number of ops and transitive dependency footprint.
Split out the interfaces into a separate library. This in turn requires
flipping the dependency from the interface on the dialect that has crept
in because both co-existed in one library. The interface shouldn't
depend on the transform dialect either.
As a consequence of splitting, the capability of the interpreter to
automatically walk the payload IR to identify payload ops of a certain
kind based on the type used for the entry point symbol argument is
disabled. This is a good move by itself as it simplifies the interpreter
logic. This functionality can be trivially replaced by a
`transform.structured.match` operation.
show more ...
|
Revision tags: llvmorg-18.1.2, llvmorg-18.1.1 |
|
#
8ec28af8 |
| 01-Mar-2024 |
Matthias Gehre <matthias.gehre@amd.com> |
Reapply "[mlir][PDL] Add support for native constraints with results (#82760)"
with a small stack-use-after-scope fix in getConstraintPredicates()
This reverts commit c80e6edba4a9593f0587e27fa0ac82
Reapply "[mlir][PDL] Add support for native constraints with results (#82760)"
with a small stack-use-after-scope fix in getConstraintPredicates()
This reverts commit c80e6edba4a9593f0587e27fa0ac825ebe174afd.
show more ...
|
#
c80e6edb |
| 01-Mar-2024 |
Matthias Gehre <matthias.gehre@amd.com> |
Revert "[mlir][PDL] Add support for native constraints with results (#82760)"
Due to buildbot failure https://lab.llvm.org/buildbot/#/builders/88/builds/72130
This reverts commit dca32a3b594b3c91f9
Revert "[mlir][PDL] Add support for native constraints with results (#82760)"
Due to buildbot failure https://lab.llvm.org/buildbot/#/builders/88/builds/72130
This reverts commit dca32a3b594b3c91f9766a9312b5d82534910fa1.
show more ...
|
#
dca32a3b |
| 01-Mar-2024 |
Matthias Gehre <matthias.gehre@amd.com> |
[mlir][PDL] Add support for native constraints with results (#82760)
From https://reviews.llvm.org/D153245
This adds support for native PDL (and PDLL) C++ constraints to return
results.
This
[mlir][PDL] Add support for native constraints with results (#82760)
From https://reviews.llvm.org/D153245
This adds support for native PDL (and PDLL) C++ constraints to return
results.
This is useful for situations where a pattern checks for certain
constraints of multiple interdependent attributes and computes a new
attribute value based on them. Currently, for such an example it is
required to escape to C++ during matching to perform the check and after
a successful match again escape to native C++ to perform the computation
during the rewriting part of the pattern. With this work we can do the
computation in C++ during matching and use the result in the rewriting
part of the pattern. Effectively this enables a choice in the trade-off
of memory consumption during matching vs recomputation of values.
This is an example of a situation where this is useful: We have two
operations with certain attributes that have interdependent constraints.
For instance `attr_foo: one_of [0, 2, 4, 8], attr_bar: one_of [0, 2, 4,
8]` and `attr_foo == attr_bar`. The pattern should only match if all
conditions are true. The new operation should be created with a new
attribute which is computed from the two matched attributes e.g.
`attr_baz = attr_foo * attr_bar`. For the check we already escape to
native C++ and have all values at hand so it makes sense to directly
compute the new attribute value as well:
```
Constraint checkAndCompute(attr0: Attr, attr1: Attr) -> Attr;
Pattern example with benefit(1) {
let foo = op<test.foo>() {attr = attr_foo : Attr};
let bar = op<test.bar>(foo) {attr = attr_bar : Attr};
let attr_baz = checkAndCompute(attr_foo, attr_bar);
rewrite bar with {
let baz = op<test.baz> {attr=attr_baz};
replace bar with baz;
};
}
```
To achieve this the following notable changes were necessary:
PDLL:
- Remove check in PDLL parser that prevented native constraints from
returning results
PDL:
- Change PDL definition of pdl.apply_native_constraint to allow variadic
results
PDL_interp:
- Change PDL_interp definition of pdl_interp.apply_constraint to allow
variadic results
PDLToPDLInterp Pass:
The input to the pass is an arbitrary number of PDL patterns. The pass
collects the predicates that are required to match all of the pdl
patterns and establishes an ordering that allows creation of a single
efficient matcher function to match all of them. Values that are matched
and possibly used in the rewriting part of a pattern are represented as
positions. This allows fusion and thus reusing a single position for
multiple matching patterns. Accordingly, we introduce
ConstraintPosition, which records the type and index of the result of
the constraint. The problem is for the corresponding value to be used in
the rewriting part of a pattern it has to be an input to the
pdl_interp.record_match operation, which is generated early during the
pass such that its surrounding block can be referred to by branching
operations. In consequence the value has to be materialized after the
original pdl.apply_native_constraint has been deleted but before we get
the chance to generate the corresponding pdl_interp.apply_constraint
operation. We solve this by emitting a placeholder value when a
ConstraintPosition is evaluated. These placeholder values (due to fusion
there may be multiple for one constraint result) are replaced later when
the actual pdl_interp.apply_constraint operation is created.
Changes since the phabricator review:
- Addressed all comments
- In particular, removed registerConstraintFunctionWithResults and
instead changed registerConstraintFunction so that contraint functions
always have results (empty by default)
- Thus we don't need to reuse `rewriteFunctions` to store constraint
functions with results anymore, and can instead use
`constraintFunctions`
- Perform a stable sort of ConstraintQuestion, so that
ConstraintQuestion appear before other ConstraintQuestion that use their
results.
- Don't create placeholders for pdl_interp::ApplyConstraintOp. Instead
generate the `pdl_interp::ApplyConstraintOp` before generating the
successor block.
- Fixed a test failure in the pdl python bindings
Original code by @martin-luecke
Co-authored-by: martin-luecke <martinpaul.luecke@amd.com>
show more ...
|
Revision tags: llvmorg-18.1.0, llvmorg-18.1.0-rc4, llvmorg-18.1.0-rc3, llvmorg-18.1.0-rc2, llvmorg-18.1.0-rc1, llvmorg-19-init |
|
#
2798b72a |
| 12-Jan-2024 |
Oleksandr "Alex" Zinenko <zinenko@google.com> |
[mlir] introduce debug transform dialect extension (#77595)
Introduce a new extension for simple print-debugging of the transform
dialect scripts. The initial version of this extension consists of
[mlir] introduce debug transform dialect extension (#77595)
Introduce a new extension for simple print-debugging of the transform
dialect scripts. The initial version of this extension consists of two
ops that are printing the payload objects associated with transform
dialect values. Similar ops were already available in the test extenion
and several downstream projects, and were extensively used for testing.
show more ...
|
#
f90b6090 |
| 03-Jan-2024 |
Oleksandr "Alex" Zinenko <zinenko@google.com> |
[mlir] introduce transform.num_associations (#76723)
Add a new transform operation that creates a new parameter containing the number of payload objects (operations, values or attributes) associated
[mlir] introduce transform.num_associations (#76723)
Add a new transform operation that creates a new parameter containing the number of payload objects (operations, values or attributes) associated with the argument. This is useful in matching and for debugging purposes. This replaces three ad-hoc operations previously provided by the test extension.
show more ...
|
Revision tags: llvmorg-17.0.6, llvmorg-17.0.5, llvmorg-17.0.4, llvmorg-17.0.3, llvmorg-17.0.2 |
|
#
085075a5 |
| 25-Sep-2023 |
Matthias Springer <me@m-sp.org> |
[mlir][transform] Check for invalidated iterators on payload values (#66472)
Same as #66369 but for payload values. (#66369 added checks only for
payload operations.)
It was necessary to change
[mlir][transform] Check for invalidated iterators on payload values (#66472)
Same as #66369 but for payload values. (#66369 added checks only for
payload operations.)
It was necessary to change the signature of `getPayloadValues` to return
an iterator. This is now similar to payload operations.
Fixes an issue in #66369 where the `LLVM_ENABLE_ABI_BREAKING_CHECKS`
check was inverted.
show more ...
|
Revision tags: llvmorg-17.0.1, llvmorg-17.0.0, llvmorg-17.0.0-rc4 |
|
#
e2d39f79 |
| 23-Aug-2023 |
Christopher Bate <cbate@nvidia.com> |
[mlir][Transform] Add `updateConversionTarget` to `ConversionPatternDescriptorOpInterface`
This change adds a method to modify the ConversionTarget used during `transform.apply_conversion_patterns`
[mlir][Transform] Add `updateConversionTarget` to `ConversionPatternDescriptorOpInterface`
This change adds a method to modify the ConversionTarget used during `transform.apply_conversion_patterns` to the `ConversionPatternDescriptorOpInterface`. This is needed when the TypeConverter is used to dictate the dynamic legality of operations, as in "structural" conversion patterns present in, for example, the SCF and func dialects.
As a first use case/test, this change also adds a `transform.apply_patterns.scf.structural_conversions` operation to the SCF dialect.
Reviewed By: springerm
Differential Revision: https://reviews.llvm.org/D158672
show more ...
|
#
4f63252d |
| 14-Sep-2023 |
Matthias Springer <me@m-sp.org> |
[mlir][transform] Fix crash when op is erased during transform.foreach (#66357)
Fixes a crash when an op, that is mapped to handle that a
`transform.foreach` iterates over, was erased (through the
[mlir][transform] Fix crash when op is erased during transform.foreach (#66357)
Fixes a crash when an op, that is mapped to handle that a
`transform.foreach` iterates over, was erased (through the
`TrackingRewriter`). Erasing an op removes it from all mappings and
invalidates iterators. This is already taken care of when an op is
iterating over payload ops in its `apply` method, but not when another
transform op is erasing a tracked payload op.
show more ...
|
#
830b9b07 |
| 12-Sep-2023 |
Mehdi Amini <joker.eph@gmail.com> |
Update some uses of `getAttr()` to be explicit about Inherent vs Discardable (NFC)
|
Revision tags: llvmorg-17.0.0-rc3, llvmorg-17.0.0-rc2 |
|
#
bcfdb3e4 |
| 07-Aug-2023 |
Matthias Springer <me@m-sp.org> |
[mlir][transform] Add apply_conversion_patterns op
This transform op applies a dialect conversion to the targeted ops. Its design is similar to `apply_patterns`.
Patterns are specified in the first
[mlir][transform] Add apply_conversion_patterns op
This transform op applies a dialect conversion to the targeted ops. Its design is similar to `apply_patterns`.
Patterns are specified in the first region of `apply_conversion_patterns`. They must implement the `ConversionPatternDescriptorOpInterface`. Regular rewrite patterns and dialect conversion patterns should not be mixed, so the interface is separate from the `PatternDescriptorOpInterface`.
The type converter is specified as the single op of the second region. It is optional; if no type converter is specified, it is expected that pattern descriptors provide their own type converters. If both the pattern descriptors and the `apply_conversion_patterns` op specify a type converter, the type converter of the pattern descriptor is used.
Differential Revision: https://reviews.llvm.org/D157109
show more ...
|
Revision tags: llvmorg-17.0.0-rc1, llvmorg-18-init |
|
#
7dfcd4b7 |
| 07-Jul-2023 |
Matthias Springer <me@m-sp.org> |
[mlir][transform] Add VerifyOp
This transform op runs the verifier on the targeted payload ops. It is for debugging only.
Differential Revision: https://reviews.llvm.org/D154711
|
#
dd81c6b8 |
| 04-Jul-2023 |
Alex Zinenko <zinenko@google.com> |
[mlir] integration tests for transform dialect matchers
Add integration tests exercising transform dialect matchers for slightly larger compositions of structured ops, namely reductions and matrix m
[mlir] integration tests for transform dialect matchers
Add integration tests exercising transform dialect matchers for slightly larger compositions of structured ops, namely reductions and matrix multiplications with optional leading and trailing elementwise operations.
Reviewed By: qcolombet
Differential Revision: https://reviews.llvm.org/D154440
show more ...
|
#
9cc8e458 |
| 26-Jun-2023 |
Matthias Springer <me@m-sp.org> |
[mlir][transform] Add notifyPayloadOperationReplaced to TransformRewriter
This function allows users to update payload op mappings in cases where such replacements cannot be performed automatically
[mlir][transform] Add notifyPayloadOperationReplaced to TransformRewriter
This function allows users to update payload op mappings in cases where such replacements cannot be performed automatically by the rewriter/listener interface.
Differential Revision: https://reviews.llvm.org/D153764
show more ...
|
#
c580bd26 |
| 22-Jun-2023 |
Alex Zinenko <zinenko@google.com> |
[mlir][transform] fix handle invalidation check for reentrant regions
When exiting the scope of a region attached to a transform op, clean up the handle invalidation checks assocaited with handles d
[mlir][transform] fix handle invalidation check for reentrant regions
When exiting the scope of a region attached to a transform op, clean up the handle invalidation checks assocaited with handles defined in this region. Otherwise, these checks may trigger on the next entry to the region while there is no incorrect usage.
Reviewed By: springerm
Differential Revision: https://reviews.llvm.org/D153545
show more ...
|
#
19380396 |
| 14-Jun-2023 |
Quinn Dawkins <quinn@nod-labs.com> |
[mlir][Transform] Allow parameter and value types in merge_handles op
Similar to operation handles, merging handles for other types can be useful to avoid repetition of common transformations across
[mlir][Transform] Allow parameter and value types in merge_handles op
Similar to operation handles, merging handles for other types can be useful to avoid repetition of common transformations across a set of parameters. For example, forming a list of static values for comparison rather than comparing the parameters one at a time.
Reviewed By: ftynse
Differential Revision: https://reviews.llvm.org/D153240
show more ...
|
#
c63d2b2c |
| 20-Jun-2023 |
Matthias Springer <me@m-sp.org> |
[mlir][transform] Add TransformRewriter
All `apply` functions now have a `TransformRewriter &` parameter. This rewriter should be used to modify the IR. It has a `TrackingListener` attached and upda
[mlir][transform] Add TransformRewriter
All `apply` functions now have a `TransformRewriter &` parameter. This rewriter should be used to modify the IR. It has a `TrackingListener` attached and updates the internal handle-payload mappings based on rewrites.
Implementations no longer need to create their own `TrackingListener` and `IRRewriter`. Error checking is integrated into `applyTransform`. Tracking listener errors are reported only for ops with the `ReportTrackingListenerFailuresOpTrait` trait attached, allowing for a gradual migration. Furthermore, errors can be silenced with an op attribute.
Additional API will be added to `TransformRewriter` in subsequent revisions. This revision just adds an "empty" `TransformRewriter` class and updates all `apply` implementations.
Differential Revision: https://reviews.llvm.org/D152427
show more ...
|
Revision tags: llvmorg-16.0.6 |
|
#
1b390f5e |
| 09-Jun-2023 |
Matthias Springer <me@m-sp.org> |
[mlir][transform] Simplify TrackingListener test case
Use the default TrackingListener. No need to set up a derived listener just for the test case. This revision is in preparation of a future chang
[mlir][transform] Simplify TrackingListener test case
Use the default TrackingListener. No need to set up a derived listener just for the test case. This revision is in preparation of a future change that adds a TrackingRewriter infrastructure.
Differential Revision: https://reviews.llvm.org/D152446
show more ...
|
#
572b171f |
| 09-Jun-2023 |
Matthias Springer <me@m-sp.org> |
[mlir][transform] TrackingListener: Distinguish between failure and "should be dropped"
When looking for replacement ops (`findReplacementOp`) distinguish between "no replacement could be found" and
[mlir][transform] TrackingListener: Distinguish between failure and "should be dropped"
When looking for replacement ops (`findReplacementOp`) distinguish between "no replacement could be found" and "this op should be dropped from the mapping". The latter case will be utilized in a subsequent revision when a payload op is mapped to a consumed handle.
Differential Revision: https://reviews.llvm.org/D152375
show more ...
|
#
cc7f5243 |
| 06-Jun-2023 |
Matthias Springer <me@m-sp.org> |
[mlir][transform] Use separate ops instead of PatternRegistry
* Remove `transform::PatternRegistry`. * Add a new op for each currently registered pattern set. * Change names of vector dialect patter
[mlir][transform] Use separate ops instead of PatternRegistry
* Remove `transform::PatternRegistry`. * Add a new op for each currently registered pattern set. * Change names of vector dialect pattern selector ops, so that they are consistent with the remaining code base. * Remove redundant `transform.vector.extract_address_computations` op.
Differential Revision: https://reviews.llvm.org/D152249
show more ...
|
#
5a10f207 |
| 06-Jun-2023 |
Matthias Springer <me@m-sp.org> |
[mlir][transform] Add region to ApplyPatternsOp
Patterns should be selected by adding ops that implement `PatternDescriptorOpInterface` to the region of `apply_pattern` ops. Such ops can have operan
[mlir][transform] Add region to ApplyPatternsOp
Patterns should be selected by adding ops that implement `PatternDescriptorOpInterface` to the region of `apply_pattern` ops. Such ops can have operands, allowing for pattern parameterization. The existing way of selecting patterns from the PatternRegistry is deprecated.
Differential Revision: https://reviews.llvm.org/D152167
show more ...
|