summaryrefslogtreecommitdiffstats
path: root/mlir/test/Transforms
Commit message (Collapse)AuthorAgeFilesLines
* [mlir] : Fix ViewOp shape folder for identity affine mapsAhmed Taei2020-01-151-1/+2
| | | | | | | | | | | | Summary: Fix the ViewOpShapeFolder in case of no affine mapping associated with a Memref construct identity mapping. Reviewers: nicolasvasilache Subscribers: mehdi_amini, rriddle, jpienaar, burmako, shauheen, antiagainst, arpith-jacob, mgester, lucyrfox, liufengdb, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D72735
* [mlir] Change the syntax of AffineMapAttr and IntegerSetAttr to avoid ↵River Riddle2020-01-1329-583/+584
| | | | | | | | | | conflicts with function types. Summary: The current syntax for AffineMapAttr and IntegerSetAttr conflict with function types, making it currently impossible to round-trip function types(and e.g. FuncOp) in the IR. This revision changes the syntax for the attributes by wrapping them in a keyword. AffineMapAttr is wrapped with `affine_map<>` and IntegerSetAttr is wrapped with `affine_set<>`. Reviewed By: nicolasvasilache, ftynse Differential Revision: https://reviews.llvm.org/D72429
* [MLIR] Don't use SSA names directly for std.view canonicalization testAhmed Taei2020-01-081-5/+5
| | | | | | | | | | Reviewers: rriddle, nicolasvasilache Subscribers: mehdi_amini, jpienaar, burmako, shauheen, antiagainst, arpith-jacob, mgester, lucyrfox, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D72408
* Canonicalize static alloc followed by memref_cast and std.viewAhmed Taei2020-01-081-3/+8
| | | | | | | | | | | | Summary: Rewrite alloc, memref_cast, std.view into allo, std.view by droping memref_cast. Reviewers: nicolasvasilache Subscribers: mehdi_amini, rriddle, jpienaar, burmako, shauheen, antiagainst, arpith-jacob, mgester, lucyrfox, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D72379
* Add integer bit-shift operations to the standard dialect.Manuel Freiberger2019-12-225-67/+67
| | | | | | | | | | | | | | | | | | | Rename the 'shlis' operation in the standard dialect to 'shift_left'. Add tests for this operation (these have been missing so far) and add a lowering to the 'shl' operation in the LLVM dialect. Add also 'shift_right_signed' (lowered to LLVM's 'ashr') and 'shift_right_unsigned' (lowered to 'lshr'). The original plan was to name these operations 'shift.left', 'shift.right.signed' and 'shift.right.unsigned'. This works if the operations are prefixed with 'std.' in MLIR assembly. Unfortunately during import the short form is ambigous with operations from a hypothetical 'shift' dialect. The best solution seems to omit dots in standard operations for now. Closes tensorflow/mlir#226 PiperOrigin-RevId: 286803388
* fix isValidDim for block arg caseUday Bondhugula2019-12-201-4/+3
| | | | | | | | | | | | | - a block argument associated with an arbitrary op can't be a valid dimensional identifier; it has to be the block argument of either a function op or an affine.for. Signed-off-by: Uday Bondhugula <uday@polymagelabs.com> Closes tensorflow/mlir#331 COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/331 from bondhugula:valid_dim 3273b4fcbaa31fb7b6671d93c9e42a6b2a6a4e4c PiperOrigin-RevId: 286593693
* Introduce prefetch op: affine -> std -> llvm intrinsicUday Bondhugula2019-12-181-0/+13
| | | | | | | | | | | | | | | | | | | Introduce affine.prefetch: op to prefetch using a multi-dimensional subscript on a memref; similar to affine.load but has no effect on semantics, but only on performance. Provide lowering through std.prefetch, llvm.prefetch and map to llvm's prefetch instrinsic. All attributes reflected through the lowering - locality hint, rw, and instr/data cache. affine.prefetch %0[%i, %j + 5], false, 3, true : memref<400x400xi32> Signed-off-by: Uday Bondhugula <uday@polymagelabs.com> Closes tensorflow/mlir#225 COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/225 from bondhugula:prefetch 4c3b4e93bc64d9a5719504e6d6e1657818a2ead0 PiperOrigin-RevId: 286212997
* Try to fold operations in DialectConversion when trying to legalize.River Riddle2019-12-132-24/+19
| | | | | | This change allows for DialectConversion to attempt folding as a mechanism to legalize illegal operations. This also expands folding support in OpBuilder::createOrFold to generate new constants when folding, and also enables it to work in the context of a PatternRewriter. PiperOrigin-RevId: 285448440
* More affine expr simplifications for floordiv and modUday Bondhugula2019-12-102-3/+3
| | | | | | | | | | | | | | | | | | | | | | Add one more simplification for floordiv and mod affine expressions. Examples: (2*d0 + 1) floordiv 2 is simplified to d0 (8*d0 + 4*d1 + d2) floordiv 4 simplified to 4*d0 + d1 + d2 floordiv 4. etc. Similarly, (4*d1 + 1) mod 2 is simplified to 1, (2*d0 + 8*d1) mod 8 simplified to 2*d0 mod 8. Change getLargestKnownDivisor to return int64_t to be consistent and to avoid casting at call sites (since the return value is used in expressions of int64_t/index type). Signed-off-by: Uday Bondhugula <uday@polymagelabs.com> Closes tensorflow/mlir#202 COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/202 from bondhugula:affine b13fcb2f1c00a39ca5434613a02408e085a80e77 PiperOrigin-RevId: 284866710
* Minor spelling tweaksKazuaki Ishizaki2019-12-091-1/+1
| | | | | | Closes tensorflow/mlir#304 PiperOrigin-RevId: 284568358
* DimOp folding for alloc/view dynamic dimensionsUday Bondhugula2019-12-061-1/+57
| | | | | | | | | Signed-off-by: Uday Bondhugula <uday@polymagelabs.com> Closes tensorflow/mlir#253 COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/253 from bondhugula:dimop a4b464f24ae63fd259114558d87e11b8ee4dae86 PiperOrigin-RevId: 284169689
* Drop MaterializeVectorTransfers in favor of simpler declarative unrollingNicolas Vasilache2019-12-044-387/+0
| | | | | | Now that we have unrolling as a declarative pattern, we can drop a full pass that has gone stale. In the future we may want to add specific unrolling patterns for VectorTransferReadOp. PiperOrigin-RevId: 283806880
* Loop coalescing: fix pointer chainsing in use-chain traversalAlex Zinenko2019-12-041-0/+32
| | | | | | | | | | | | | | | In the replaceAllUsesExcept utility function called from loop coalescing the iteration over the use-chain is incorrect. The use list nodes (IROperands) have next/prev links, and bluntly resetting the use would make the loop to continue on uses of the value that was replaced instead of the original one. As a result, it could miss the existing uses and update the wrong ones. Make sure we increment the iterator before updating the use in the loop body. Reported-by: Uday Bondhugula <uday@polymagelabs.com> Closes tensorflow/mlir#291. PiperOrigin-RevId: 283754195
* AffineLoopFusion: Prevent fusion of multi-out-edge producer loopsDiego Caballero2019-12-031-0/+53
| | | | | | | | | | | | | tensorflow/mlir#162 introduced a bug that incorrectly allowed fusion of producer loops with multiple outgoing edges. This commit fixes that problem. It also introduces a new flag to disable sibling loop fusion so that we can test producer-consumer fusion in isolation. Closes tensorflow/mlir#259 COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/259 from dcaballe:dcaballe/fix_multi_out_edge_producer_fusion 578d5661705fd5c56c555832d5e0528df88c5282 PiperOrigin-RevId: 283531105
* Make std.divis and std.diviu support ElementsAttr folding.Ben Vanik2019-11-251-9/+71
| | | | PiperOrigin-RevId: 282434465
* Support folding of StandardOps with DenseElementsAttr.Ben Vanik2019-11-241-0/+28
| | | | PiperOrigin-RevId: 282270243
* Add more canonicalizations for SubViewOp.Mahesh Ravishankar2019-11-221-10/+62
| | | | | | | | | | Depending on which of the offsets, sizes, or strides are constant, the subview op can be canonicalized in different ways. Add such canonicalizations, which generalize the existing approach of canonicalizing subview op only if all of offsets, sizes and shapes are constants. PiperOrigin-RevId: 282010703
* Correctly parse empty affine maps.MLIR Team2019-11-201-0/+9
| | | | | | Previously the test case crashes / produces an error. PiperOrigin-RevId: 281630540
* Merge DCE and unreachable block elimination into a new utility ↵River Riddle2019-11-201-5/+5
| | | | | | | | 'simplifyRegions'. This moves the different canonicalizations of regions into one place and invokes them in the fixed-point iteration of the canonicalizer. PiperOrigin-RevId: 281617072
* Add multi-level DCE pass.Sean Silva2019-11-201-0/+162
| | | | | | | | | This is a simple multi-level DCE pass that operates pretty generically on the IR. Its key feature compared to the existing peephole dead op folding that happens during canonicalization is being able to delete recursively dead cycles of the use-def graph, including block arguments. PiperOrigin-RevId: 281568202
* Fix 'the the' typo.Alexander Belyaev2019-11-201-1/+1
| | | | PiperOrigin-RevId: 281501234
* Add getRemappedValue to ConversionPatternRewriterDiego Caballero2019-11-191-0/+13
| | | | | | | | | | This method is needed for N->1 conversion patterns to retrieve remapped Values used in the original N operations. Closes tensorflow/mlir#237 COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/237 from dcaballe:dcaballe/getRemappedValue 1f64fadcf2b203f7b336ff0c5838b116ae3625db PiperOrigin-RevId: 281321881
* Fix SubViewOp stride calculation in constant folding.Andy Davis2019-11-181-6/+28
| | | | | | Adds unit tests for subview offset and stride argument constant folding. PiperOrigin-RevId: 281161041
* Fix Affine Loop Fusion test case reported on github.Andy Davis2019-11-181-5/+55
| | | | | | This CL utilizies the more robust fusion feasibility analysis being built out in LoopFusionUtils, which will eventually be used to replace the current affine loop fusion pass. PiperOrigin-RevId: 281112340
* Implement folding of pattern dim(subview(_)[...][s1, ..., sn][...], i) -> si.Stephan Herhut2019-11-181-4/+16
| | | | PiperOrigin-RevId: 281042016
* Mark std.view as no-sideeffect.Stephan Herhut2019-11-151-0/+6
| | | | | | The same reasoning as for std.subview applies. PiperOrigin-RevId: 280639308
* Mark std.subview as no-sideeffect.Stephan Herhut2019-11-151-25/+36
| | | | | | | | In essence, std.subview is just an abstract indexing transformation (somewhat akin to a gep in llvm) and by itself has no effect. From a practical perspective this helps, as it allows to remove dead subview operations. PiperOrigin-RevId: 280630046
* Refactor the LowerVectorTransfers pass to use the RewritePattern infra - NFCNicolas Vasilache2019-11-141-213/+0
| | | | | | This is step 1/n in refactoring infrastructure along the Vector dialect to make it ready for retargetability and composable progressive lowering. PiperOrigin-RevId: 280529784
* Adds canonicalizer to SubViewOp which folds constants from base memref and ↵Andy Davis2019-11-141-0/+40
| | | | | | | | operands into the subview result memref type. Changes SubViewOp to support zero operands case, when offset, strides and sizes are all constant. PiperOrigin-RevId: 280485075
* Move VectorOps to Tablegen - (almost) NFCNicolas Vasilache2019-11-147-34/+43
| | | | | | | | | | | | | | | | This CL moves VectorOps to Tablegen and cleans up the implementation. This is almost NFC but 2 changes occur: 1. an interface change occurs in the padding value specification in vector_transfer_read: the value becomes non-optional. As a shortcut we currently use %f0 for all paddings. This should become an OpInterface for vectorization in the future. 2. the return type of vector.type_cast is trivial and simplified to `memref<vector<...>>` Relevant roundtrip and invalid tests that used to sit in core are moved to the vector dialect. The op documentation is moved to the .td file. PiperOrigin-RevId: 280430869
* NFC: Refactor block signature conversion to not erase the original arguments.River Riddle2019-11-132-2/+2
| | | | | | This refactors the implementation of block signature(type) conversion to not insert fake cast operations to perform the type conversion, but to instead create a new block containing the proper signature. This has the benefit of enabling the use of pre-computed analyses that rely on mapping values. It also leads to a much cleaner implementation overall. The major user facing change is that applySignatureConversion will now replace the entry block of the region, meaning that blocks generally shouldn't be cached over calls to applySignatureConversion. PiperOrigin-RevId: 280226936
* Also consider index constants when folding integer arithmetics with constants.Stephan Herhut2019-11-111-0/+45
| | | | PiperOrigin-RevId: 279698088
* Swap operand order in std.view operation so that offset appears before ↵Andy Davis2019-11-071-11/+14
| | | | | | dynamic sizes in the operand list. PiperOrigin-RevId: 279114236
* Add canonicalizer for ViewOp which folds constants into the ViewOp memref ↵Andy Davis2019-11-071-0/+46
| | | | | | shape and layout map strides and offset. PiperOrigin-RevId: 279088023
* Add a PatternRewriter hook to merge blocks, and use it to support for ↵River Riddle2019-11-051-4/+34
| | | | | | | | | | | | | | | | | | | folding branches. A pattern rewriter hook, mergeBlock, is added that allows for merging the operations of one block into the end of another. This is used to support a canonicalization pattern for branch operations that folds the branch when the successor has a single predecessor(the branch block). Example: ^bb0: %c0_i32 = constant 0 : i32 br ^bb1(%c0_i32 : i32) ^bb1(%x : i32): return %x : i32 becomes: ^bb0: %c0_i32 = constant 0 : i32 return %c0_i32 : i32 PiperOrigin-RevId: 278677825
* Support lowering of imperfectly nested loops into GPU dialect.Mahesh Ravishankar2019-11-011-6/+14
| | | | | | | | | | | | | | | | | | | The current lowering of loops to GPU only supports lowering of loop nests where the loops mapped to workgroups and workitems are perfectly nested. Here a new lowering is added to handle lowering of imperfectly nested loop body with the following properties 1) The loops partitioned to workgroups are perfectly nested. 2) The loop body of the inner most loop partitioned to workgroups can contain one or more loop nests that are to be partitioned across workitems. Each individual loops nests partitioned to workitems should also be perfectly nested. 3) The number of workgroups and workitems are not deduced from the loop bounds but are passed in by the caller of the lowering as values. 4) For statements within the perfectly nested loop nest partitioned across workgroups that are not loops, it is valid to have all threads execute that statement. This is NOT verified. PiperOrigin-RevId: 277958868
* Add support to GreedyPatternRewriter for erasing unreachable blocks.River Riddle2019-10-301-0/+15
| | | | | | Rewrite patterns may make modifications to the CFG, including dropping edges between blocks. This change adds a simple unreachable block elimination run at the end of each iteration to ensure that the CFG remains valid. PiperOrigin-RevId: 277545805
* Add support for marking an operation as recursively legal.River Riddle2019-10-281-0/+18
| | | | | | | | | | | | | | | | | | | | | In some cases, it may be desirable to mark entire regions of operations as legal. This provides an additional granularity of context to the concept of "legal". The `ConversionTarget` supports marking operations, that were previously added as `Legal` or `Dynamic`, as `recursively` legal. Recursive legality means that if an operation instance is legal, either statically or dynamically, all of the operations nested within are also considered legal. An operation can be marked via `markOpRecursivelyLegal<>`: ```c++ ConversionTarget &target = ...; /// The operation must first be marked as `Legal` or `Dynamic`. target.addLegalOp<MyOp>(...); target.addDynamicallyLegalOp<MySecondOp>(...); /// Mark the operation as always recursively legal. target.markOpRecursivelyLegal<MyOp>(); /// Mark optionally with a callback to allow selective marking. target.markOpRecursivelyLegal<MyOp, MySecondOp>([](Operation *op) { ... }); /// Mark optionally with a callback to allow selective marking. target.markOpRecursivelyLegal<MyOp>([](MyOp op) { ... }); ``` PiperOrigin-RevId: 277086382
* Convert the Canonicalize and CSE passes to generic Operation Passes.River Riddle2019-10-243-3/+3
| | | | | | This allows for them to be used on other non-function, or even other function-like, operations. The algorithms are already generic, so this is simply changing the derived pass type. The majority of this change is just ensuring that the nesting of these passes remains the same, as the pass manager won't auto-nest them anymore. PiperOrigin-RevId: 276573038
* Add @below and @above directives to verify-diagnostics.River Riddle2019-10-231-302/+302
| | | | | | | | | | | | | | | | | | This simplifies defining expected-* directives when there are multiple that apply to the next or previous line. @below applies the directive to the next non-designator line, i.e. the next line that does not contain an expected-* designator. @above applies to the previous non designator line. Examples: // Expect an error on the next line that does not contain a designator. // expected-remark@below {{remark on function below}} // expected-remark@below {{another remark on function below}} func @bar(%a : f32) // Expect an error on the previous line that does not contain a designator. func @baz(%a : f32) // expected-remark@above {{remark on function above}} // expected-remark@above {{another remark on function above}} PiperOrigin-RevId: 276369085
* Fix minor spelling tweaks (NFC)Kazuaki Ishizaki2019-10-203-4/+4
| | | | | | Closes tensorflow/mlir#175 PiperOrigin-RevId: 275726876
* Lower vector transfer ops to loop.for operations.Nicolas Vasilache2019-10-181-11/+19
| | | | | | This allows mixing linalg operations with vector transfer operations (with additional modifications to affine ops) and is a step towards solving tensorflow/mlir#189. PiperOrigin-RevId: 275543361
* Implement simple loop-invariant-code-motion based on dialect interfaces.Stephan Herhut2019-10-162-324/+568
| | | | PiperOrigin-RevId: 275004258
* Allowing replacing non-root operations in DialectConversion.River Riddle2019-10-141-0/+7
| | | | | | When dealing with regions, or other patterns that need to generate temporary operations, it is useful to be able to replace other operations than the root op being matched. Before this PR, these operations would still be considered for legalization meaning that the conversion would either fail, erroneously need to mark these ops as legal, or add unnecessary patterns. PiperOrigin-RevId: 274598513
* Add support for canonicalizing callable regions during inlining.River Riddle2019-10-101-2/+23
| | | | | | This will allow for inlining newly devirtualized calls, as well as give a more accurate cost model(when we have one). Currently canonicalization will only run for nodes that have no child edges, as the child nodes may be erased during canonicalization. We can support this in the future, but it requires more intricate deletion tracking. PiperOrigin-RevId: 274011386
* Remove the need to convert operations in regions of operations that have ↵River Riddle2019-10-102-2/+13
| | | | | | | | been replaced. When an operation with regions gets replaced, we currently require that all of the remaining nested operations are still converted even though they are going to be replaced when the rewrite is finished. This cl adds a tracking for a minimal set of operations that are known to be "dead". This allows for ignoring the legalization of operations that are won't survive after conversion. PiperOrigin-RevId: 274009003
* Add test for fix to tablegen for custom folders for ops that return a singleParker Schuh2019-10-091-0/+8
| | | | | | | | | variadic result. Add missing test for single line fix to `void OpEmitter::genFolderDecls()` entitled "Fold away reduction over 0 dimensions." PiperOrigin-RevId: 273880337
* Add support for some multi-store cases in affine fusionDiego Caballero2019-10-091-0/+75
| | | | | | | | | | | | | | This PR is a stepping stone towards supporting generic multi-store source loop nests in affine loop fusion. It extends the algorithm to support fusion of multi-store loop nests that: 1. have only one store that writes to a function-local live out, and 2. the remaining stores are involved in loop nest self dependences or no dependences within the function. Closes tensorflow/mlir#162 COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/162 from dcaballe:dcaballe/multi-output-fusion 7fb7dec6fe8b45f5ce176f018bfe37b256420c45 PiperOrigin-RevId: 273773907
* Add Instance Specific Pass Options.MLIR Team2019-10-081-3/+3
| | | | | | | | | | | | | | | | This allows individual passes to define options structs and for these options to be parsed per instance of the pass while building the pass pipeline from the command line provided textual specification. The user can specify these per-instance pipeline options like so: ``` struct MyPassOptions : public PassOptions<MyPassOptions> { Option<int> exampleOption{*this, "flag-name", llvm::cl::desc("...")}; List<int> exampleListOption{*this, "list-flag-name", llvm::cl::desc("...")}; }; static PassRegistration<MyPass, MyPassOptions> pass("my-pass", "description"); ``` PiperOrigin-RevId: 273650140
* Add a PatternRewriter hook for cloning a region into another.River Riddle2019-10-082-1/+28
| | | | | | This is similar to the `inlineRegionBefore` hook, except the original blocks are unchanged. The region to be cloned *must* not have been modified during the conversion process at the point of cloning, i.e. it must belong an operation that has yet to be converted, or the operation that is currently being converted. PiperOrigin-RevId: 273622533
OpenPOWER on IntegriCloud