Commit Graph

12284 Commits

Author SHA1 Message Date
Matthias Springer adc93e0d38 [mlir][SCF] Loop lb/ub are symbols during Affine Min/Max canonicalization
This fixes a bug in SCF/AffineCanonicalizationUtils.cpp. Loop lb/ub were previously considered dimensions, which caused a crash when a (non-optimizable) affine.min / affine.max expression was processed (due to multiplication of two dims). Lb/ub are now considered symbols and symbols may be multiplied. (The scope of the analysis is "within the loop body", at which point lb/ub are constants.)

Differential Revision: https://reviews.llvm.org/D132021
2022-08-18 11:44:48 +02:00
Matthias Springer 3f914d84c3 [mlir][bufferize] Better error handling: Fail if ToMemrefOps are found
bufferization.to_memref ops are not supported in One-Shot Analysis. They often trigger a failed assertion that can be confusing. Instead, scan for to_memref ops before running the analysis and immediately abort with a proper error message.

Differential Revision: https://reviews.llvm.org/D132027
2022-08-18 11:37:57 +02:00
Mats Petersson 5334a6337d [MLIR][NFC] Sort table of operations alphabetically
Arrange the operations in alphabetical order, rather than what
appears to be the order they were added. This was suggested in
a review when adding new operations.

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D132046
2022-08-18 10:31:27 +01:00
Rainer Orth ca98e0dd6c [mlir][test] Require JIT support in JIT tests
A number of mlir tests `FAIL` on Solaris/sparcv9 with `Target has no JIT
support`.  This patch fixes that by mimicing `clang/test/lit.cfg.py` which
implements a `host-supports-jit` keyword for this.  The gtest-based unit
tests don't support `REQUIRES:`, so lack of support needs to be hardcoded
there.

Tested on `amd64-pc-solaris2.11` (`check-mlir` results unchanged) and
`sparcv9-sun-solaris2.11` (only one unrelated failure left).

Differential Revision: https://reviews.llvm.org/D131151
2022-08-18 11:26:07 +02:00
Uday Bondhugula d7ac92f27b [MLIR] Remove hardcoded usage of alloc/dealloc; use memory effects
Remove hardcoded usage of memref.alloc/dealloc ops in affine utils; use memory
effects instead. This is NFC for existing test cases, but strictly more
general/powerful in terms of functionality: it allows other allocation and
freeing ops (like gpu.alloc/dealloc) to work in conjunction with affine ops and
utilities.

Differential Revision: https://reviews.llvm.org/D132011
2022-08-18 14:46:03 +05:30
Güray Özen 85882e7d64 [mlir][Vector] Support 0-D vectors in ReductionOp
This commit adds support for 0-D vectors in ReductionOp.

Reviewed By: nicolasvasilache, dcaballe

Differential Revision: https://reviews.llvm.org/D131896
2022-08-18 09:12:47 +00:00
Vitaly Buka 3f5f2905c4 [test] Propagate HWASAN_OPTIONS 2022-08-17 18:59:49 -07:00
Jakub Kuderski 95c4e51839 [mlir][spirv] Add arith.addi_carry to spv.IAddCarry conversion
Reviewed By: antiagainst

Differential Revision: https://reviews.llvm.org/D131908
2022-08-17 21:33:34 -04:00
Aart Bik e3d64ccf9f [mlir][sparse] more concise sparse tensor type printing
This change omits default values from the sparse tensor type,
saving considerable text real estate for the common cases.

Reviewed By: Peiming

Differential Revision: https://reviews.llvm.org/D132083
2022-08-17 17:35:50 -07:00
Jacques Pienaar 8fe0691161 [mlir] Update when to check for non-null optional default attr
OptionalAttr does the wrapping with Optional explicitly in ODS while
default valued optional attribute doesn't (and follows DefaultValuedAttr
in this behavior/meant as drop-in for updating old behavior), update
when to emit check for non-null to account for this.  Also add variant
for optional default valued string attribute to have same convenience as
default valued string attribute.
2022-08-17 17:00:47 -07:00
Jacques Pienaar 052669e71a [mlir] add missing pessimistic setting
This is updated on https://reviews.llvm.org/D127139, to mark op with region as pessimistic.

Reviewed By: jpienaar

Differential Revision: https://reviews.llvm.org/D131480
2022-08-17 16:20:13 -07:00
root 894e8a5446 [MLIR] Add dealloc alias check to bufferization
Traverse the cloneOp for aliases to find the alloc op

Reviewed By: frgossen, bondhugula

Differential Revision: https://reviews.llvm.org/D131797
2022-08-17 19:11:59 -04:00
Jakub Kuderski 4309170c87 [mlir] Add arith.addi_carry op
The `arith.addi_carry` op implements integer addition with overflows. The carry is returned via the second result, as `i1`.

Reviewed By: antiagainst, bondhugula

Differential Revision: https://reviews.llvm.org/D131893
2022-08-17 17:01:20 -04:00
Markus Böck f289c47b5e [mlir][ODS] Add `constBuilderCall` to `Dense*ArrayAttr`s
These are useful in builders of Ops taking DenseArrayAttrs or for use in Rewriter, to create constant instances.

Differential Revision: https://reviews.llvm.org/D132067
2022-08-17 22:18:13 +02:00
Nirvedh Meshram 6b8952554c [mlir][spirv] Modify intel joint matrix ops
Adding more supported storage classes in pointer type
Removing support for arithmetic ops as this is not available on the tensor hardware

Reviwed By: antiagainst

Differential Revision: https://reviews.llvm.org/D132039
2022-08-17 18:40:59 +00:00
Markus Böck a5b11f40f8 [mlir] Fix stale comment about how to use `VariadicOfVariadic`
The kind of attribute required has changed in 58a47508f0 but the comment was not updated to reflect it.
2022-08-17 20:15:17 +02:00
Peiming Liu 8f8c8168f3 [mlir][sparse] fix compiler warning
Reviewed By: aartbik, bixia

Differential Revision: https://reviews.llvm.org/D132040
2022-08-17 17:46:28 +00:00
Jim Kitchen c8bb23547f [mlir][sparse] Custom reduce with identity
Implement the new sparse_tensor.reduce operation which
accepts a starting identity value and a code block
describing how to perform the reduction.

Reviewed by: aartbik

Differential Revision: https://reviews.llvm.org/D130573
2022-08-17 11:21:46 -05:00
Mats Petersson 1e12793491 [MLIR]Add support for Arith MAX & MIN operations
There are some of this supported in various places, but the
basic conversion of single operations to LLVM was not supported.

Adding this to allow Flang to use these.

Reviewed By: bondhugula

Differential Revision: https://reviews.llvm.org/D131912
2022-08-17 17:00:53 +01:00
Thomas Joerg 5ad7cc7f21 Fix unused variable (introduced in
c248219b09)
2022-08-17 15:18:37 +02:00
Dominik Adamski 19bd4789b9 [NFC][OpenMP] Update simd loop collapse support description
Simdloop collapse clause is supported in the same way
as colllapse clause for worksharing loops.

Reviewed By: kiranchandramohan

Differential Revision: https://reviews.llvm.org/D131674

Signed-off-by: Dominik Adamski <dominik.adamski@amd.com>
2022-08-17 03:57:22 -05:00
Thomas Joerg 42b2facbe2 Revert "DynamicMemRefType: iteration and access by indices"
This reverts commit b8ecf32f81.

This commit introduces undefined behavior according to UBSan:
UndefinedBehaviorSanitizer: nullptr-with-nonzero-offset third_party/llvm/llvm-project/mlir/include/mlir/ExecutionEngine/CRunnerUtils.h:377:5
2022-08-17 10:35:00 +02:00
Peiming Liu ee986ab727 [mlir][sparse] Refactoring: remove Operation * from the argument list in utility functions
This patch remove the Operation *op from the argument list in utility functions, and directly pass the Location instead of calling op->getLoc().

This should make the code more clear, as the utility function (logically) does not relies on the operation that we are currently rewriting, and they behave the same regardless of the operation.

Reviewed By: aartbik, wrengr

Differential Revision: https://reviews.llvm.org/D131991
2022-08-16 21:26:43 +00:00
Peiming Liu c248219b09 [mlir][sparse] Implements concatenate operation for sparse tensor
This patch implements the conversion rule for operation introduced in https://reviews.llvm.org/D131200.
Also contains integration test for correctness

Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D131200
2022-08-16 20:47:47 +00:00
Slava Zakharin f9d988f1ac [mlir][math] Added basic support for FPowI operation.
The operation computes pow(b, p), where 'b' is floating point
and 'p' is a signed integer. The result's type matches 'b' type.
The operands must have the same shape.

Differential Revision: https://reviews.llvm.org/D129811
2022-08-16 09:24:01 -07:00
Nikita Popov 8f555a52e0 [cmake] Fix tablegen exports
This fixes some fallout from D131282. Currently, add_tablegen() will add the tablegen target to LLVM_EXPORTS and associates the install with LLVMExports. For non-standalone builds, this means that you end up with mlir-tblgen and clang-tblgen in LLVMExports.

However, these projects should instead be using MLIR_EXPORTS/MLIRTargets and CLANG_EXPORTS/ClangTargets. To fix this, add an extra EXPORT option and make use of get_target_export_arg() to create the correct export argument.

Reviewed By: ashay-github

Differential Revision: https://reviews.llvm.org/D131565
2022-08-16 14:17:23 +02:00
Johannes Reifferscheid 375a5cb648 Don't lower log1p(x) to log(1 + x).
The latter has accuracy issues around 0. The lowering in MathToLLVM is kept for now.

Reviewed By: bkramer

Differential Revision: https://reviews.llvm.org/D131676
2022-08-16 06:58:00 +02:00
Nirvedh Meshram b8f62dc22a [MLIR][SPIRV] Add intel joint matrix ops
Reviewed By: antiagainst

Differential Revision: https://reviews.llvm.org/D131586
2022-08-15 23:49:45 +00:00
Thomas Raoux 444b4fda17 [mlir][tosa] Fix clamp float lowering
min and max were mixed up after switching to using float min/max

Differential Revision: https://reviews.llvm.org/D131923
2022-08-15 22:25:14 +00:00
Lei Zhang 6f4f9e316c [mlir][spirv] Add a test covering load/store with memory operands
Reviewed By: kuhar

Differential Revision: https://reviews.llvm.org/D131904
2022-08-15 17:48:33 -04:00
Kai Sasaki 5605f17a4d [mlir][complex] Mark all supported operation illegal explicitly for complex to libm
We can mark all supported operations illegal explicitly to ensure no convertible ops remain.

Differential Revision: https://reviews.llvm.org/D131877
2022-08-15 17:02:16 -04:00
Matthias Springer 31fbdab376 [mlir][transforms] Add topological sort analysis
This change add a helper function for computing a topological sorting of a list of ops. E.g. this can be useful in transforms where a subset of ops should be cloned without dominance errors.

The analysis reuses the existing implementation in TopologicalSortUtils.cpp.

Differential Revision: https://reviews.llvm.org/D131669
2022-08-15 21:09:18 +02:00
Diego Caballero e86119b4ff [mlir] Minor fixes after removing types from attributes
D130092 removed types from attributes. This patch fixes a minor
issues what was exposed when integrating that change in IREE. An
explicit cast is needed so that the template type of `makeArrayRef`
is automatically deduced.

Co-authored-by: Lei Zhang <antiagainst@google.com>

Reviewed By: Mogball

Differential Revision: https://reviews.llvm.org/D131604
2022-08-15 19:07:25 +00:00
Stella Laurenzo f55a6fde1d [mlir] Make sure that aggregate shared libraries define all of their symbols.
We were hitting issues on Linux where this was only being caught at runtime, and different linkers (BFD vs LLD) are differently strict in such situations. Such libraries will also fail to build properly on Windows (but test coverage of that is limited, so it is better to enforce globally).

Differential Revision: https://reviews.llvm.org/D131911
2022-08-15 12:02:24 -07:00
Slava Zakharin 2dde4ba639 [mlir][math] Added algebraic simplification for IPowI operation.
Differential Revision: https://reviews.llvm.org/D130390
2022-08-15 11:55:05 -07:00
Jeff Niu 133624acf9 [mlir][python] Fix build on windows
Reviewed By: stella.stamenova, ashay-github

Differential Revision: https://reviews.llvm.org/D131906
2022-08-15 14:51:04 -04:00
Slava Zakharin cd3a234fa9 [mlir][math] Added constant folding for IPowI operation.
Differential Revision: https://reviews.llvm.org/D130389
2022-08-15 11:31:14 -07:00
Diego Caballero 43beaeed38 Revert "antiagainst's fix"
This reverts commit 42d48d0966.
2022-08-15 18:27:35 +00:00
Diego Caballero 42d48d0966 antiagainst's fix 2022-08-15 17:57:38 +00:00
Zhixun Tan e42bfec9b6 [mlir][dataflow] Remove the unused AnalysisState::defaultInitialize().
Depends On D131660

`defaultInitialize()` was introduced for the "nudging" behavior, which has been deleted.

Reviewed By: Mogball, rriddle

Differential Revision: https://reviews.llvm.org/D131746
2022-08-15 13:24:08 -04:00
Zhixun Tan 4835441d02 [mlir][dataflow] Remove Abstract{Sparse,Dense}Lattice::isAtFixpoint() and an ineffective optimization to simplify public API
Currently, in the MLIR `{Sparse,Dense}DataFlowAnalysis` API, there is a small optimization:

Before running a transfer function, if the "out state" is already at the pessimistic fixpoint (bottom lattice value), then we know that it cannot possibly be changed, therefore we can skip the transfer function.

I benchmarked and found that this optimization is ineffective, so we can remove it and simplify `{Sparse,Dense}DataFlowAnalysis`. In a subsequent patch, I plan to change/remove the concept of the pessimistic fixpoint so that the API is further simplified.

Benchmark: I ran the following tests 5 times (after 3 warmup runs), and timed the `initializeAndRun()` function.

| Test | Before (us) | After (us) |
| mlir-opt -test-dead-code-analysis mlir/test/Analysis/DataFlow/test-dead-code-analysis.mlir | 181.2536 | 187.7074 |
| mlir-opt -- -test-dead-code-analysis mlir/test/Analysis/DataFlow/test-last-modified-callgraph.mlir | 109.5504 | 105.0654 |
| mlir-opt -- -test-dead-code-analysis mlir/test/Analysis/DataFlow/test-last-modified.mlir | 333.3646 | 322.4224 |
| mlir-opt -- -allow-unregistered-dialect -sccp mlir/test/Analysis/DataFlow/test-combined-sccp.mlir | 1027.1492 | 1081.818 |

Note: `test-combined-sccp.mlir` is crafted by combining `mlir/test/Transforms/sccp.mlir`, `mlir/test/Transforms/sccp-structured.mlir` and `mlir/test/Transforms/sccp-callgraph.mlir`.

Reviewed By: aartbik, Mogball

Differential Revision: https://reviews.llvm.org/D131660
2022-08-15 13:21:05 -04:00
Jakub Kuderski 53d4ff4a47 [mlir] Simplify is_splat use in MatchAllPred. NFC.
This is a simple cleanup after https://reviews.llvm.org/D131289.

Reviewed By: antiagainst, Mogball

Differential Revision: https://reviews.llvm.org/D131895
2022-08-15 13:18:11 -04:00
Thomas Raoux 91594b5b98 [mlir][nvpu] Prevent F32ToTF32 pattern to generate illegal IR
We shouldn't apply this pattern to non F32->F32 mma.sync operations.

Differential Revision: https://reviews.llvm.org/D131902
2022-08-15 16:46:18 +00:00
Mahesh Ravishankar f365e85c83 [mlir] Revisit `LinalgLoopDistributionOptions`.
This patch cleans up the way `LinalgLoopDistributionOptions` are meant
to be used. The option just contains a call back that takes the list
of loop ranges that represent the loops that are to be distributed.
These loops are the outer parallel loops of the tiled operation which
have non-zero tile sizes specified. The call back returns for each of
the loops,
- The procId to use,
- The number of processors,
- The distribution method to use for that loop.

Reviewed By: antiagainst, hanchung

Differential Revision: https://reviews.llvm.org/D131232
2022-08-15 15:56:17 +00:00
Michele Scuttari b8ecf32f81
DynamicMemRefType: iteration and access by indices
The methods to perform such operations have been implemented for the DynamicMemRefType in a way that is similar to the implementation for StridedMemRefType. Up until here one could pass an unranked memref to the library, and thus obtain a “dynamic” memref descriptor, but then there would have been no possibility to operate on its content.

Differential Revision: https://reviews.llvm.org/D131359
2022-08-15 17:37:39 +02:00
Matthias Springer 4911100dc6 [mlir][linalg][python] Add named constructor for MatchOp
This constructor makes it easier to match for ops by their name.

Differential Revision: https://reviews.llvm.org/D131882
2022-08-15 14:41:28 +02:00
Matthias Springer a36348c586 [mlir][bufferize] Fix bug in AllocTensorElimination
AllocTensorElimination does currently not support chains where the type is
changing. AllocTensorElimination used to generate invalid IR for such
inputs. With this commit, AllocTensorElimination does no longer apply to
such inputs. (It can be extended to support such IR if needed.)

Differential Revision: https://reviews.llvm.org/D131880
2022-08-15 11:45:58 +02:00
Kazu Hirata 6d9cd9199a Use llvm::all_of (NFC) 2022-08-14 16:25:36 -07:00
Kazu Hirata 3a6da9ebcb [mlir] Remove redundant member initialization (NFC)
Identified with readability-redundant-member-init.
2022-08-14 12:51:59 -07:00
Jacques Pienaar b23e72a2e7 [mlir][shape] Rename dim.dim to dim.index (NFC)
dim member on dim was confusing, change to be consistent with
tensor::dim.
2022-08-13 09:34:37 -07:00