summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
| * Move GPU::FuncOp definition to ODS - NFCAlex Zinenko2019-12-065-189/+193
| | | | | | | | | | | | | | | | Move the definition of the GPU function opreation from hand-rolled C++ code to ODS framework. This only does the moves, a follow-up is necessary to clean up users of custom functions that could be auto-generated by ODS. PiperOrigin-RevId: 284233245
| * Provide a way to get the type of a ValueHandle.MLIR Team2019-12-062-12/+35
| | | | | | | | PiperOrigin-RevId: 284221337
| * [VectorOps] Add lowering of vector.broadcast to LLVM IRAart Bik2019-12-064-10/+403
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For example, a scalar broadcast %0 = vector.broadcast %x : f32 to vector<2xf32> return %0 : vector<2xf32> which expands scalar x into vector [x,x] by lowering to the following LLVM IR dialect to implement the duplication over the leading dimension. %0 = llvm.mlir.undef : !llvm<"<2 x float>"> %1 = llvm.mlir.constant(0 : index) : !llvm.i64 %2 = llvm.insertelement %x, %0[%1 : !llvm.i64] : !llvm<"<2 x float>"> %3 = llvm.shufflevector %2, %0 [0 : i32, 0 : i32] : !llvm<"<2 x float>">, !llvm<"<2 x float>"> return %3 : vector<2xf32> In the trailing dimensions, the operand is simply "passed through", unless a more elaborate "stretch" is required. For example %0 = vector.broadcast %arg0 : vector<1xf32> to vector<4xf32> return %0 : vector<4xf32> becomes %0 = llvm.mlir.undef : !llvm<"<4 x float>"> %1 = llvm.mlir.constant(0 : index) : !llvm.i64 %2 = llvm.extractelement %arg0[%1 : !llvm.i64] : !llvm<"<1 x float>"> %3 = llvm.mlir.constant(0 : index) : !llvm.i64 %4 = llvm.insertelement %2, %0[%3 : !llvm.i64] : !llvm<"<4 x float>"> %5 = llvm.shufflevector %4, %0 [0 : i32, 0 : i32, 0 : i32, 0 : i32] : !llvm<"<4 x float>">, !llvm<"<4 x float>"> llvm.return %5 : !llvm<"<4 x float>"> PiperOrigin-RevId: 284219926
| * Generate builder for ops that use InferTypeOpInterface trait in ODSJacques Pienaar2019-12-064-16/+66
| | | | | | | | | | | | | | | | | | | | For ops with infer type op interface defined, generate version that calls the inferal method on build. This is intermediate step to removing special casing of SameOperandsAndResultType & FirstAttrDereivedResultType. After that would be generating the inference code, with the initial focus on shaped container types. In between I plan to refactor these a bit to reuse generated paths. The intention would not be to add the type inference trait in multiple places, but rather to take advantage of the current modelling in ODS where possible to emit it instead. Switch the `inferReturnTypes` method to be static. Skipping ops with regions here as I don't like the Region vs unique_ptr<Region> difference at the moment, and I want the infer return type trait to be useful for verification too. So instead, just skip it for now to avoid churn. PiperOrigin-RevId: 284217913
| * Add conversions of GPU func with memory attributions to LLVM/NVVMAlex Zinenko2019-12-065-9/+371
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | GPU functions use memory attributions, a combination of Op attributes and region arguments, to specify function-wide buffers placed in workgroup or private memory spaces. Introduce a lowering pattern for GPU functions to be converted to LLVM functions taking into account memory attributions. Workgroup attributions get transformed into module-level globals with unique names derived from function names. Private attributions get converted into llvm.allocas inside the function body. In both cases, we inject at the beginning of the function the IR that obtains the raw pointer to the data and populates a MemRef descriptor based on the MemRef type of buffer, making attributions compose with the rest of the MemRef lowering and transparent for use with std.load and std.store. While using raw pointers instead of descriptors might have been more efficient, it is better implemented as a canonicalization or a separate transformation so that non-attribution memrefs could also benefit from it. PiperOrigin-RevId: 284208396
| * fix examples in commentsAlexandre E. Eichenberger2019-12-061-20/+18
| | | | | | | | | | | | | | Closes tensorflow/mlir#301 COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/301 from AlexandreEichenberger:vect-doc-update 7e5418a9101a4bdad2357882fe660b02bba8bd01 PiperOrigin-RevId: 284202462
| * Use regex to fix failure when stats are disabled.River Riddle2019-12-061-3/+3
| | | | | | | | | | | | | | | | It would be nice if we could detect if stats were enabled or not and use 'Requires', but this isn't possible to do at configure time. Fixes tensorflow/mlir#296 PiperOrigin-RevId: 284200271
| * Unroll vector masks along with their associated vector arguments.Andy Davis2019-12-067-114/+86
| | | | | | | | | | | | | | | | | | Updates vector ContractionOp to use proper vector masks (produced by CreateMaskOp/ConstantMaskOp). Leverages the following canonicalizations in unrolling unit test: CreateMaskOp -> ConstantMaskOp, StridedSliceOp(ConstantMaskOp) -> ConstantMaskOp Removes IndexTupleOp (no longer needed now that we have vector mask ops). Updates all unit tests. PiperOrigin-RevId: 284182168
| * [spirv] Reorder `erase` and `emplace` to avoid "invalid iterator access".Denis Khalikov2019-12-061-1/+3
| | | | | | | | | | | | | | | | | | | | The iterator should be erased before adding a new entry into blockMergeInfo to avoid iterator invalidation. Closes tensorflow/mlir#299 COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/299 from denis0x0D:sandbox/reoder_erase 983be565809aa0aadfc7e92962e4d4b282f63c66 PiperOrigin-RevId: 284173235
| * DimOp folding for alloc/view dynamic dimensionsUday Bondhugula2019-12-064-31/+91
| | | | | | | | | | | | | | | | | | 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
| * minor spelling tweaksKazuaki Ishizaki2019-12-0619-95/+97
| | | | | | | | | | | | | | Closes tensorflow/mlir#290 COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/290 from kiszk:spelling_tweaks_201912 9d9afd16a723dd65754a04698b3976f150a6054a PiperOrigin-RevId: 284169681
| * LLVM::AddressOfOp: properly take into account the address spaceAlex Zinenko2019-12-063-3/+21
| | | | | | | | | | | | | | | | | | | | The AddressOf operation in the LLVM dialect return a pointer to a global variable. The latter may be in a non-default address space as indicated by the "addr_space" attribute. Check that the address space of the pointer returned by AddressOfOp matches that of the referenced GlobalOp. Update the AddressOfOp builder to respect this constraint. PiperOrigin-RevId: 284138860
| * NFC: Add documentation for `-mlir-print-op-on-diagnostic` and ↵River Riddle2019-12-051-0/+49
| | | | | | | | | | | | | | | | `-mlir-print-stacktrace-on-diagnostic`. This change adds proper documentation in Diagnostics.md, allowing for users to more easily find them. PiperOrigin-RevId: 284092336
| * Add include path to the TestDialect to fix broken build.River Riddle2019-12-051-0/+2
| | | | | | | | PiperOrigin-RevId: 284067891
| * [Linalg] Add permutation information to tilingJose Ignacio Gomez2019-12-0512-24/+304
| | | | | | | | | | | | | | | | | | | | | | This patch closes issue tensorflow/mlir#271. It adds an optional permutation map to declarative tiling transformations. The map is expressed as a list of integers. Closes tensorflow/mlir#288 COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/288 from tetuante:issue271 2df2938d6a1f01b3bc404ded08dea2dd1e10b588 PiperOrigin-RevId: 284064151
| * Refactor the IRPrinting instrumentation to take a derivable config.River Riddle2019-12-053-56/+159
| | | | | | | | | | | | This allows for more interesting behavior from users, e.g. enabling the ability to dump the IR to a separate file for each pass invocation. PiperOrigin-RevId: 284059447
| * Add UnrankedMemRef Typenmostafa2019-12-0523-116/+676
| | | | | | | | | | | | | | Closes tensorflow/mlir#261 COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/261 from nmostafa:nmostafa/unranked 96b6e918f6ed64496f7573b2db33c0b02658ca45 PiperOrigin-RevId: 284037040
| * [spirv] Add CompositeInsertOp operationDenis Khalikov2019-12-057-225/+408
| | | | | | | | | | | | | | | | | | | | A CompositeInsertOp operation make a copy of a composite object, while modifying one part of it. Closes tensorflow/mlir#292 COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/292 from denis0x0D:sandbox/composite_insert 2200962b9057bda53cd2f2866b461e2797196380 PiperOrigin-RevId: 284036551
| * Add support for instance specific pass statistics.River Riddle2019-12-0511-33/+500
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Statistics are a way to keep track of what the compiler is doing and how effective various optimizations are. It is useful to see what optimizations are contributing to making a particular program run faster. Pass-instance specific statistics take this even further as you can see the effect of placing a particular pass at specific places within the pass pipeline, e.g. they could help answer questions like "what happens if I run CSE again here". Statistics can be added to a pass by simply adding members of type 'Pass::Statistics'. This class takes as a constructor arguments: the parent pass pointer, a name, and a description. Statistics can be dumped by the pass manager in a similar manner to how pass timing information is dumped, i.e. via PassManager::enableStatistics programmatically; or -pass-statistics and -pass-statistics-display via the command line pass manager options. Below is an example: struct MyPass : public OperationPass<MyPass> { Statistic testStat{this, "testStat", "A test statistic"}; void runOnOperation() { ... ++testStat; ... } }; $ mlir-opt -pass-pipeline='func(my-pass,my-pass)' foo.mlir -pass-statistics Pipeline Display: ===-------------------------------------------------------------------------=== ... Pass statistics report ... ===-------------------------------------------------------------------------=== 'func' Pipeline MyPass (S) 15 testStat - A test statistic MyPass (S) 6 testStat - A test statistic List Display: ===-------------------------------------------------------------------------=== ... Pass statistics report ... ===-------------------------------------------------------------------------=== MyPass (S) 21 testStat - A test statistic PiperOrigin-RevId: 284022014
| * Allow specification of the workgroup size for GPUToSPIRV lowering.Mahesh Ravishankar2019-12-056-16/+60
| | | | | | | | | | | | | | | | | | | | SPIR-V/Vulkan spec requires the workgroups size to be specified with the spv.ExecutionMode operation. This was hard-wired to be set to a particular value. It is now changed to be configurable by clients of the pass or of the patterns that implement the lowering from GPU to SPIRV. PiperOrigin-RevId: 284017482
| * Add spv.AtomicCompareExchangeWeakLei Zhang2019-12-056-126/+325
| | | | | | | | PiperOrigin-RevId: 283997917
| * Add a flag to dump the current stack trace when emitting a diagnostic.River Riddle2019-12-051-0/+19
| | | | | | | | | | | | It is often desirable to know where within the program that a diagnostic was emitted, without reverting to assert/unreachable which crash the program. This change adds a flag `mlir-print-stacktrace-on-diagnostic` that attaches the current stack trace as a note to every diagnostic that gets emitted. PiperOrigin-RevId: 283996373
| * [spirv] Fix nested loop (de)serializationLei Zhang2019-12-053-45/+191
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For serialization, when we have nested ops, the inner loop will create multiple SPIR-V blocks. If the outer loop has block arguments (which corresponds to OpPhi instructions), we defer the handling of OpPhi's parent block handling until we serialized all blocks and then fix it up with the result <id>. These two cases happening together was generating invalid SPIR-V blob because we previously assume the parent block to be the block containing the terminator. That is not true anymore when the block contains structured control flow ops. If that happens, it should be fixed to use the structured control flow op's merge block. For deserialization, we record a map from header blocks to their corresponding merge and continue blocks during the initial deserialization and then use the info to construct spv.selection/spv.loop. The existing implementation will also fall apart when we have nested loops. If so, we clone all blocks for the outer loop, including the ones for the inner loop, to the spv.loop's region. So the map for header blocks' merge info need to be updated; otherwise we are operating on already deleted blocks. PiperOrigin-RevId: 283949230
| * Fix MLIR Build after LLVM upstream JIT changes (getMainJITDylib removed)Mehdi Amini2019-12-051-1/+4
| | | | | | | | | | | | The getMainJITDylib() method was removed in 4fc68b9b7f, replace it by creating a JITDylib on the fly. PiperOrigin-RevId: 283948595
| * Move ModuleManager functionality into mlir::SymbolTable.Tres Popp2019-12-0510-101/+109
| | | | | | | | | | | | | | | | | | | | Note for broken code, the following transformations occurred: ModuleManager::insert(Block::iterator, Operation*) - > SymbolTable::insert(Operation*, Block::iterator) ModuleManager::lookupSymbol -> SymbolTable::lookup ModuleManager::getModule() -> SymbolTable::getOp() ModuleManager::getContext() -> SymbolTable::getOp()->getContext() ModuleManager::* -> SymbolTable::* PiperOrigin-RevId: 283944635
| * Add MLIRIR as a dependency to LLVM and related dialectsLei Zhang2019-12-041-3/+3
| | | | | | | | | | | | Fixes tensorflow/mlir#289 PiperOrigin-RevId: 283914472
| * Optimize operation ordering to support non-congruent indices.River Riddle2019-12-043-9/+96
| | | | | | | | | | | | This change adds support for non-congruent indices in the operation ordering within a basic block. This effect of this is that insertions are less likely to cause an invalidation of the ordering within a block. This has a big effect on modules that have very large basic blocks. PiperOrigin-RevId: 283858136
| * Add emitOptional(Error|Warning|Remark) functions to simplify emission with ↵River Riddle2019-12-049-194/+151
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | an optional location. In some situations a diagnostic may optionally be emitted by the presence of a location, e.g. attribute and type verification. These situations currently require extra 'if(loc) emitError(...); return failure()' wrappers that make verification clunky. These new overloads take an optional location and a list of arguments to the diagnostic, and return a LogicalResult. We take the arguments directly and return LogicalResult instead of returning InFlightDiagnostic because we cannot create a valid diagnostic with a null location. This creates an awkward situation where a user may try to treat the, potentially null, diagnostic as a valid one and encounter crashes when attaching notes/etc. Below is an example of how these methods simplify some existing usages: Before: if (loc) emitError(*loc, "this is my diagnostic with argument: ") << 5; return failure(); After: return emitOptionalError(loc, "this is my diagnostic with argument: ", 5); PiperOrigin-RevId: 283853599
| * Add a CL option to Standard to LLVM lowering to use alloca instead of ↵Nicolas Vasilache2019-12-043-41/+116
| | | | | | | | | | | | | | | | | | malloc/free. In the future, a more configurable malloc and free interface should be used and exposed via extra parameters to the `createLowerToLLVMPass`. Until requirements are gathered, a simple CL flag allows generating code that runs successfully on hardware that cannot use the stdlib. PiperOrigin-RevId: 283833424
| * Add canonicalization patterns for vector CreateMaskOp and StridedSliceOp to ↵Andy Davis2019-12-045-6/+326
| | | | | | | | | | | | | | | | | | | | | | be used in the unroll vector op transformation. Adds a ConstantMaskOp to the vector ops dialect. Adds the following canonicalization patterns: CreateMaskOp -> ConstantMaskOp StridedSliceOp(ConstantMaskOp) -> ConstantMaskOp PiperOrigin-RevId: 283816752
| * [CSE] NFC: Hash the attribute dictionary pointer instead of the list of ↵River Riddle2019-12-042-2/+9
| | | | | | | | | | | | attributes. PiperOrigin-RevId: 283810829
| * Drop MaterializeVectorTransfers in favor of simpler declarative unrollingNicolas Vasilache2019-12-048-1179/+39
| | | | | | | | | | | | 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
| * NFC: Fix mismatches between LangRef.md and actual parser implementation.River Riddle2019-12-043-25/+33
| | | | | | | | PiperOrigin-RevId: 283805832
| * [spirv] Define a few more extensions in SPIRVBase.tdLei Zhang2019-12-041-3/+43
| | | | | | | | PiperOrigin-RevId: 283798496
| * Print out large elementsattr's such that they are parseable.Sean Silva2019-12-042-17/+37
| | | | | | | | | | | | | | | | | | | | | | I found that when running crash reproducers, the elided elementsattr's would prevent parsing the IR repro. I found myself manually going and replacing the "..." with some valid IR. With this change, we now print elided attrs as `opaque<"", "0xDEADBEEF">` to clearly delineate them as being elided while still being parseable. PiperOrigin-RevId: 283781806
| * NFC - fix name / comments - isAccessInvariantUday Bondhugula2019-12-042-20/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - the name was misleading; this is really checking if a Value being used to index was loop IV invariant. Update comment. - the method is only used locally; what can be exposed in the future is isAccessInvariant(LoadOrStoreOp op, Value *iv) Signed-off-by: Uday Bondhugula <uday@polymagelabs.com> Closes tensorflow/mlir#285 COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/285 from bondhugula:quickfix fe5837abe987980c4ab469a9aa7de8e4f0007d9f PiperOrigin-RevId: 283771923
| * [spirv] Adding sqrt op in the GLSL extension.Scott Todd2019-12-043-1/+69
| | | | | | | | PiperOrigin-RevId: 283769736
| * Loop coalescing: fix pointer chainsing in use-chain traversalAlex Zinenko2019-12-042-1/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
| * Added new FAbs, FCeil, Cos, Neg, Sign, Tanh operations.Julian Gross2019-12-043-242/+534
| | | | | | | | | | | | | | Closes tensorflow/mlir#251 COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/251 from dfki-jugr:new_ops 0398997bf9953016898f873068e22916a062eb2b PiperOrigin-RevId: 283750699
| * Adds support for unrolling single-result vector operations with iterator ↵Andy Davis2019-12-045-21/+432
| | | | | | | | | | | | | | | | type lists and indexing maps to a target vector size. Adds unit tests for unrolling the vector ContractionOp with different iteration orders. PiperOrigin-RevId: 283747503
| * minor spelling tweaksKazuaki Ishizaki2019-12-048-12/+12
| | | | | | | | | | | | | | Closes tensorflow/mlir#250 COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/250 from kiszk:spelling_tweaks_201911 50fc04443723190b764e824b6fcd2469fecb56e6 PiperOrigin-RevId: 283733032
| * Avoid variable name conflict in MLIR tutorial code snippetSmit Hinsu2019-12-031-4/+5
| | | | | | | | PiperOrigin-RevId: 283682865
| * Refactor dependencies to expose Vector transformations as patterns - NFCNicolas Vasilache2019-12-0329-88/+210
| | | | | | | | | | | | | | | | | | This CL refactors some of the MLIR vector dependencies to allow decoupling VectorOps, vector analysis, vector transformations and vector conversions from each other. This makes the system more modular and allows extracting VectorToVector into VectorTransforms that do not depend on vector conversions. This refactoring exhibited a bunch of cyclic library dependencies that have been cleaned up. PiperOrigin-RevId: 283660308
| * [spirv] Add spv.GroupNonUniformBallotLei Zhang2019-12-037-7/+170
| | | | | | | | | | | | | | | | | | This CL also did the following cleanup: - Moved the test for spv.SubgroupBallotKHR to its own file - Wrapped generated canonicalization patterns in anonymous namespace - Updated header comments in SPVOps.td PiperOrigin-RevId: 283650091
| * Add a pass to legalize operations before lowering to SPIR-V.Mahesh Ravishankar2019-12-039-2/+362
| | | | | | | | | | | | | | | | | | | | | | | | Not all StandardOps can be lowered to SPIR-V. For example, subview op implementation requires use of pointer bitcasts which is not valid according to SPIR-V spec (or at least is ambiguous about it). Such ops need to be removed/transformed before lowering to SPIR-V. The SPIRVLegalizationPass is added a place where such legalizations can be added. Current implementation folds the subview ops with load/stores so that the lowering itself does not have to convert a subview op. PiperOrigin-RevId: 283642981
| * Make diagnostic a bit clearer.Sean Silva2019-12-032-2/+2
| | | | | | | | | | | | This prints out in case of any pass failure. Not just a crash. PiperOrigin-RevId: 283616719
| * Add CreateMaskOp to the VectorOps dialect.Andy Davis2019-12-034-1/+84
| | | | | | | | PiperOrigin-RevId: 283591888
| * Verifier: Better error message in case of successor operand mismatch.Sean Silva2019-12-032-7/+23
| | | | | | | | | | | | In particular, print the successor number in the diagnostic. PiperOrigin-RevId: 283585084
| * Allow analyses to provide a hook 'isInvalidated' to determine if they are ↵River Riddle2019-12-033-9/+85
| | | | | | | | | | | | | | | | | | | | | | | | | | | | truly invalidated. The hook has the following form: * `bool isInvalidated(const AnalysisManager::PreservedAnalyses &)` Given a preserved analysis set, the analysis returns true if it should truly be invalidated. This allows for more fine-tuned invalidation in cases where an analysis wasn't explicitly marked preserved, but may be preserved(or invalidated) based upon other properties; such as analyses sets. PiperOrigin-RevId: 283582889
| * Convert MemRefType to a linearized array in SPIR-V lowering.Mahesh Ravishankar2019-12-034-80/+115
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The SPIR-V lowering used nested !spv.arrays to represented multi-dimensional arrays, with the hope that in-conjunction with the layout annotations, the shape and layout of memref can be represented directly. It is unclear though how portable this representation will end up being. It will rely on driver compilers implementing complex index computations faithfully. A more portable approach is to use linearized arrays to represent memrefs and explicitly instantiate all the index computation in SPIR-V. This gives added benefit that we can further optimize the generated code in MLIR before generating the SPIR-V binary. PiperOrigin-RevId: 283571167
OpenPOWER on IntegriCloud