Commit Graph

11788 Commits

Author SHA1 Message Date
Groverkss d71a8bb157 [MLIR][Affine] Allow affine-expr on RHS in IntegerSet
Currently, the parser for IntegerSet, only allows constraints like:

```
affine-constraint ::= affine-expr `>=` `0`
                    | affine-expr `==` `0`
```

This form is sometimes unreadable and painful to use when writing unittests
for Presburger library and tests in general.

This patch extends the parser to allow affine constraints with affine-expr on
the RHS:

```
affine-constraint ::= affine-expr `>=` `affine-expr`
                    | affine-expr `==` `affine-expr`
```

The internal storage and printing of IntegerSet is still in the original format.

Reviewed By: bondhugula

Differential Revision: https://reviews.llvm.org/D128915
2022-07-03 16:22:39 +01:00
lewuathe 5148c685e3 [mlir][complex] Inverse canonicalization between exp and log
We can canonicalize consecutive complex.exp and complex.log which are inverse functions each other.

Reviewed By: bixia

Differential Revision: https://reviews.llvm.org/D128966
2022-07-03 09:26:55 +09:00
lorenzo chelini 7fc4518f4a [MLIR] Rename FusePadOpWithLinalgConsumer -> FusePadOpWithLinalgProducer (NFC)
Follow up after D128978, where I mistakenly rename the file. The linalg op is
fused with its producer, not the consumer.
2022-07-02 11:01:50 +02:00
wren romano 537db49596 [mlir][sparse] Silencing some -Wunused-function in unittests
This is a followup to D128058.

Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D129027
2022-07-01 18:47:44 -07:00
wren romano 875ee0ed1c [mlir][sparse] Reducing computational complexity
This is a followup to D128847.  The `AffineMap::getPermutedPosition` method performs a linear scan of the map, thus the previous implementation had asymptotic complexity of `O(|topSort| * |m|)`.  This change reduces that to `O(|topSort| + |m|)`.

Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D129011
2022-07-01 12:55:09 -07:00
Eric Kunze b7f4335d6a [mlir][tosa] Update TOSA transpose_conv2d to match spec
The TOSA Specification doesn't have a dilation attribute for transpose_conv2d,
and the padding array is of size 4. (top,bottom,left,right).

This change updates the dialect to match the specification, and updates the lit
tests to match the dialect changes.

Differential Revision: https://reviews.llvm.org/D127332
2022-07-01 19:10:28 +00:00
rdzhabarov f59c279b72 [mlir] Fix usages of `run-reproducer`.
There is no need to specify `run-reproducer` explicitly anymore.

Differential Revision: https://reviews.llvm.org/D129010
2022-07-01 18:36:07 +00:00
Peiming Liu daeb2dcea0 [mlir][sparse] add more unittest cases to sparse dialect merger
Reviewed By: aartbik, wrengr

Differential Revision: https://reviews.llvm.org/D128058
2022-07-01 17:58:10 +00:00
Arjun P c4abef28a3 [MLIR][Presburger] support symbolicLexMin for IntegerRelation
This also changes the space of the returned lexmin for IntegerPolyhedrons;
the symbols in the poly now correspond to symbols in the result rather than dims.

Reviewed By: Groverkss

Differential Revision: https://reviews.llvm.org/D128933
2022-07-01 18:00:11 +01:00
Arjun P c2fcaf84e5 [MLIR][Presburger] Simplex: refactor (symbolic)lex to support specifying multiple varKinds as symbols
This is also required to support lexmin for relations.

Reviewed By: Groverkss

Differential Revision: https://reviews.llvm.org/D128931
2022-07-01 17:47:39 +01:00
lorenzo chelini cc2a614796 [MLIR][Linalg] Update filename to reflect implementation (NFC)
Reviewed By: nicolasvasilache

Differential Revision: https://reviews.llvm.org/D128978
2022-07-01 17:24:54 +02:00
Nicolas Vasilache b994d388ae [mlir][SCF] Add a ParallelCombiningOpInterface to decouple scf::PerformConcurrently from its contained operations
This allows purging references of scf.ForeachThreadOp and scf.PerformConcurrentlyOp from
ParallelInsertSliceOp.
This will allowmoving the op closer to tensor::InsertSliceOp with which it should share much more
code.

In the future, the decoupling will also allow extending the type of ops that can be used in the
parallel combinator as well as semantics related to multiple concurrent inserts to the same
result.

Differential Revision: https://reviews.llvm.org/D128857
2022-07-01 00:16:02 -07:00
Nicolas Vasilache 6a57d8fba5 [mlir][vector] Untangle TransferWriteDistribution and avoid crashing in the 0-D case.
This revision avoids a crash in the 0-D case of distributing vector.transfer ops out of
vector.warp_execute_on_lane_0.
Due to the code complexity and lack of documentation, it took untangling the implementation
before realizing that the simple fix was to fail in the 0-D case.
The rewrite is still very useful to understand this code better.

Differential Revision: https://reviews.llvm.org/D128793
2022-07-01 00:15:34 -07:00
jacquesguan 8f45c5862f [mlir][Vector] Fold InsertStridedSliceOp of ExtractStridedSliceOp.
This patch supports to fold InsertStridedSliceOp(ExtractStridedSliceOp(dst), dst) to dst.

Differential Revision: https://reviews.llvm.org/D128903
2022-07-01 11:43:35 +08:00
jacquesguan 91ab4d4231 [mlir][Vector] Fold InsertStridedSliceOp of two splat with the same input to splat.
This patch folds InsertStridedSliceOp(SplatOp(X):src_type, SplatOp(X):dst_type) to SplatOp(X):dst_type.

Reviewed By: Mogball

Differential Revision: https://reviews.llvm.org/D128891
2022-07-01 10:46:47 +08:00
Fangrui Song 27abff670b Remove unneeded cl::ZeroOrMore. NFC 2022-06-30 19:11:27 -07:00
Fangrui Song 62a4e6ab15 [mlir] Remove unneeded cl::ZeroOrMore for ListOption variables. NFC 2022-06-30 19:04:44 -07:00
wren romano 46394861a3 [mlir][tblgen] Improving error messages
This differential improves two error conditions, by detecting them earlier and by providing better messages to help users understand what went wrong.

Reviewed By: jpienaar

Differential Revision: https://reviews.llvm.org/D128555
2022-06-30 18:25:53 -07:00
Mogball c095afcba6 [mlir] Add Dead Code Analysis
This patch implements the analysis state classes needed for sparse data-flow analysis and implements a dead-code analysis using those states to determine liveness of blocks, control-flow edges, region predecessors, and function callsites.

Depends on D126751

Reviewed By: rriddle, phisiart

Differential Revision: https://reviews.llvm.org/D127064
2022-06-30 13:51:25 -07:00
Javed Absar c2ecf16224 [mlir][Inliner] Support recursion in Inliner
This fixes  Bug https://github.com/llvm/llvm-project/issues/53492
 and uses InlineHistory to track recursive inlining.

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D127072
2022-06-30 18:52:45 +01:00
Benoit Jacob 030b36a44c Useful error when input dim is unused by LHS/RHS.
Differential Revision: https://reviews.llvm.org/D128925
2022-06-30 17:46:05 +00:00
Christopher Bate 670eee08ce [mlir][VectorToGPU] Fix support for i4, col-major operand support
For the conversion to nvgpu `mma.sync` and `ldmatrix` pathways, the code
was missing support for the `i4` data type. While fixing this, another
bug was discoverd that caused the number of ldmatrix tiles calculated for
certain operand types and configurations to be incorrect. This change
fixes both issues and adds additional tests.

Differential Revision: https://reviews.llvm.org/D128074
2022-06-30 10:26:59 -06:00
Nicolas Vasilache 178f9bd63c [mlir][Linalg] Uniformize SplitReduction transforms and add option to use Bufferization::AllocTensor
This revision merges the 2 split_reduction transforms and adds extra control by using attributes.

SplitReduction is known to require a concrete additional buffer to store tempoaray information.
Add an option to introduce a `bufferization.alloc_tensor` instead of `linalg.init_tensor`.
This behaves better with subset-based tiling and bufferization.

Differential Revision: https://reviews.llvm.org/D128722
2022-06-30 03:32:23 -07:00
Matthias Springer 76f7e4b7a3 [mlir][SCF][bufferize][NFC] Utilize recently added helper function
This should have been part of D128666.

Differential Revision: https://reviews.llvm.org/D128885
2022-06-30 09:54:52 +02:00
Fangrui Song 67854f9ed0 Use value_or instead of getValueOr. NFC 2022-06-29 21:55:02 -07:00
Aart Bik e057f25dee [mlir][sparse] auto-insertion of conversion to resolve cycles
When the iteration graph is cyclic (even after several attempts using less and less constraints), the current sparse compiler bails out, and no rewriting hapens. However, this revision adds some new logic where the sparse compiler tries to find a single input sparse tensor that breaks the cycle, and then adds a proper sparse conversion operation. This way, more incoming kernels can be handled!

Note, the resulting code is not optimal (although it keeps more or less proper "sparse" complexity), and more improvements should be added (especially when the kernel directly yields without computation, such as the transpose example). However, handling is better than not handling ;-)

Reviewed By: bixia

Differential Revision: https://reviews.llvm.org/D128847
2022-06-29 18:28:18 -07:00
Min-Yih Hsu 9bad9248ed [mlir][LLVMIR] Apply SubElementTypeInterface on suitable types
This feature is tested by unit test since not many places in the codebase
use SubElementTypeInterface.

Differential Revision: https://reviews.llvm.org/D127539
2022-06-29 13:58:02 -07:00
Min-Yih Hsu d41028610b [mlir] Prevent SubElementInterface from going into infinite recursion
Since only mutable types and attributes can go into infinite recursion
inside SubElementInterface::walkSubElement, and there are only a few of
them (mutable types and attributes), we introduce new traits for Type
and Attribute: TypeTrait::IsMutable and AttributeTrait::IsMutable,
respectively. They indicate whether a type or attribute is mutable.
Such traits are required if the ImplType defines a `mutate` function.

Then, inside SubElementInterface, we use a set to record visited mutable
types and attributes that have been visited before.

Differential Revision: https://reviews.llvm.org/D127537
2022-06-29 13:58:02 -07:00
rdzhabarov ef2c837a73 [Fix] Fix compilation warning on unused var. 2022-06-29 19:54:49 +00:00
River Riddle 0d9e51ea42 [mlir] Update the pass crash reproducer documentation
The reproducer is now encoded using an external resource, instead
of a comment at the top of the file.
2022-06-29 12:23:11 -07:00
River Riddle 361acbb362 [mlir] Refactor pass crash reproducer generation to be an assembly resource
We currently generate reproducer configurations using a comment placed at
the top of the generated .mlir file. This is kind of hacky given that comments
have no semantic context in the source file and can easily be dropped. This
strategy also wouldn't work if/when we have a bitcode format. This commit
switches to using an external assembly resource, which is verifiable/can
work with a hypothetical bitcode naturally/and removes the awkward processing
from mlir-opt for splicing comments and re-applying command line options. With
the removal of command line munging, this opens up new possibilities for
executing reproducers in memory.

Differential Revision: https://reviews.llvm.org/D126447
2022-06-29 12:14:02 -07:00
River Riddle ea488bd6e1 [mlir] Allow for attaching external resources to .mlir files
This commit enables support for providing and processing external
resources within MLIR assembly formats. This is a mechanism with which
dialects, and external clients, may attach additional information when
printing IR without that information being encoded in the IR itself.
External resources are not uniqued within the MLIR context, are not
attached directly to any operation, and are solely intended to live and be
processed outside of the immediate IR. There are many potential uses of this
functionality, for example MLIR's pass crash reproducer could utilize this to
attach the pass resource executing when a crash occurs. Other types of
uses may be embedding large amounts of binary data, such as weights in ML
applications, that shouldn't be copied directly into the MLIR context, but
need to be kept adjacent to the IR.

External resources are encoded using a key-value pair nested within a
dictionary anchored by name either on a dialect, or an externally registered
entity. The key is an identifier used to disambiguate the data. The value
may be stored in various limited forms, but general encodings use a string
(human readable) or blob format (binary). Within the textual format, an
example may be of the form:

```mlir
{-#
  // The `dialect_resources` section within the file-level metadata
  // dictionary is used to contain any dialect resource entries.
  dialect_resources: {
    // Here is a dictionary anchored on "foo_dialect", which is a dialect
    // namespace.
    foo_dialect: {
      // `some_dialect_resource` is a key to be interpreted by the dialect,
      // and used to initialize/configure/etc.
      some_dialect_resource: "Some important resource value"
    }
  },
  // The `external_resources` section within the file-level metadata
  // dictionary is used to contain any non-dialect resource entries.
  external_resources: {
    // Here is a dictionary anchored on "mlir_reproducer", which is an
    // external entity representing MLIR's crash reproducer functionality.
    mlir_reproducer: {
      // `pipeline` is an entry that holds a crash reproducer pipeline
      // resource.
      pipeline: "func.func(canonicalize,cse)"
    }
  }
```

Differential Revision: https://reviews.llvm.org/D126446
2022-06-29 12:14:01 -07:00
Benoit Jacob 694ad3eaef Fix CombineContractBroadcast folding reduction iterators.
Fix CombineContractBroadcast folding reduction iterators.

Differential Revision: https://reviews.llvm.org/D128739
2022-06-29 18:01:56 +00:00
Nicolas Vasilache 0fb24a85cb [mlir][Tensor] Improve documentation of verification behavior of InsertSliceOp. 2022-06-29 07:52:54 -07:00
Nicolas Vasilache 741f8f2bed [mlir][Tensor][NFC] Better document rank-reducing behavior of ExtractSliceOp and cleanup 2022-06-29 07:37:58 -07:00
Mehdi Amini 84124ff891 Apply clang-tidy fixes for readability-simplify-boolean-expr in ViewLikeInterface.cpp (NFC) 2022-06-29 12:15:39 +00:00
Mehdi Amini be7997221d Apply clang-tidy fixes for readability-identifier-naming in Float16bits.cpp (NFC) 2022-06-29 12:13:57 +00:00
Arjun P d08522f5bc [MLIR][Preburger] fix typo covertVarKind -> convertVarKind
Also update parameter names in the implementation file to match the header.
2022-06-29 13:08:20 +01:00
Arjun P 7236e5de54 Revert clang-tidy fixes for readability-simplify-boolean-expr and add NOLINT
The original code is more readable because the goal is to check if the given
value does *not* lie in the range. It is harder to understand this by
reading the rewritten code.

Reviewed By: mehdi_amini

Differential Revision: https://reviews.llvm.org/D128753
2022-06-29 12:23:35 +01:00
Benjamin Kramer 206a6037a0 [Presburger] Cheat around old versions of clang not doing NRVO when there's a derived-to-base cast in the way
Should be NFC. We can just do the base conversion manually and avoid
warnings about it. Clang before Clang 13 didn't implement P1825 and
complains:

mlir/lib/Analysis/Presburger/IntegerRelation.cpp:226:10: warning: local variable 'result' will be copied
      despite being returned by name [-Wreturn-std-move]
  return result;
         ^~~~~~
mlir/lib/Analysis/Presburger/IntegerRelation.cpp:226:10: note: call 'std::move' explicitly to avoid copying
  return result;
         ^~~~~~
         std::move(result)
2022-06-29 12:40:59 +02:00
Christian Sigg f6d00bac77 Revert "Add default copy and move c'tor/assignment to PresburgerRelation."
This reverts commit 2cd468ef15.
2022-06-29 12:24:28 +02:00
Christian Sigg 2cd468ef15 Add default copy and move c'tor/assignment to PresburgerRelation.
Differential Revision: https://reviews.llvm.org/D128789
2022-06-29 12:07:55 +02:00
lewuathe 0180709590 [mlir][complex] Canonicalization for consecutive complex.neg
Consecutive complex.neg are redundant so that we can canonicalize them to the original operands.

Reviewed By: pifon2a

Differential Revision: https://reviews.llvm.org/D128781
2022-06-29 11:11:40 +02:00
Adrian Kuegel 0a6e29f455 Revert "[mlir][Presburger] Fix warning Wreturn-std-move (NFC)"
This reverts commit a4070a5e77.
It introduced another warning instead.
2022-06-29 09:22:36 +02:00
Adrian Kuegel a4070a5e77 [mlir][Presburger] Fix warning Wreturn-std-move (NFC) 2022-06-29 09:10:20 +02:00
lorenzo chelini 58a55107c2 [MLIR][Math] Improve docs for round op (NFC)
Reviewed By: antiagainst

Differential Revision: https://reviews.llvm.org/D128662
2022-06-29 08:35:07 +02:00
Peixin-Qiao 1795f8cd2e [NFC][OpenMP] Fix worksharing-loop
1. Remove the redundant collapse clause in MLIR OpenMP worksharing-loop
   operation.
2. Fix several typos.
3. Refactor the chunk size type conversion since CreateSExtOrTrunc has
   both type check and type conversion.

Reviewed By: kiranchandramohan

Differential Revision: https://reviews.llvm.org/D128338
2022-06-29 12:20:03 +08:00
River Riddle 9560f02141 [mlir] Add `enableSplitting` and `insertMarkerInOutput` options to `splitAndProcessBuffer`
`enableSplitting` simply enables/disables whether we should split
or use the full buffer. `insertMarkerInOutput` toggles if split markers
should be inserted in between prcessed output chunks.

These options allow for merging the duplicate code paths we have
when splitting is optional.

Differential Revision: https://reviews.llvm.org/D128764
2022-06-28 15:42:35 -07:00
Jacques Pienaar 04235d07ad [mlir] Update flipped accessors (NFC)
Follow up with memref flipped and flipping any intermediate changes
made.
2022-06-28 13:11:26 -07:00
Mehdi Amini 08d651d7ba Apply clang-tidy fixes for performance-unnecessary-value-param in VectorDistribute.cpp (NFC) 2022-06-28 19:52:46 +00:00