Commit Graph

11989 Commits

Author SHA1 Message Date
Jacques Pienaar 72686d68c1 [mlir] Explicitly mark dialect prefixing
Missed previously and needed to flip the default. Most of these just
flipped to _Raw to retain existing state/keep this small except for TOSA
dialect which got flipped to _Both as no further change was needed..
2022-07-21 12:58:19 -07:00
John Ericson 07b749800c [cmake] Don't export `LLVM_TOOLS_INSTALL_DIR` anymore
First of all, `LLVM_TOOLS_INSTALL_DIR` put there breaks our NixOS
builds, because `LLVM_TOOLS_INSTALL_DIR` defined the same as
`CMAKE_INSTALL_BINDIR` becomes an *absolute* path, and then when
downstream projects try to install there too this breaks because our
builds always install to fresh directories for isolation's sake.

Second of all, note that `LLVM_TOOLS_INSTALL_DIR` stands out against the
other specially crafted `LLVM_CONFIG_*` variables substituted in
`llvm/cmake/modules/LLVMConfig.cmake.in`.

@beanz added it in d0e1c2a550 to fix a
dangling reference in `AddLLVM`, but I am suspicious of how this
variable doesn't follow the pattern.

Those other ones are carefully made to be build-time vs install-time
variables depending on which `LLVMConfig.cmake` is being generated, are
carefully made relative as appropriate, etc. etc. For my NixOS use-case
they are also fine because they are never used as downstream install
variables, only for reading not writing.

To avoid the problems I face, and restore symmetry, I deleted the
exported and arranged to have many `${project}_TOOLS_INSTALL_DIR`s.
`AddLLVM` now instead expects each project to define its own, and they
do so based on `CMAKE_INSTALL_BINDIR`. `LLVMConfig` still exports
`LLVM_TOOLS_BINARY_DIR` which is the location for the tools defined in
the usual way, matching the other remaining exported variables.

For the `AddLLVM` changes, I tried to copy the existing pattern of
internal vs non-internal or for LLVM vs for downstream function/macro
names, but it would good to confirm I did that correctly.

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D117977
2022-07-21 19:04:00 +00:00
Jacques Pienaar a1ec0d8bdc [mlir] Flip dialects to _Prefixed
At least two weeks passed since flipped to _Both. Made some additional
NFC changes in .td files that were not converted earlier.
2022-07-21 12:03:07 -07:00
George Petterson a935a0bf50 Adding a new variant of DepthwiseConv2D
This is the same as the existing multiplier-1 variant of DepthwiseConv2D, but in PyTorch dim order.

Reviewed By: nicolasvasilache

Differential Revision: https://reviews.llvm.org/D128575
2022-07-21 14:36:57 -04:00
Javed Absar 56094296f5 Fix type in documentation
Reviewed By: bondhugula

Differential Revision: https://reviews.llvm.org/D130274
2022-07-21 18:42:31 +01:00
Jakub Kuderski 52b630da02 [mlir][spirv] Rename spv.GLSL ops to spv.GL. NFC.
This is to improve consistency within the SPIR-V dialect and make these ops a bit shorter.

Reviewed By: antiagainst

Differential Revision: https://reviews.llvm.org/D130280
2022-07-21 13:03:30 -04:00
Christopher Bate 297ba167de [mlir][linalg] Add tile_size option to `structured.tile_to_foreach_thread_op`
This change modifies `structured.tile_to_foreach_thread_op` so that
it accepts either `tile_sizes` or `num_threads` parameters. If
`tile_sizes` are specified, then the number of threads required is
derived the tile sizes rather than the other way around. In both cases,
more aggressive folding of loop parameters is enabled during the
transformation, allowing for the potential elimination of `affine.min`
and `affine.max` operations in the static shape case when calculating
the final adjusted tile size.

Differential Revision: https://reviews.llvm.org/D130139
2022-07-21 10:32:01 -06:00
Alex Zinenko ee168fb90e [mlir][python] Fix issues with block argument slices
The type extraction helper function for block argument and op result
list objects was ignoring the slice entirely. So was the slice addition.
Both are caused by a misleading naming convention to implement slices
via CRTP. Make the convention more explicit and hide the helper
functions so users have harder time calling them directly.

Closes #56540.

Reviewed By: stellaraccident

Differential Revision: https://reviews.llvm.org/D130271
2022-07-21 14:41:12 +00:00
Nicolas Vasilache 1f77f01c65 [mlir][Linalg] Add a Transform dialect NavigationOp op to match a list of ops or an interface.
This operation is a NavigationOp that simplifies the writing of transform IR.
Since there is no way of refering to an interface by name, the current implementation uses
an EnumAttr and depends on the interfaces it supports.
In the future, it would be worthwhile to remove this dependence and generalize.

Differential Revision: https://reviews.llvm.org/D130267
2022-07-21 07:11:42 -07:00
Ivan Butygin d4217e6cc8 [mlir][memref] Missing type conversion in memref.reshape llvm lowering
Shape can be memref of index type, so memref::LoadOp result need to be converted into llvm type.

Differential Revision: https://reviews.llvm.org/D129965
2022-07-21 11:15:35 +02:00
lorenzo chelini 2ed7c3fd84 [MLIR][SCF] Enable better bufferization for `TileConsumerAndFuseProducersUsingSCFForOp`
Replace iterators of the outermost loop with region arguments of the innermost
one. The changes avoid later `bufferization` passes to insert allocation within
the body of the innermost loop.

Reviewed By: mravishankar

Differential Revision: https://reviews.llvm.org/D130083
2022-07-21 10:14:26 +02:00
lorenzo chelini 7f1c03171d Revert "[RFC][MLIR][SCF] Enable better bufferization for `TileConsumerAndFuseProducersUsingSCFForOp`"
This reverts commit 9e65850305.
2022-07-21 09:40:30 +02:00
lorenzo chelini 9e65850305 [RFC][MLIR][SCF] Enable better bufferization for `TileConsumerAndFuseProducersUsingSCFForOp`
Replace iterators of the outermost loop with region arguments of the innermost
one. The changes avoid later `bufferization` passes to insert allocation within
the body of the innermost loop.

Reviewed By: mravishankar

Differential Revision: https://reviews.llvm.org/D130083
2022-07-21 08:56:50 +02:00
Mahesh Ravishankar 485190df95 [mlir][Linalg] Deprecate `tileAndFuseLinalgOps` method and associated patterns.
The `tileAndFuseLinalgOps` is a legacy approach for tiling + fusion of
Linalg operations. Since it was also intended to work on operations
with buffer operands, this method had fairly complex logic to make
sure tile and fuse was correct even with side-effecting linalg ops.
While complex, it still wasnt robust enough. This patch deprecates
this method and thereby deprecating the tiling + fusion method for ops
with buffer semantics. Note that the core transformation to do fusion
of a producer with a tiled consumer still exists. The deprecation here
only removes methods that auto-magically tried to tile and fuse
correctly in presence of side-effects.

The `tileAndFuseLinalgOps` also works with operations with tensor
semantics. There are at least two other ways the same functionality
exists.
1) The `tileConsumerAndFuseProducers` method. This does a similar
   transformation, but using a slightly different logic to
   automatically figure out the legal tile + fuse code. Note that this
   is also to be deprecated soon.
2) The prefered way uses the `TilingInterface` for tile + fuse, and
   relies on the caller to set the tiling options correctly to ensure
   that the generated code is correct.
As proof that (2) is equivalent to the functionality provided by
`tileAndFuseLinalgOps`, relevant tests have been moved to use the
interface, where the test driver sets the tile sizes appropriately to
generate the expected code.

Differential Revision: https://reviews.llvm.org/D129901
2022-07-21 05:05:06 +00:00
jacquesguan 9c22853ec4 [mlir][Math] Add constant folder for LogOp.
This patch adds constant folder for LogOp which only supports single and double precision floating-point.

Reviewed By: ftynse

Differential Revision: https://reviews.llvm.org/D130148
2022-07-21 10:58:32 +08:00
River Riddle ed344c8877 [mlir:LSP] Add a quickfix code action for inserting expected-* diagnostic checks
This allows for automatically inserting expected checks for parser and verifier
diagnostics, which simplifies the workflow when building new dialect
constructs or extending existing ones.

Differential Revision: https://reviews.llvm.org/D130152
2022-07-20 15:43:59 -07:00
Tanyo Kwok 5b0d6bf210 [MLIR] Add function to create Float16 array attribute
This patch adds a new function mlirDenseElementsAttrFloat16Get(),
which accepts the shaped type, the number of Float16 values, and a
pointer to an array of Float16 values, each of which is a uint16_t
value.

This commit is repeating https://reviews.llvm.org/D123981 + #761 but for Float16

Differential Revision: https://reviews.llvm.org/D130069
2022-07-20 21:58:15 +00:00
Jakub Kuderski 3930cc6847 [mlir][spirv] Rename spv.ocl to spv.cl. NFC.
This is to improve the consistency within the SPIR-V dialect and to make op names a bit shorter.

Reviewed By: antiagainst

Differential Revision: https://reviews.llvm.org/D130194
2022-07-20 17:46:45 -04:00
River Riddle b64a286332 [mlir:LSP] Add a doc blurb for code completion
This also gets used for the vscode extension documentation.
2022-07-20 12:02:13 -07:00
River Riddle 362c4e68c9 [mlir:LSP] Remove several more annoying completion commit characters
These characters are annoying in that they accept completions
that weren't intended, causing user frustration.
2022-07-20 12:02:13 -07:00
Kazu Hirata 360c1111e3 Use llvm::is_contained (NFC) 2022-07-20 09:09:19 -07:00
Ingo Müller 000e426449 [mlir][bufferize][doc] Fix documentation of return type of `to_memref`.
This is my very first contact with this dialect, so I am not very
confident with this commit, but it seems like the op returns a memref,
not a tensor, so that's what comment about the result type should say.

[mlir][bufferization][doc] Improve typesetting of inline code. Fix Typo.

Reviewed By: pifon2a

Differential Revision: https://reviews.llvm.org/D130159
2022-07-20 13:21:49 +00:00
River Riddle ee7ccbeaa7 [mlir:LSP][NFC] Make the LSPServer class private
There is no benefit to making it public, and the code is much
cleaner and easier to follow when inlined. This also matches
the pattern within the PDLL lsp server.
2022-07-20 01:43:30 -07:00
Anush Elangovan f9676d2d22 [mlir] Fix macOS tests
Fix shared library names on macOS for execution_engine.py test.

Reviewed By: stellaraccident

Differential Revision: https://reviews.llvm.org/D130143
2022-07-20 10:19:05 +02:00
jacquesguan c3d856bf58 [mlir][Math] Add constant folder for Log1pOp.
This patch adds constant folder for Log1pOp which only supports single and double precision floating-point.

Differential Revision: https://reviews.llvm.org/D129979
2022-07-20 14:59:35 +08:00
Mahesh Ravishankar b8a1f00d41 [mlir][TilingInterface] Add support for interchange to tiling patterns that use the `TilingInterface`.
Differential Revision: https://reviews.llvm.org/D129956
2022-07-20 05:24:17 +00:00
Jacques Pienaar c35807f271 [mlir] Address compiler warning 2022-07-19 20:03:03 -07:00
River Riddle 7d815ab9b4 [mlir][NFC] Split out various tests from IR/invalid.mlir
This file contains a huge number of tests that should really be in
different dialect/files. It is monolothic because of the legacy
surrounding the old standard dialect, affine operations, etc. Splitting
this up makes the tests much more maintainable given that they are now
group with other similar tests.
2022-07-19 16:34:35 -07:00
Slava Zakharin 04644a9e55 [mlir] Fixed ordering of pass statistics.
The change makes sure the plain C string statistics names
are properly ordered.

Differential Revision: https://reviews.llvm.org/D130122
2022-07-19 15:52:02 -07:00
Jacques Pienaar d2c0572b2e [mlir] Flip LinAlg dialect to _Both
This one required more changes than ideal due to overlapping generated name
with different return types. Changed getIndexingMaps to getIndexingMapsArray to
move it out of the way/highlight that it returns (more expensively) a
SmallVector and uses the prefixed name for the Attribute.

Differential Revision: https://reviews.llvm.org/D129919
2022-07-19 14:42:58 -07:00
Benoit Jacob f0c3fd185e Don't combine if there would remain no true reduction dim.
Differential Revision: https://reviews.llvm.org/D130109
2022-07-19 19:58:53 +00:00
Rajas Vanjape 9451440f82 [mlir][docs] Fix pass manager document
The code example for pass manager incorrectly uses nestedFunctionPM
instead of nestedAnyPm for adding CSE and Canonicalize Passes. This diff fixes
it by changing it to nestedAnyPm.

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D130110
2022-07-19 19:52:57 +00:00
Jeff Niu 2d05418b17 Revert "[mlir][ods] (NFC) Remove warning in `AttrOrTypeDef`"
This reverts commit e45ef5ebf4.
2022-07-19 10:25:24 -07:00
Jeff Niu e45ef5ebf4 [mlir][ods] (NFC) Remove warning in `AttrOrTypeDef`
This warning was added because using attribute or type assembly formats
with `skipDefaultBuilders` set could cause compilation errors, since the
required builder prototype may not necessarily be generated and would
need to be checked by hand. This patch removes the warning because a
warning that the generated C++ "might" not compile is not particularly
useful. Attempting to address the TODO (i.e. detect whether a builder of
the correct prototype is provided) would be fragile since it would not
be possible to account for implicit conversions, etc.

In general, ODS should not be emitting warnings in cases like these.
2022-07-19 09:17:19 -07:00
bhatuzdaname 7f76471ee8 [mlir][tblgen] Add support for extraClassDefinition in AttrDef
For AttrDef declarations, place specified code in extraClassDefinition into the generated *.cpp.inc file.

Reviewed By: Mogball, rriddle

Differential Revision: https://reviews.llvm.org/D129574
2022-07-19 09:13:32 -07:00
lipracer 71da3914c1 [mlir][NFC] Use proper c++ namespaces in .td files
td files:
mlir::ArrayRef => llvm::ArrayRef
mlir::Optional=>llvm::Optional
mlir::SmallVector => llvm::SmallVector

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D128537
2022-07-19 08:51:21 -07:00
Nicolas Vasilache 18b92c66fe [mlir][Linalg] Add a TileToForeachThread transform.
This revision adds a new transformation to tile a TilingInterface `op` to a tiled `scf.foreach_thread`, applying
tiling by `num_threads`.
If non-empty, the `threadDimMapping` is added as an attribute to the resulting `scf.foreach_thread`.
0-tile sizes (i.e. tile by the full size of the data) are used to encode
that a dimension is not tiled.

Differential Revision: https://reviews.llvm.org/D129577
2022-07-19 04:56:11 -07:00
Markus Böck 61394636f0 [mlir] Ignore effects on allocated results when checking whether the op is trivially dead.
In the current state, this is only special cased for Allocation effects, but any effects on results allocated by the operation may be ignored when checking whether the op may be removed, as none of them are possible to be observed if the result is unused.

A use case for this is for IRs for languages which always initialize on allocation. To correctly model such operations, a Write as well as an Allocation effect should be placed on the result. This would prevent the Op from being deleted if unused however. This patch fixes that issue.

Differential Revision: https://reviews.llvm.org/D129854
2022-07-19 10:58:25 +02:00
Matthias Springer 106d695287 [mlir][sparse][NFC] Update remaining test cases
No more to_memref, memref.alloc or memref.dealloc when possible.

Differential Revision: https://reviews.llvm.org/D130023
2022-07-19 09:21:10 +02:00
Matthias Springer 27a431f5e9 [mlir][bufferization][NFC] Move sparse_tensor.release to bufferization dialect
This op used to belong to the sparse dialect, but there are use cases for dense bufferization as well. (E.g., when a tensor alloc is returned from a function and should be deallocated at the call site.) This change moves the op to the bufferization dialect, which now has an `alloc_tensor` and a `dealloc_tensor` op.

Differential Revision: https://reviews.llvm.org/D129985
2022-07-19 09:18:19 +02:00
Jacques Pienaar c8598fa22f [mlir] Add refineReturnTypes to InferTypeOpInterface
refineReturnType method shares the same parameters as inferReturnTypes
but gets passed in the return types of the op if known that can be used
during refinement passes or for more op specific error reporting.
Currently the error reporting on failure is generic and doesn't allow
for specializing the returned result based on failure, with this change
what would previously have been a separate trait with specialized
verification can just be handled as part of inferrence rather than
duplicated.

refineReturnTypes behaves like inferReturnTypes if no result types are fed in,
while the current verification is recast as the default implementation for
refineReturnTypes with it calling inferReturnTypes (and so the default type
verification now goes through refine and allows for more op specific inference
mismatch errors).

Differential Revision: https://reviews.llvm.org/D129955
2022-07-18 22:18:52 -07:00
Mehdi Amini d04c2b2fd9 Revert "[MLIR] Generic 'malloc', 'aligned_alloc' and 'free' functions"
This reverts commit 3e21fb616d.

A lot of integration tests are failing on the bot.
2022-07-18 18:07:36 +00:00
Arjun P 477c2c6f4a [MLIR][Presburger] fix warning under g++ (NFC) 2022-07-18 18:02:20 +01:00
Arjun P ffb8b7b2a0 [MLIR][Presburger] Provide functions to convert between arrays of MPInt and int64_t
Reviewed By: Groverkss

Differential Revision: https://reviews.llvm.org/D129509
2022-07-18 17:34:50 +01:00
Arjun P ca6a5afbb2 [MLIR][Presburger] SlowMPInt: fix bug in ceilDiv, floorDiv where widths weren't harmonized
This also adds tests for abs, ceilDiv, floorDiv, mod, gcd and lcm.

Reviewed By: Groverkss

Differential Revision: https://reviews.llvm.org/D129816
2022-07-18 17:34:01 +01:00
Aart Bik 28ebb0b61d [mlir][sparse] migrate sparse rewriting to sparse transformations pass
The rules in the linalg file were very specific to sparse tensors so will
find a better home under sparse tensor dialect than linalg dialect. Also
moved some rewriting from sparsification into this new "pre-rewriting" file.

Reviewed By: springerm

Differential Revision: https://reviews.llvm.org/D129910
2022-07-18 09:29:22 -07:00
Alexander Batashev e59cdcd070 [mlir][spirv] Allow unnamed entry point functions
SPIR-V specification does not require a function to have a name
if it is an entry point. Adjust deserializer to allow those kinds
of SPIR-V binaries.

Reviewed By: antiagainst

Differential Revision: https://reviews.llvm.org/D120181
2022-07-18 12:03:38 -04:00
Michele Scuttari 3e21fb616d [MLIR] Generic 'malloc', 'aligned_alloc' and 'free' functions
When converted to the LLVM dialect, the memref.alloc and memref.free operations were generating calls to hardcoded 'malloc' and 'free' functions. This didn't leave any freedom to users to provide their custom implementation. Those operations now convert into calls to '_mlir_alloc' and '_mlir_free' functions, which have also been implemented into the runtime support library as wrappers to 'malloc' and 'free'. The same has been done for the 'aligned_alloc' function.

Reviewed By: ftynse

Differential Revision: https://reviews.llvm.org/D128791
2022-07-18 17:58:58 +02:00
jacquesguan a5cae20bdb [mlir][Math] Add constant folder for Log10Op.
This patch adds constant folder for Log10Op which only support single and double precision floating-point.

Reviewed By: Mogball

Differential Revision: https://reviews.llvm.org/D129740
2022-07-18 10:19:25 +08:00
Kazu Hirata 10bcfeebfa [mlir] Remove unused using (NFC)
Identified with misc-unused-using-decls.
2022-07-17 18:08:48 -07:00