summaryrefslogtreecommitdiffstats
path: root/mlir/lib/Analysis
Commit message (Collapse)AuthorAgeFilesLines
...
* Move the success/failure functions out of LogicalResult and into the mlir ↵River Riddle2019-03-293-41/+41
| | | | | | namespace. PiperOrigin-RevId: 237712180
* Rename Status to LogicalResult to avoid conflictions with the Status in ↵River Riddle2019-03-293-81/+82
| | | | | | xla/tensorflow/etc. PiperOrigin-RevId: 237537341
* Don't run verifyOperation in verifyDominance, as it is already run as part ↵River Riddle2019-03-291-14/+11
| | | | | | of verifyBlock. This caused the verifier to run in exponential time for nested regions. PiperOrigin-RevId: 237519751
* Refactor and share common code across addAffineForOpDomain / addSliceBoundsUday Bondhugula2019-03-292-182/+124
| | | | PiperOrigin-RevId: 237508755
* Add a basic model to set tile sizes + some cleanupUday Bondhugula2019-03-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - compute tile sizes based on a simple model that looks at memory footprints (instead of using the hardcoded default value) - adjust tile sizes to make them factors of trip counts based on an option - update loop fusion CL options to allow setting maximal fusion at pass creation - change an emitError to emitWarning (since it's not a hard error unless the client treats it that way, in which case, it can emit one) $ mlir-opt -debug-only=loop-tile -loop-tile test/Transforms/loop-tiling.mlir test/Transforms/loop-tiling.mlir:81:3: note: using tile sizes [4 4 5 ] for %i = 0 to 256 { for %i0 = 0 to 256 step 4 { for %i1 = 0 to 256 step 4 { for %i2 = 0 to 250 step 5 { for %i3 = #map4(%i0) to #map11(%i0) { for %i4 = #map4(%i1) to #map11(%i1) { for %i5 = #map4(%i2) to #map12(%i2) { %0 = load %arg0[%i3, %i5] : memref<8x8xvector<64xf32>> %1 = load %arg1[%i5, %i4] : memref<8x8xvector<64xf32>> %2 = load %arg2[%i3, %i4] : memref<8x8xvector<64xf32>> %3 = mulf %0, %1 : vector<64xf32> %4 = addf %2, %3 : vector<64xf32> store %4, %arg2[%i3, %i4] : memref<8x8xvector<64xf32>> } } } } } } PiperOrigin-RevId: 237461836
* Convert ambiguous bool returns in /Analysis to use Status instead.River Riddle2019-03-293-130/+130
| | | | PiperOrigin-RevId: 237390240
* Fix unionBoundingBox bug introduced by cl/237141668Uday Bondhugula2019-03-291-3/+4
| | | | | | - add test case PiperOrigin-RevId: 237241598
* Adds offset argument to specified range of ids know to be aligned when ↵MLIR Team2019-03-291-16/+18
| | | | | | | | calling mergeAndAlignIds (used by FlatAffineConstraints). Supports use case where FlatAffineConstraints::composeMap adds dim identifiers with no SSA values (because the identifiers are the result of an AffineValueMap which is not materialized in the IR and thus has no SSA Value results). PiperOrigin-RevId: 237145506
* Add FlatAffineConstraints::containsId to avoid using findId when position isn'tUday Bondhugula2019-03-292-16/+19
| | | | | | | needed + other cleanup - clean up unionBoundingBox (hoist SmallVector allocations out of loop). PiperOrigin-RevId: 237141668
* Use FlatAffineConstraints::unionBoundingBox to perform slice bounds union ↵MLIR Team2019-03-292-5/+70
| | | | | | | | | for loop fusion pass (WIP). Adds utility to convert slice bounds to a FlatAffineConstraints representation. Adds utility to FlatAffineConstraints to promote loop IV symbol identifiers to dim identifiers. PiperOrigin-RevId: 236973261
* Change Pass:getFunction() to return pointer instead of ref - NFCUday Bondhugula2019-03-293-3/+3
| | | | | | | | | - change this for consistency - everything else similar takes/returns a Function pointer - the FuncBuilder ctor, Block/Value/Instruction::getFunction(), etc. - saves a whole bunch of &s everywhere PiperOrigin-RevId: 236928761
* Change the TensorFlow attribute prefix from "tf$" to "tf." to match the ↵River Riddle2019-03-291-6/+2
| | | | | | specification of dialect attributes. This also fixes tblgen generation of dialect attributes that used the sugared name "tf$attr" as c++ identifiers. PiperOrigin-RevId: 236924392
* Fix and improve detectAsModUday Bondhugula2019-03-291-12/+44
| | | | | | | | - fix for the mod detection - simplify/avoid the mod at construction (if the dividend is already known to be less than the divisor), since the information is available at hand there PiperOrigin-RevId: 236882988
* Fix dialect attribute hooks so that they accept a NamedAttribute instead of ↵River Riddle2019-03-291-3/+3
| | | | | | an Attribute. PiperOrigin-RevId: 236869321
* Adds loop attribute as a temporary work around to prevent slice fusion of ↵MLIR Team2019-03-291-13/+18
| | | | | | loop nests containing instructions with side effects (the proper solution will be do use memref read/write regions in the future). PiperOrigin-RevId: 236733739
* Bug fix for getConstantBoundOnDimSizeUday Bondhugula2019-03-291-4/+4
| | | | | | | | | | | - this was detected when memref-bound-check was run on the output of the loop-fusion pass - the addition (to represent ceildiv as a floordiv) had to be performed only for the constant term of the constraint - update test cases - memref-bound-check no longer returns an error on the output of this test case PiperOrigin-RevId: 236731137
* Introduce the notion of dialect attributes and dependent attributes. A ↵River Riddle2019-03-291-7/+48
| | | | | | | | | | | | | | | dialect attribute derives its context from a specific dialect, whereas a dependent attribute derives context from what it is attached to. Following this, we now enforce that functions and function arguments may only contain dialect specific attributes. These are generic entities and cannot provide any specific context for a dependent attribute. Dialect attributes are defined as: dialect-namespace `.` attr-name `:` attribute-value Dialects can override any of the following hooks to verify the validity of a given attribute: * verifyFunctionAttribute * verifyFunctionArgAttribute * verifyInstructionAttribute PiperOrigin-RevId: 236507970
* Update addSliceBounds to deal with loops with floor's/mod's.Uday Bondhugula2019-03-292-28/+87
| | | | | | | | | - This change only impacts the cost model for fusion, given the way addSliceBounds was being used. It so happens that the output in spite of this CL's fix is the same; however, the assertions added no longer fail. (an invalid/inconsistent memref region was being used earlier). PiperOrigin-RevId: 236405030
* NFC. Move all of the remaining operations left in BuiltinOps to StandardOps. ↵River Riddle2019-03-298-8/+1
| | | | | | The only thing left in BuiltinOps are the core MLIR types. The standard types can't be moved because they are referenced within the IR directory, e.g. in things like Builder. PiperOrigin-RevId: 236403665
* Use consistent names for dialect op source filesLei Zhang2019-03-297-7/+7
| | | | | | | | | | | | | | | This CL changes dialect op source files (.h, .cpp, .td) to follow the following convention: <full-dialect-name>/<dialect-namespace>Ops.{h|cpp|td} Builtin and standard dialects are specially treated, though. Both of them do not have dialect namespace; the former is still named as BuiltinOps.* and the latter is named as Ops.*. Purely mechanical. NFC. PiperOrigin-RevId: 236371358
* A simple pass to detect and mark all parallel loopsUday Bondhugula2019-03-292-22/+75
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - detect all parallel loops based on dep information and mark them with a "parallel" attribute - add mlir::isLoopParallel(OpPointer<AffineForOp> ...), and refactor an existing method to use that (reuse some code from @andydavis (cl/236007073) for this) - a simple/meaningful way to test memref dep test as well Ex: $ mlir-opt -detect-parallel test/Transforms/parallelism-detection.mlir #map1 = ()[s0] -> (s0) func @foo(%arg0: index) { %0 = alloc() : memref<1024x1024xvector<64xf32>> %1 = alloc() : memref<1024x1024xvector<64xf32>> %2 = alloc() : memref<1024x1024xvector<64xf32>> for %i0 = 0 to %arg0 { for %i1 = 0 to %arg0 { for %i2 = 0 to %arg0 { %3 = load %0[%i0, %i2] : memref<1024x1024xvector<64xf32>> %4 = load %1[%i2, %i1] : memref<1024x1024xvector<64xf32>> %5 = load %2[%i0, %i1] : memref<1024x1024xvector<64xf32>> %6 = mulf %3, %4 : vector<64xf32> %7 = addf %5, %6 : vector<64xf32> store %7, %2[%i0, %i1] : memref<1024x1024xvector<64xf32>> } {parallel: false} } {parallel: true} } {parallel: true} return } PiperOrigin-RevId: 236367368
* Loop fusion for input reuse.MLIR Team2019-03-293-13/+78
| | | | | | | | | | | | | *) Breaks fusion pass into multiple sub passes over nodes in data dependence graph: - first pass fuses single-use producers into their unique consumer. - second pass enables fusing for input-reuse by fusing sibling nodes which read from the same memref, but which do not share dependence edges. - third pass fuses remaining producers into their consumers (Note that the sibling fusion pass may have transformed a producer with multiple uses into a single-use producer). *) Fusion for input reuse is enabled by computing a sibling node slice using the load/load accesses to the same memref, and fusion safety is guaranteed by checking that the sibling node memref write region (to a different memref) is preserved. *) Enables output vector and output matrix computations from KFAC patches-second-moment operation to fuse into a single loop nest and reuse input from the image patches operation. *) Adds a generic loop utilitiy for finding all sequential loops in a loop nest. *) Adds and updates unit tests. PiperOrigin-RevId: 236350987
* Analysis support for floordiv/mod's in loop bounds/Uday Bondhugula2019-03-291-28/+56
| | | | | | | | | - handle floordiv/mod's in loop bounds for all analysis purposes - allows fusion slicing to be more powerful - add simple test cases based on -memref-bound-check - fusion based test cases in follow up CLs PiperOrigin-RevId: 236328551
* Method to align/merge dimensional/symbolic identifiers between two ↵Uday Bondhugula2019-03-292-102/+169
| | | | | | | | | | | | | | | FlatAffineConstraints - add a method to merge and align the spaces (identifiers) of two FlatAffineConstraints (both get dimension-wise and symbol-wise unique columns) - this completes several TODOs, gets rid of previous assumptions/restrictions in composeMap, unionBoundingBox, and reuses common code - remove previous workarounds / duplicated funcitonality in FlatAffineConstraints::composeMap and unionBoundingBox, use mergeAlignIds from both PiperOrigin-RevId: 236320581
* Use Instruction::isBeforeInBlock instead of a linear scanUday Bondhugula2019-03-291-15/+7
| | | | | | | - use Instruction::isBeforeInBlock instead of a linear scan in AffineAnalysis.cpp PiperOrigin-RevId: 236235824
* Remove PassResult and have the runOnFunction/runOnModule functions return ↵River Riddle2019-03-293-9/+6
| | | | | | void instead. To signal a pass failure, passes should now invoke the 'signalPassFailure' method. This provides the equivalent functionality when needed, but isn't an intrusive part of the API like PassResult. PiperOrigin-RevId: 236202029
* Change some of the debug messages to use emitError / emitWarning / emitNote ↵Uday Bondhugula2019-03-292-7/+7
| | | | | | - NFC PiperOrigin-RevId: 236169676
* Add support for named function argument attributes. The attribute dictionary ↵River Riddle2019-03-291-9/+23
| | | | | | | | | | is printed after the argument type: func @arg_attrs(i32 {arg_attr: 10}) func @arg_attrs(%arg0: i32 {arg_attr: 10}) PiperOrigin-RevId: 236136830
* Detect more trivially redundant constraints betterUday Bondhugula2019-03-291-11/+47
| | | | | | | | | | | | | | | | | | | | | | | | | - detect more trivially redundant constraints in FlatAffineConstraints::removeTrivialRedundantConstraints. Redundancy due to constraints that only differ in the constant part (eg., 32i + 64j - 3 >= 0, 32 + 64j - 8 >= 0) is now detected. The method is still linear-time and does a single scan over the FlatAffineConstraints buffer. This detection is useful and needed to eliminate redundant constraints generated after FM elimination. - update GCDTightenInequalities so that we also normalize by the GCD while at it. This way more constraints will show up as redundant (232i - 203 >= 0 becomes i - 1 >= 0 instead of 232i - 232 >= 0) without having to call normalizeConstraintsByGCD. - In FourierMotzkinEliminate, call GCDTightenInequalities and normalizeConstraintsByGCD before calling removeTrivialRedundantConstraints() - so that more redundant constraints are detected. As a result, redundancy due to constraints like i - 5 >= 0, i - 7 >= 0, 2i - 5 >= 0, 232i - 203 >= 0 is now detected (here only i >= 7 is non-redundant). As a result of these, a -memref-bound-check on the added test case runs in 16ms instead of 1.35s (opt build) and no longer returns a conservative result. PiperOrigin-RevId: 235983550
* Fix bug in memref region computation with slice loop bounds. Adds loop IV ↵MLIR Team2019-03-292-11/+28
| | | | | | values to ComputationSliceState which are used in FlatAffineConstraints::addSliceBounds, to ensure that constraints are only added for loop IV values which are present in the constraint system. PiperOrigin-RevId: 235952912
* Port all of the existing passes over to the new pass manager infrastructure. ↵River Riddle2019-03-293-27/+15
| | | | | | This is largely NFC. PiperOrigin-RevId: 235952357
* Temp change in FlatAffineConstraints::getSliceBounds() to deal with TODO inUday Bondhugula2019-03-291-11/+16
| | | | | | | | | | | LoopFusion - getConstDifference in LoopFusion is pending a refactoring to handle bounds with min's and max's; it currently asserts on some useful test cases that we want to experiment with. This CL changes getSliceBounds to be more conservative so as to not trigger the assertion. Filed b/126426796 to track this. PiperOrigin-RevId: 235826538
* Allow function names to have a leading underscore. This matches what is ↵River Riddle2019-03-291-5/+5
| | | | | | already defined in the spec, but not supported in the implementation. PiperOrigin-RevId: 235823663
* Validate the names of attribute, dialect, and functions during verification. ↵River Riddle2019-03-291-33/+51
| | | | | | This essentially enforces the parsing rules upon their names. PiperOrigin-RevId: 235818842
* Add a Function::isExternal utility to simplify checks for external functions.River Riddle2019-03-291-1/+1
| | | | PiperOrigin-RevId: 235746553
* Rewrite the dominance info classes to allow for operating on arbitrary ↵River Riddle2019-03-291-54/+72
| | | | | | control flow within operation regions. The CSE pass is also updated to properly handle nested dominance. PiperOrigin-RevId: 235742627
* Cleanup post cl/235283610 - NFCUday Bondhugula2019-03-291-4/+5
| | | | | | | - remove stale comments + cleanup - drop MLIRContext * field from expr flattener PiperOrigin-RevId: 235621178
* Refactor AffineExprFlattener and move FlatAffineConstraints out of IR intoUday Bondhugula2019-03-296-9/+2538
| | | | | | | | | | | | | | | | | Analysis - NFC - refactor AffineExprFlattener (-> SimpleAffineExprFlattener) so that it doesn't depend on FlatAffineConstraints, and so that FlatAffineConstraints could be moved out of IR/; the simplification that the IR needs for AffineExpr's doesn't depend on FlatAffineConstraints - have AffineExprFlattener derive from SimpleAffineExprFlattener to use for all Analysis/Transforms purposes; override addLocalFloorDivId in the derived class - turn addAffineForOpDomain into a method on FlatAffineConstraints - turn AffineForOp::getAsValueMap into an AffineValueMap ctor PiperOrigin-RevId: 235283610
* Define a PassID class to use when defining a pass. This allows for the type ↵River Riddle2019-03-293-9/+3
| | | | | | used for the ID field to be self documenting. It also allows for the compiler to know the set alignment of the ID object, which is useful for storing pointer identifiers within llvm data structures. PiperOrigin-RevId: 235107957
* Fix for getMemRefSizeInBytes: unsigned -> uint64_tUday Bondhugula2019-03-291-1/+1
| | | | PiperOrigin-RevId: 234829637
* NFC: Refactor the files related to passes.River Riddle2019-03-294-95/+3
| | | | | | | * PassRegistry is split into its own source file. * Pass related files are moved to a new library 'Pass'. PiperOrigin-RevId: 234705771
* Misc. updates/fixes to analysis utils used for DMA generation; update DMAUday Bondhugula2019-03-291-18/+38
| | | | | | | | | | | | | | | | | | | | | | | | | generation pass to make it drop certain assumptions, complete TODOs. - multiple fixes for getMemoryFootprintBytes - pass loopDepth correctly from getMemoryFootprintBytes() - use union while computing memory footprints - bug fixes for addAffineForOpDomain - take into account loop step - add domains of other loop IVs in turn that might have been used in the bounds - dma-generate: drop assumption of "non-unit stride loops being tile space loops and skipping those and recursing to inner depths"; DMA generation is now purely based on available fast mem capacity and memory footprint's calculated - handle memory region compute failures/bailouts correctly from dma-generate - loop tiling cleanup/NFC - update some debug and error messages to use emitNote/emitError in pipeline-data-transfer pass - NFC PiperOrigin-RevId: 234245969
* Update direction vector computation to use ↵MLIR Team2019-03-292-54/+20
| | | | | | | | FlatAffineConstraints::getLower/UpperBounds. Update FlatAffineConstraints::getLower/UpperBounds to project to the identifier for which bounds are being computed. This change enables computing bounds on an identifier which were previously dependent on the bounds of another identifier. PiperOrigin-RevId: 234017514
* Fix + cleanup for getMemRefRegion()Uday Bondhugula2019-03-291-13/+16
| | | | | | | | | | - determine symbols for the memref region correctly - this wasn't exposed earlier since we didn't have any test cases where the portion of the nest being DMAed for was non-hyperrectangular (i.e., bounds of one IV depending on other IVs within that part) PiperOrigin-RevId: 233493872
* Remove the restriction that only registered terminator operations may ↵River Riddle2019-03-291-18/+36
| | | | | | terminate a block and have block operands. This allows for any operation to hold block operands. It also introduces the notion that unregistered operations may terminate a block. As such, the 'isTerminator' api on Instruction has been split into 'isKnownTerminator' and 'isKnownNonTerminator'. PiperOrigin-RevId: 233076831
* Automated rollback of changelist 232728977.Uday Bondhugula2019-03-291-1/+1
| | | | PiperOrigin-RevId: 232944889
* Automated rollback of changelist 232717775.Uday Bondhugula2019-03-292-9/+9
| | | | PiperOrigin-RevId: 232807986
* Rename the 'if' operation in the AffineOps dialect to 'affine.if' and namespaceRiver Riddle2019-03-291-1/+1
| | | | | | the AffineOps dialect with 'affine'. PiperOrigin-RevId: 232728977
* NFC: Rename the 'for' operation in the AffineOps dialect to 'affine.for'. ↵River Riddle2019-03-292-10/+10
| | | | | | The is the second step to adding a namespace to the AffineOps dialect. PiperOrigin-RevId: 232717775
* Address post submit review comments for removing Block::findInstPositionInBlock.River Riddle2019-03-292-4/+6
| | | | PiperOrigin-RevId: 232713514
OpenPOWER on IntegriCloud