aboutsummaryrefslogtreecommitdiff
path: root/mlir
AgeCommit message (Collapse)AuthorFilesLines
2021-08-10[mlir] Avoid including <alloca.h> on FreeBSD and NetBSDDimitry Andric1-0/+4
Instead, include `<cstdlib>` which is the canonical header containing the declaration of `alloca()`. Reviewed By: bondhugula Differential Revision: https://reviews.llvm.org/D107699 (cherry picked from commit ab4b4684a26c31b1eb507a7eb6d2f4ac30764c3d)
2021-08-04Fix a couple regression tests I missed updating in 2a284782Eli Friedman1-4/+4
(cherry picked from commit 6eb2ffbaeb56c8b08ad17c823e1699b964e10b8b)
2021-08-03[mlir] Change ABI breaking use of NDEBUG to LLVM_ENABLE_ABI_BREAKING_CHECKSMarkus Böck2-4/+4
The `DataLayout` class currently contains the member `layoutStack` which is hidden behind a preprocessor region dependant on the NDEBUG macro. Code wise this makes a lot of sense, as the `layoutStack` is used for extra assertions that users will want when compiling a debug build. It however has the uncomfortable consequence of leading to a different ABI in Debug and Release builds. This I think is a bit annoying for downstream projects and others as they may want to build against a stable Release of MLIR in Release mode, but be able to debug their own project depending on MLIR. This patch changes the related uses of NDEBUG to LLVM_ENABLE_ABI_BREAKING_CHECKS. As the macro is computed at configure time of LLVM, it may not change based on compiler settings of a downstream projects like NDEBUG would. Differential Revision: https://reviews.llvm.org/D107227 (cherry picked from commit 97335ad13fd4f231a75163a1e5c232aed5efe921)
2021-07-27[mlir][openacc] Initial translation for DataOp to LLVM IRValentin Clement2-66/+282
Add basic translation of acc.data to LLVM IR with runtime calls. Reviewed By: jdoerfert Differential Revision: https://reviews.llvm.org/D104301
2021-07-27[mlir] Replace LLVM_ATTRIBUTE_NORETURN with C++11 [[noreturn]]Fangrui Song1-1/+1
[[noreturn]] can be used since 2016 when the minimum compiler requirement was bumped to GCC 4.8/MSVC 2015.
2021-07-28Add llvm::equal convenient wrapper for ranges around std::equalMehdi Amini1-4/+1
Differential Revision: https://reviews.llvm.org/D106913
2021-07-27[PDL] Mark PatternOp as SingleBlockRiver Riddle1-1/+3
This provides access to the SingleBlock accessor methods, e.g. getBody().
2021-07-27[PDL] Fix the builders for OperationOp and PatternOpRiver Riddle2-2/+2
2021-07-27[mlir] Add a FailureOr copy constructor from a FailureOr of a convertible type.River Riddle1-0/+4
2021-07-27[PDL] Remove RewriteEndOp and mark RewriteOp as NoTerminatorRiver Riddle2-18/+5
RewriteEndOp was a fake terminator operation that is no longer needed now that blocks are not required to have terminators. Differential Revision: https://reviews.llvm.org/D106911
2021-07-27[mlir] Math: add algebraic simplification patterns to math transformsEugene Zhulenev7-0/+219
Reviewed By: bkramer Differential Revision: https://reviews.llvm.org/D106822
2021-07-27Re-engineer MLIR python build support.Stella Laurenzo20-387/+811
* Implements all of the discussed features: - Links against common CAPI libraries that are self contained. - Stops using the 'python/' directory at the root for everything, opening the namespace up for multiple projects to embed the MLIR python API. - Separates declaration of sources (py and C++) needed to build the extension from building, allowing external projects to build custom assemblies from core parts of the API. - Makes the core python API relocatable (i.e. it could be embedded as something like 'npcomp.ir', 'npcomp.dialects', etc). Still a bit more to do to make it truly isolated but the main structural reset is done. - When building statically, installed python packages are completely self contained, suitable for direct setup and upload to PyPi, et al. - Lets external projects assemble their own CAPI common runtime library that all extensions use. No more possibilities for TypeID issues. - Begins modularizing the API so that external projects that just include a piece pay only for what they use. * I also rolled in a re-organization of the native libraries that matches how I was packaging these out of tree and is a better layering (i.e. all libraries go into a nested _mlir_libs package). There is some further cleanup that I resisted since it would have required source changes that I'd rather do in a followup once everything stabilizes. * Note that I made a somewhat odd choice in choosing to recompile all extensions for each project they are included into (as opposed to compiling once and just linking). While not leveraged yet, this will let us set definitions controlling the namespacing of the extensions so that they can be made to not conflict across projects (with preprocessor definitions). * This will be a relatively substantial breaking change for downstreams. I will handle the npcomp migration and will coordinate with the circt folks before landing. We should stage this and make sure it isn't causing problems before landing. * Fixed a couple of absolute imports that were causing issues. Differential Revision: https://reviews.llvm.org/D106520
2021-07-27[mlir][sparse] fixed bug in verificationAart Bik2-4/+22
The order of testing in two sparse tensor ops was incorrect, which could cause an invalid cast (crashing the compiler instead of reporting the error). This revision fixes that bug. Reviewed By: gussmith23 Differential Revision: https://reviews.llvm.org/D106841
2021-07-27[mlir] Fix typo s/applyPermuationMap/applyPermutationMap/Benjamin Kramer3-10/+10
2021-07-27Define the namespace for the Affine dialect in ODS (NFC)Mehdi Amini2-2/+3
This aligns the structure of the Affine dialect on all the other dialects. In particular this makes the ODS C++ generated code independent of the enclosing namespace.
2021-07-26[MLIR][NFC] Rework some comments.Rahul Joshi4-7/+8
Differential Revision: https://reviews.llvm.org/D106834
2021-07-26[mlir] Make ValueShapeRange a new classJacques Pienaar3-10/+32
Retaining old interface and should be constructable as previous, change would have been NFC except it this doesn't implicitly work with OpAdaptor generated in C++14. Differential Revision: https://reviews.llvm.org/D106772
2021-07-26[MLIR][SCF][NFC] Fix typo in documentation of scf.whileRahul Joshi1-2/+2
- `scf.yield` in the "after" region supplies new arguments to the "before" region. Differential Revision: https://reviews.llvm.org/D106806
2021-07-26[mlir][tosa] Disable tosa shape verification between operands/resultsRob Suderman3-25/+44
Tosa shape verification prevent shape propagation when coming from a dialect of known shape. Relax this constraint to allow ingestion / shape propagation from these other dialects. Differential Revision: https://reviews.llvm.org/D106610
2021-07-26[mlir] split type conversion to two lines for GCC's sakeTres Popp1-1/+4
2021-07-26[mlir] Fix RankedTensorType::walkImmediateSubElements methodVladislav Vinogradov3-0/+7
Add 'enconding' attribute visitor. Without it ASM printer doesn't use attribute aliases for 'enconding'. Reviewed By: rriddle Differential Revision: https://reviews.llvm.org/D105554
2021-07-26[mlir] Added new RegionBranchTerminatorOpInterface and adapted uses of ↵Marcel Koester12-71/+208
hasTrait<ReturnLike>. This CL adds a new RegionBranchTerminatorOpInterface to query information about operands that can be passed to successor regions. Similar to the BranchOpInterface, it allows to freely define the involved operands. However, in contrast to the BranchOpInterface, it expects an additional region number to distinguish between various use cases which might require different operands passed to different regions. Moreover, we added new utility functions (namely getMutableRegionBranchSuccessorOperands and getRegionBranchSuccessorOperands) to query (mutable) operand ranges for operations equiped with the ReturnLike trait and/or implementing the newly added interface. This simplifies reasoning about terminators in the scope of the nested regions. We also adjusted the SCF.ConditionOp to benefit from the newly added capabilities. Differential Revision: https://reviews.llvm.org/D105018
2021-07-24[mlir] Async: lower SCF operations into CFG inside coroutinesEugene Zhulenev3-1/+58
Reviewed By: mehdi_amini Differential Revision: https://reviews.llvm.org/D106747
2021-07-24[mlir] Restore markUnknownOpDynamicallyLegal to call isDynamicallyLegal by ↵Benjamin Kramer1-1/+2
default Looks like an oversight from b7a464989955e6374b39b518e317b59b510d4dc5 This should probably have a test case ...
2021-07-24[mlir] ConversionTarget legality callbacks refactoringButygin2-25/+23
* Get rid of Optional<std::function> as std::function already have a null state * Add private setLegalityCallback function to set legality callback for unknown ops * Get rid of unknownOpsDynamicallyLegal flag, use unknownLegalityFn state insted. This causes behavior change when user first calls markUnknownOpDynamicallyLegal with callback and then without but I am not sure is the original behavior was really a 'feature', or just oversignt in the original implementation. Differential Revision: https://reviews.llvm.org/D105496
2021-07-23[MLIR][NFC] Minor cleanup in liveness.Rahul Joshi2-23/+15
- Rename isLastUse to isDeadAfter to reflect what the function does. - Avoid a second walk over all operations in BlockInfoBuilder constructor. - use std::move() to save the new in set. Differential Revision: https://reviews.llvm.org/D106702
2021-07-23[mlir][linalg] Add pooling_nchw_max, conv_2d_nchw as yaml ops.Yi Zhang6-10/+229
- Add pooling_nchw_max. - Move conv_2d_nchw to yaml ops and add strides and dilation attributes. Reviewed By: gysit Differential Revision: https://reviews.llvm.org/D106658
2021-07-23[mlir][linalg] Fix bug in contraction op vectorization with output permthomasraoux4-21/+71
When the output indexing map has a permutation we need to consider in the contraction vector type. Differential Revision: https://reviews.llvm.org/D106469
2021-07-23[mlir][Complex]: Add lowerings for AddOp and SubOp from Complex dialect toAdrian Kuegel2-6/+63
Standard. Differential Revision: https://reviews.llvm.org/D106429
2021-07-23[mlir] Async: special handling for parallel loops with zero iterationsEugene Zhulenev3-56/+104
Reviewed By: mehdi_amini Differential Revision: https://reviews.llvm.org/D106590
2021-07-23[mlir][Linalg] Fix a missing copy when source of insert_slice is not inplace.Nicolas Vasilache2-8/+88
When the source tensor of a tensor.insert_slice is not equivalent to an inplace buffer an extra copy is necessary. This revision adds the missing copy. Reviewed By: gysit Differential Revision: https://reviews.llvm.org/D106587
2021-07-22[mlir] Fix comment typosJacques Pienaar1-6/+6
2021-07-22[mlir][tosa] Make tosa MakeBroadcastable pass handle unreanked tensors.Rob Suderman1-19/+32
If this pass executes without shape inference its possible for unranked tensors to appear in the IR. This pass should gracefully handle unranked tensors. Differential Revision: https://reviews.llvm.org/D106617
2021-07-22[mlir][tosa] Quantized Conv2DOp lowering to linalg added.Rob Suderman5-12/+201
Includes a version of a quantized conv2D operations with a lowering from TOSA to linalg with corresponding test. We keep the quantized and quantized variants as separate named ops to avoid the additional operations for non-quantized convolutions. Differential Revision: https://reviews.llvm.org/D106407
2021-07-22[mlir] Also update inferReturnTensorTypes (NFC)Jacques Pienaar2-2/+2
Missed this one in the first go.
2021-07-22[mlir] Update to use ValueShapeRange (NFC)Jacques Pienaar2-19/+19
Update to use alias in preparation for changing it to not just be a pure alias.
2021-07-22[mlir] Improve description of interface optionsMarius Brehler1-8/+14
Reviewed By: rriddle Differential Revision: https://reviews.llvm.org/D106539
2021-07-22[MLIR][memref] Fix findDealloc() to handle > 1 dealloc for the given alloc.Rahul Joshi6-26/+82
- Change findDealloc() to return Optional<Operation *> and return None if > 1 dealloc is associated with the given alloc. - Add findDeallocs() to return all deallocs associated with the given alloc. - Fix current uses of findDealloc() to bail out if > 1 dealloc is found. Differential Revision: https://reviews.llvm.org/D106456
2021-07-22[mlir] Fix various issues in TimerImpl.rdzhabarov1-4/+4
More specifically: 1) Use variable after move. 2) steady_clock needs to be used for measuring time intervals, but not the system_clock. Reviewed By: mehdi_amini Differential Revision: https://reviews.llvm.org/D106513
2021-07-22[MLIR] Fix affine.for empty loop body folderUday Bondhugula2-7/+13
Fix affine.for empty loop body folder in the presence of yield values. The existing pattern ignored iter_args/yield values and thus crashed when yield values had uses. Reviewed By: mehdi_amini Differential Revision: https://reviews.llvm.org/D106121
2021-07-21[mlir] Extend scf pipeling to support loop carried dependenciesthomasraoux2-9/+207
Differential Revision: https://reviews.llvm.org/D106325
2021-07-21[mlir] Add workaround for false positive in -Wfree-nonheap-objectFangrui Song1-3/+8
Restore 499571ea835daf786626a0db1e12f890b6cd8f8d reverted by 0082764605cc0e7e0363a41ffa77d214c3157aa6. A compiler slightly older than "[clang][Sema] removes -Wfree-nonheap-object reference param false positive" may report the false positive. We need to retain the workaround a bit longer so that such compilers can be used to compile MLIR in a warning-free way.
2021-07-21Add verifier for insert/extract element/value on type match between ↵Mehdi Amini4-1/+141
container and inserted/extracted value, and fix vector.shuffle lowering Reviewed By: nicolasvasilache Differential Revision: https://reviews.llvm.org/D106398
2021-07-21[mlir][LLVM] Revert bareptr calling convention handling as an argument ↵Nicolas Vasilache3-13/+84
materialization. Type conversion and argument materialization are context-free: there is no available information on which op / branch is currently being converted. As a consequence, bare ptr convention cannot be handled as an argument materialization: it would apply irrespectively of the parent op. This doesn't typecheck in the case of non-funcOp and we would see cases where a memref descriptor would be inserted in place of the pointer in another memref descriptor. For now the proper behavior is to revert to a specific BarePtrFunc implementation and drop the blanket argument materialization logic. This reverts the relevant piece of the conversion to LLVM to what it was before https://reviews.llvm.org/D105880 and adds a relevant test and documentation to avoid the mistake by whomever attempts this again in the future. Reviewed By: arpith-jacob Differential Revision: https://reviews.llvm.org/D106495
2021-07-21Revert "Add workaround for false positive in -Wfree-nonheap-object"Christopher Di Bella1-8/+3
This reverts commit 499571ea835daf786626a0db1e12f890b6cd8f8d.
2021-07-21[mlir] Add alias for input to shaped type op interfaceJacques Pienaar2-1/+5
Range type that allows for wrapping different value & shape ranges with correspondence to Shape's ValueShape type - initially aliased to ValueRange (which corresponds to the trivial mapping from a ShapedType's Value's shape to shape). Just plain alias, before expanding. Differential Revision: https://reviews.llvm.org/D99133
2021-07-21[MLIR] Add folder for zero trip count affine.forUday Bondhugula3-9/+51
AffineForOp's folding hook is expected to fold away trivially empty affine.for. This allows simplification to happen as part of the canonicalizer and from wherever the folding hook is used. While more complex analysis based zero trip count detection is available from other passes in analysis and transforms, simple and inexpensive folding had been missing. Also, update/improve affine.for op documentation clarifying semantics of the result values for zero trip count loops. Differential Revision: https://reviews.llvm.org/D106123
2021-07-21[MLIR] Introduce a new rewrite driver to simplify supplied list of opsUday Bondhugula8-53/+225
Introduce a new rewrite driver (MultiOpPatternRewriteDriver) to rewrite a supplied list of ops and other ops. Provide a knob to restrict rewrites strictly to those ops or also to affected ops (but still not to completely related ops). This rewrite driver is commonly needed to run any simplification and cleanup at the end of a transforms pass or transforms utility in a way that only simplifies relevant IR. This makes it easy to write test cases while not performing unrelated whole IR simplification that may invalidate other state at the caller. The introduced utility provides more freedom to developers of transforms and transform utilities to perform focussed and local simplification. In several cases, it provides greater efficiency as well as more simplification when compared to repeatedly calling `applyOpPatternsAndFold`; in other cases, it avoids the need to undesirably call `applyPatternsAndFoldGreedily` to do unrelated simplification in a FuncOp. Update a few transformations that were earlier using applyOpPatternsAndFold (SimplifyAffineStructures, affineDataCopyGenerate, a linalg transform). TODO: - OpPatternRewriteDriver can be removed as it's a special case of MultiOpPatternRewriteDriver, i.e., both can be merged. Differential Revision: https://reviews.llvm.org/D106232
2021-07-21[llvm] Add enum iteration to SequenceGuillaume Chatelet1-2/+2
This patch allows iterating typed enum via the ADT/Sequence utility. It also changes the original design to better separate concerns: - `StrongInt` only deals with safe `intmax_t` operations, - `SafeIntIterator` presents the iterator and reverse iterator interface but only deals with safe `StrongInt` internally. - `iota_range` only deals with `SafeIntIterator` internally. This design ensures that operations are always valid. In particular, "Out of bounds" assertions fire when: - the `value_type` is not representable as an `intmax_t` - iterator operations make internal computation underflow/overflow - the internal representation cannot be converted back to `value_type` Differential Revision: https://reviews.llvm.org/D106279
2021-07-21[mlir-tblgen] Support binding multi-results of NativeCodeCallChia-hung Duan8-45/+226
We are able to bind NativeCodeCall result as binding operation. To make table-gen have better understanding in the form of helper function, we need to specify the number of return values in the NativeCodeCall template. A VoidNativeCodeCall is added for void case. Reviewed By: jpienaar Differential Revision: https://reviews.llvm.org/D102160