summaryrefslogtreecommitdiffstats
path: root/mlir/lib/Transforms
Commit message (Collapse)AuthorAgeFilesLines
...
* Add support to GreedyPatternRewriter for erasing unreachable blocks.River Riddle2019-10-301-0/+56
| | | | | | 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
* Bugfix: Keep worklistMap in sync with worklist in GreedyPatternRewriterDiego Caballero2019-10-291-0/+1
| | | | | | | | | | | When we removed a pattern, we removed it from worklist but not from worklistMap. Then, when we tried to add a new pattern on the same Operation again, the pattern wasn't added since it already existed in the worklistMap (but not in the worklist). Closes tensorflow/mlir#211 PiperOrigin-RevId: 277319669
* Add support for marking an operation as recursively legal.River Riddle2019-10-281-73/+148
| | | | | | | | | | | | | | | | | | | | | 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-242-34/+26
| | | | | | 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
* Fix "set-but-unused" warning in DialectConversionAlex Zinenko2019-10-231-0/+1
| | | | | | | The variable in question is only used in an assertion, leading to a warning in opt builds. PiperOrigin-RevId: 276352259
* Fix minor spelling tweaks (NFC)Kazuaki Ishizaki2019-10-205-23/+23
| | | | | | Closes tensorflow/mlir#177 PiperOrigin-RevId: 275692653
* Lower vector transfer ops to loop.for operations.Nicolas Vasilache2019-10-181-10/+17
| | | | | | 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
* NFC: Remove trivial builder get methods.River Riddle2019-10-177-30/+30
| | | | | | These don't add any value, and some are even more restrictive than the respective static 'get' method. PiperOrigin-RevId: 275391240
* Introduce a wrapper around ConversionPattern that operates on the derived classGeoffrey Martin-Noble2019-10-171-6/+4
| | | | | | Analogous to OpRewritePattern, this makes writing conversion patterns more convenient. PiperOrigin-RevId: 275349854
* Rename LoopNestBuilder to AffineLoopNestBuilder - NFCNicolas Vasilache2019-10-171-3/+3
| | | | PiperOrigin-RevId: 275310747
* Update Chapter 4 of the Toy tutorialSana Damani2019-10-161-0/+4
| | | | | | | | | | This Chapter now introduces and makes use of the Interface concept in MLIR to demonstrate ShapeInference. END_PUBLIC Closes tensorflow/mlir#191 PiperOrigin-RevId: 275085151
* Allow for remapping argument to a Value in SignatureConversion.Mahesh Ravishankar2019-10-161-3/+22
| | | | | | | | | | | | | | | | The current SignatureConversion framework (part of DialectConversion) allows remapping input arguments to a function from 1->0, 1->1 or 1->many arguments during conversion. Another case is where the argument itself is dropped, but it's use are remapped to another Value*. An example of this is: The Vulkan/SPIR-V spec requires entry functions to be of type void(void). The GPU -> SPIR-V conversion implemented this without having the DialectConversion framework track the remapping that lead to some undefined behavior. The changes here addresses that. PiperOrigin-RevId: 275059656
* Add support for PatternRewriter::eraseOp.River Riddle2019-10-163-13/+22
| | | | | | This hook is useful when an operation is known to be dead, and no replacement values make sense. PiperOrigin-RevId: 275052756
* Fix CMake configuration after introduction of LICM and LoopLikeInterfaceMehdi Amini2019-10-161-1/+4
| | | | | | | b843cc5d5a introduced a new op LICM transformation and a LoopLike interface, but missed the CMake aspects of it. This should fix the build. PiperOrigin-RevId: 275038533
* Implement simple loop-invariant-code-motion based on dialect interfaces.Stephan Herhut2019-10-162-184/+336
| | | | PiperOrigin-RevId: 275004258
* Allowing replacing non-root operations in DialectConversion.River Riddle2019-10-141-1/+16
| | | | | | 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-102-17/+133
| | | | | | 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-101-3/+46
| | | | | | | | 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
* Guard rewriter insertion point during signature conversion.Christian Sigg2019-10-091-0/+1
| | | | | | Avoid unexpected side effect in rewriter insertion point. PiperOrigin-RevId: 273785794
* Add support for some multi-store cases in affine fusionDiego Caballero2019-10-091-34/+66
| | | | | | | | | | | | | | 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 a PatternRewriter hook for cloning a region into another.River Riddle2019-10-081-54/+102
| | | | | | 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
* unroll and jam: fix order of jammed bodiesUday Bondhugula2019-10-081-2/+2
| | | | | | | | | | | | | | - bodies would earlier appear in the order (i, i+3, i+2, i+1) instead of (i, i+1, i+2, i+3) for example for factor 4. - clean up hardcoded test cases Signed-off-by: Uday Bondhugula <uday@polymagelabs.com> Closes tensorflow/mlir#170 COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/170 from bondhugula:ujam b66b405b2b1894a03b376952e32a9d0292042665 PiperOrigin-RevId: 273613131
* Print result types when dumping graphviz.Jing Pu2019-10-071-0/+6
| | | | PiperOrigin-RevId: 273406833
* fix simplify-affine-structures bugUday Bondhugula2019-10-071-3/+10
| | | | | | | | | Signed-off-by: Uday Bondhugula <uday@polymagelabs.com> Closes tensorflow/mlir#157 COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/157 from bondhugula:quickfix bd1fcd79825fc0bd5b4a3e688153fa0993ab703d PiperOrigin-RevId: 273316498
* Fix typos, NFC.Christian Sigg2019-10-043-3/+3
| | | | PiperOrigin-RevId: 272851237
* Add support for inlining calls with different arg/result types from the ↵River Riddle2019-10-032-36/+106
| | | | | | | | callable. Some dialects have implicit conversions inherent in their modeling, meaning that a call may have a different type that the type that the callable expects. To support this, a hook is added to the dialect interface that allows for materializing conversion operations during inlining when there is a mismatch. A hook is also added to the callable interface to allow for introspecting the expected result types. PiperOrigin-RevId: 272814379
* Update the Inliner pass to work on SCCs of the CallGraph.River Riddle2019-10-032-26/+163
| | | | | | This allows for the inliner to work on arbitrary call operations. The updated inliner will also work bottom-up through the callgraph enabling support for multiple levels of inlining. PiperOrigin-RevId: 272813876
* Show type even if elementsattr is elided in graphJacques Pienaar2019-10-021-2/+4
| | | | | | The type is quite useful for debugging and shouldn't be too large. PiperOrigin-RevId: 272390311
* Switch explicit create methods to match generated build's orderJacques Pienaar2019-09-281-1/+1
| | | | | | The generated build methods have result type before the arguments (operands and attributes, which are also now adjacent in the explicit create method). This also results in changing the create method's ordering to match most build method's ordering. PiperOrigin-RevId: 271755054
* NFC - clean up op accessor usage, std.load/store op verify, other stale infoUday Bondhugula2019-09-275-10/+7
| | | | | | | | | | | - also remove stale terminology/references in docs Signed-off-by: Uday Bondhugula <uday@polymagelabs.com> Closes tensorflow/mlir#148 COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/148 from bondhugula:cleanup e846b641a3c2936e874138aff480a23cdbf66591 PiperOrigin-RevId: 271618279
* Promote MemRefDescriptor to a pointer to struct when passing function ↵Nicolas Vasilache2019-09-271-0/+10
| | | | | | | | | | | | | boundaries in LLVMLowering. The strided MemRef RFC discusses a normalized descriptor and interaction with library calls (https://groups.google.com/a/tensorflow.org/forum/#!topic/mlir/MaL8m2nXuio). Lowering of nested LLVM structs as value types does not play nicely with externally compiled C/C++ functions due to ABI issues. Solving the ABI problem generally is a very complex problem and most likely involves taking a dependence on clang that we do not want atm. A simple workaround is to pass pointers to memref descriptors at function boundaries, which this CL implement. PiperOrigin-RevId: 271591708
* Change the return type of createPrintCFGGraphPass to match other passes.Jing Pu2019-09-251-4/+4
| | | | PiperOrigin-RevId: 271252404
* Add convenience methods to set an OpBuilder insertion point after an ↵Mehdi Amini2019-09-231-3/+1
| | | | | | Operation (NFC) PiperOrigin-RevId: 270727180
* Fix a number of Clang-Tidy warnings.Christian Sigg2019-09-235-16/+12
| | | | PiperOrigin-RevId: 270632324
* Upgrade/fix/simplify store to load forwardingUday Bondhugula2019-09-211-73/+50
| | | | | | | | | | | | | | | | - fix store to load forwarding for a certain set of cases (where forwarding shouldn't have happened); use AffineValueMap difference based MemRefAccess equality checking; utility logic is also greatly simplified - add missing equality/inequality operators for AffineExpr ==/!= ints - add == != operators on MemRefAccess Closes tensorflow/mlir#136 COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/136 from bondhugula:store-load-forwarding d79fd1add8bcfbd9fa71d841a6a9905340dcd792 PiperOrigin-RevId: 270457011
* Avoid iterator invalidation when recursively computing pattern depth.River Riddle2019-09-201-6/+9
| | | | | | computeDepth calls itself recursively, which may insert into minPatternDepth. minPatternDepth is a DenseMap, which invalidates iterators on insertion, so this may lead to asan failures. PiperOrigin-RevId: 270374203
* Support symbolic operands for memref replacement; fix memrefNormalizeUday Bondhugula2019-09-184-9/+25
| | | | | | | | | | | | | - allow symbols in index remapping provided for memref replacement - fix memref normalize crash on cases with layout maps with symbols Signed-off-by: Uday Bondhugula <uday@polymagelabs.com> Reported by: Alex Zinenko Closes tensorflow/mlir#139 COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/139 from bondhugula:memref-rep-symbols 2f48c1fdb5d4c58915bbddbd9f07b18541819233 PiperOrigin-RevId: 269851182
* Unify error messages to start with lower-case.MLIR Team2019-09-182-5/+5
| | | | PiperOrigin-RevId: 269803466
* Add rewrite pattern to compose maps into affine load/storesUday Bondhugula2019-09-172-6/+8
| | | | | | | | | | | | | | | | | | | | | | | | - add canonicalization pattern to compose maps into affine loads/stores; templatize the pattern and reuse it for affine.apply as well - rename getIndices -> getMapOperands() (getIndices is confusing since these are no longer the indices themselves but operands to the map whose results are the indices). This also makes the accessor uniform across affine.apply/load/store. Change arg names on the affine load/store builder to avoid confusion. Drop an unused confusing build method on AffineStoreOp. - update incomplete doc comment for canonicalizeMapAndOperands (this was missed from a previous update). Addresses issue tensorflow/mlir#121 Signed-off-by: Uday Bondhugula <uday@polymagelabs.com> Closes tensorflow/mlir#122 COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/122 from bondhugula:compose-load-store e71de1771e56a85c4282c10cb43f30cef0701c4f PiperOrigin-RevId: 269619540
* Add support for multi-level value mapping to DialectConversion.River Riddle2019-09-161-10/+46
| | | | | | When performing A->B->C conversion, an operation may still refer to an operand of A. This makes it necessary to unmap through multiple levels of replacement for a specific value. PiperOrigin-RevId: 269367859
* NFC - Move explicit copy/dma generation utility out of pass and into LoopUtilsUday Bondhugula2019-09-142-672/+688
| | | | | | | | | | | | | | | | - turn copy/dma generation method into a utility in LoopUtils, allowing it to be reused elsewhere. - no functional/logic change to the pass/utility - trim down header includes in files affected Signed-off-by: Uday Bondhugula <uday@polymagelabs.com> Closes tensorflow/mlir#124 COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/124 from bondhugula:datacopy 9f346e62e5bd9dd1986720a30a35f302eb4d3252 PiperOrigin-RevId: 269106088
* update normalizeMemRef utility; handle missing failure check + add more testsUday Bondhugula2019-09-141-10/+9
| | | | | | | | | | | | | | - take care of symbolic operands with alloc - add missing check for compose map failure and a test case - add test cases on strides - drop incorrect check for one-to-one'ness Signed-off-by: Uday Bondhugula <uday@polymagelabs.com> Closes tensorflow/mlir#132 COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/132 from bondhugula:normalize-memrefs 8aebf285fb0d7c19269d85255aed644657e327b7 PiperOrigin-RevId: 269105947
* NFC: Finish replacing FunctionPassBase/ModulePassBase with OpPassBase.River Riddle2019-09-1319-21/+21
| | | | | | These directives were temporary during the generalization of FunctionPass/ModulePass to OpPass. PiperOrigin-RevId: 268970259
* Log name of the generated illegal operation name in DialectConversion debug modeSmit Hinsu2019-09-131-2/+4
| | | | PiperOrigin-RevId: 268859399
* Remove redundant qualificationJacques Pienaar2019-09-091-1/+1
| | | | | | Address GCC error: extra qualification not allowed [-fpermissive] PiperOrigin-RevId: 268133737
* Add pass generate per block in a function a GraphViz Dot graph with ops as nodesJacques Pienaar2019-09-092-0/+164
| | | | | | | | | | | * Add GraphTraits that treat a block as a graph, Operation* as node and use-relationship for edges; - Just basic graph output; * Add use iterator to iterate over all uses of an Operation; * Add testing pass to generate op graph; This does not support arbitrary operations other than function nor nested regions yet. PiperOrigin-RevId: 268121782
* Refactor getUsedValuesDefinedAbove to expose a variant taking a callback (NFC)Mehdi Amini2019-09-071-8/+22
| | | | | | | This will allow clients to implement a different collection strategy on these values, including collecting each uses within the region for example. PiperOrigin-RevId: 267803978
* Add the initial inlining infrastructure.River Riddle2019-09-054-0/+348
| | | | | | | | | | | | | | | | | | This defines a set of initial utilities for inlining a region(or a FuncOp), and defines a simple inliner pass for testing purposes. A new dialect interface is defined, DialectInlinerInterface, that allows for dialects to override hooks controlling inlining legality. The interface currently provides the following hooks, but these are just premilinary and should be changed/added to/modified as necessary: * isLegalToInline - Determine if a region can be inlined into one of this dialect, *or* if an operation of this dialect can be inlined into a given region. * shouldAnalyzeRecursively - Determine if an operation with regions should be analyzed recursively for legality. This allows for child operations to be closed off from the legality checks for operations like lambdas. * handleTerminator - Process a terminator that has been inlined. This cl adds support for inlining StandardOps, but other dialects will be added in followups as necessary. PiperOrigin-RevId: 267426759
* pipeline-data-transfer: remove dead tag alloc's and improve test coverage ↵Uday Bondhugula2019-09-043-12/+20
| | | | | | | | | | | | | | | for replaceMemRefUsesWith / pipeline-data-transfer - address remaining comments from PR tensorflow/mlir#87 for better test coverage for pipeline-data-transfer/replaceAllMemRefUsesWith - remove dead tag allocs the same way they are removed for the replaced buffers Signed-off-by: Uday Bondhugula <uday@polymagelabs.com> Closes tensorflow/mlir#106 COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/106 from bondhugula:followup 9e868666d047e8d43e5f82f43e4093b838c710fa PiperOrigin-RevId: 267144774
* Utility to normalize memrefs with non-identity layout mapsUday Bondhugula2019-09-032-8/+89
| | | | | | | | | | | | | | | | - introduce utility to convert memrefs with non-identity layout maps to ones with identity layout maps: convert the type and rewrite/remap all its uses - add this utility to -simplify-affine-structures pass for testing purposes Signed-off-by: Uday Bondhugula <uday@polymagelabs.com> Closes tensorflow/mlir#104 COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/104 from bondhugula:memref-normalize f2c914aa1890e8860326c9e33f9aa160b3d65e6d PiperOrigin-RevId: 266985317
OpenPOWER on IntegriCloud