summaryrefslogtreecommitdiffstats
path: root/mlir/lib
Commit message (Collapse)AuthorAgeFilesLines
...
* Implement folding of pattern dim(subview(_)[...][s1, ..., sn][...], i) -> si.Stephan Herhut2019-11-181-1/+9
| | | | PiperOrigin-RevId: 281042016
* Rename CLI flags -lower-gpu-ops-to-*-ops to -convert-gpu-to-*Alex Zinenko2019-11-182-3/+2
| | | | | | | This makes the flags consistent with the naming scheme used elsewhere in the codebase for dialect conversions. PiperOrigin-RevId: 281027517
* [spirv] Add bit opsDenis Khalikov2019-11-151-0/+86
| | | | | | | | | | | | | This CL added op definitions for a few bit operations: * OpBitFieldInsert * OpBitFieldSExtract * OpBitFieldUExtract Closes tensorflow/mlir#233 COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/233 from denis0x0D:sandbox/bit_field_ops e7fd85b00d72d483d7992dc42b9cc4d673903455 PiperOrigin-RevId: 280691816
* NFC: Convert CmpIPredicate in StandardOps to use EnumAttrLei Zhang2019-11-156-90/+39
| | | | | | This turns several hand-written functions to auto-generated ones. PiperOrigin-RevId: 280684326
* Fix build warningsNicolas Vasilache2019-11-151-0/+1
| | | | | | | | | Delete unused constexpr ints in LowerToLLVMDialect. Add (void)toStringRef for non-debug builds. Fixes tensorflow/mlir#232. PiperOrigin-RevId: 280671014
* Templatize linalg::LowerToLoops - NFCNicolas Vasilache2019-11-151-65/+80
| | | | | | | This modification will allow to easily plug lowering of linalg ops to different types of loops (affine, loop.for and other future constructs). This is purely NFC for now. PiperOrigin-RevId: 280652186
* Refactor the LowerVectorTransfers pass to use the RewritePattern infra - NFCNicolas Vasilache2019-11-146-49/+32
| | | | | | 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
* NFC: Refactor Dialect Conversion targeting SPIR-V.Mahesh Ravishankar2019-11-148-434/+555
| | | | | | | | | | | | Refactoring the conversion from StandardOps/GPU dialect to SPIR-V dialect: 1) Move the SPIRVTypeConversion and SPIRVOpLowering class into SPIR-V dialect. 2) Add header files that expose functions to add patterns for the dialects to SPIR-V lowering, as well as a pass that does the dialect to SPIR-V lowering. 3) Make SPIRVOpLowering derive from OpLowering class. PiperOrigin-RevId: 280486871
* Adds canonicalizer to SubViewOp which folds constants from base memref and ↵Andy Davis2019-11-141-4/+161
| | | | | | | | 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
* Add CMakeLists.txt for AffineToStandard conversionAlex Zinenko2019-11-141-0/+24
| | | | PiperOrigin-RevId: 280470142
* [ODS] Fix operation argument population to avoid crashLei Zhang2019-11-142-6/+34
| | | | | | | | | | The `Operator` class keeps an `arguments` field, which contains pointers to `operands` and `attributes` elements. Thus it must be populated after `operands` and `attributes` are finalized so to have stable pointers. SmallVector may re-allocate when still having new elements added, which will invalidate pointers. PiperOrigin-RevId: 280466896
* Move Affine to Standard conversion to lib/ConversionAlex Zinenko2019-11-145-5/+6
| | | | | | | This is essentially a dialect conversion and conceptually belongs to conversions. PiperOrigin-RevId: 280460034
* Make positions of elements in MemRef descriptor privateAlex Zinenko2019-11-141-25/+17
| | | | | | | | Previous commits removed all uses of LLVMTypeConverter::k*PosInMemRefDescriptor outside of the MemRefDescriptor class. These numbers are an implementation detail and can be hidden under a layer of more semantic APIs. PiperOrigin-RevId: 280442444
* Use MemRefDescriptor in Vector-to-LLVM convresionAlex Zinenko2019-11-142-38/+19
| | | | | | | | | | Following up on the consolidation of MemRef descriptor conversion, update Vector-to-LLVM conversion to use the helper class that abstracts away the implementation details of the MemRef descriptor. This also makes the types of the attributes in emitted llvm.insert/extractelement operations consistently i64 instead of a mix of index and i64. PiperOrigin-RevId: 280441451
* Adapt code to LLVM API updates.MLIR Team2019-11-141-1/+1
| | | | PiperOrigin-RevId: 280431812
* Move VectorOps to Tablegen - (almost) NFCNicolas Vasilache2019-11-146-323/+136
| | | | | | | | | | | | | | | | 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
* Use MemRefDescriptor in Linalg-to-LLVM conversionAlex Zinenko2019-11-142-201/+157
| | | | | | | | | | | Following up on the consolidation of MemRef descriptor conversion, update Linalg-to-LLVM conversion to use the helper class that abstracts away the implementation details of the MemRef descriptor. This required MemRefDescriptor to become publicly visible. Since this conversion is heavily EDSC-based, introduce locally an additional wrapper that uses builder and location pointed to by the EDSC context while emitting descriptor manipulation operations. PiperOrigin-RevId: 280429228
* Concentrate memref descriptor manipulation logic in one placeAlex Zinenko2019-11-141-165/+174
| | | | | | | | | | | Memref descriptor is becoming increasingly complex. Memrefs are manipulated by multiple standard instructions, each of which has a non-trivial lowering to the LLVM dialect. This leads to verbose code that manipulates the descriptors exposing the internals of insert/extractelement opreations. Implement a wrapper class that contains a memref descriptor and provides semantically named methods that build the primitive IR operations instead. PiperOrigin-RevId: 280371225
* Do not emit aliases when printing local formJacques Pienaar2019-11-131-2/+10
| | | | | | Expand local scope printing to skip printing aliases as aliases are printed out at the top of a module and may not be part of the output generated by local scope print. PiperOrigin-RevId: 280278617
* Replace explicit concatenation by llvm::concatNicolas Vasilache2019-11-131-4/+2
| | | | PiperOrigin-RevId: 280258938
* Deprecate linalg.subview in favor of std.subviewNicolas Vasilache2019-11-139-173/+120
| | | | | | | | | | | This CL uses the now standard std.subview in linalg. Two shortcuts are currently taken to allow this port: 1. the type resulting from a view is currently degraded to fully dynamic to pass the SubViewOp verifier. 2. indexing into SubViewOp may access out of bounds since lowering to LLVM does not currently enforce it by construction. These will be fixed in subsequent commits after discussions. PiperOrigin-RevId: 280250129
* Add FuncOp::eraseArgumentSean Silva2019-11-131-0/+35
| | | | | | | | | | | | This is a quite complex operation that users are likely to attempt to write themselves and get wrong (citation: users=me). Ideally, we could pull this into FunctionLike, but for now, the FunctionType rewriting makes it FuncOp specific. We would need some hook for rewriting the function type (which for LLVM's func op, would need to rewrite the underlying LLVM type). PiperOrigin-RevId: 280234164
* NFC: Refactor block signature conversion to not erase the original arguments.River Riddle2019-11-132-189/+211
| | | | | | 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
* Rename the current parseSymbolName to parseOptionalSymbolNameRiver Riddle2019-11-133-14/+14
| | | | | | The current implementation silently fails if the '@' identifier isn't present, making it similar to the 'optional' parse methods. This change renames the current implementation to 'Optional' and adds a new 'parseSymbolName' that emits an error. PiperOrigin-RevId: 280214610
* Make VariableOp instructions be in the first block in the function.Hanhan Wang2019-11-121-20/+97
| | | | | | | | | | | Since VariableOp is serialized during processBlock, we add two more fields, `functionHeader` and `functionBody`, to collect instructions for a function. After all the blocks have been processed, we append them to the `functions`. Also, fix a bug in processGlobalVariableOp. The global variables should be encoded into `typesGlobalValues`. PiperOrigin-RevId: 280105366
* Add operations needed to support lowering of AffineExpr to SPIR-V.Mahesh Ravishankar2019-11-121-14/+72
| | | | | | | | Lowering of CmpIOp, DivISOp, RemISOp, SubIOp and SelectOp to SPIR-V dialect enables the lowering of operations generated by AffineExpr -> StandardOps conversion into the SPIR-V dialect. PiperOrigin-RevId: 280039204
* NFC: Change DictionaryAttr::get(StringRef) to use binary search instead of a ↵River Riddle2019-11-121-5/+7
| | | | | | | | linear scan. The elements of a DictionaryAttr are guaranteed to be sorted by name, so we can use a more efficient lookup when searching for an attribute. PiperOrigin-RevId: 280035488
* Make legality check in GPU->SPIR-V lowering of FuncOp kernel specific.Mahesh Ravishankar2019-11-121-2/+7
| | | | | | | | | | Existing check that sets FuncOp to be dynamically legal was just checking that the types of the argument are SPIR-V compatible. Since the current conversion from GPU to SPIR-V does not handle lowering non-kernel functions, change the legality check to verify that the FuncOp has the gpu.kernel attribute and has void(void) return type. PiperOrigin-RevId: 280032782
* Add support for OpPhi in loop header blockLei Zhang2019-11-123-8/+52
| | | | | | | | | | | | During deserialization, the loop header block will be moved into the spv.loop's region. If the loop header block has block arguments, we need to make sure it is correctly carried over to the block where the new spv.loop resides. During serialization, we need to make sure block arguments from the spv.loop's entry block are not silently dropped. PiperOrigin-RevId: 280021777
* Add an option to print an operation if a diagnostic is emitted on itRiver Riddle2019-11-121-6/+40
| | | | | | It is often helpful to inspect the operation that the error/warning/remark/etc. originated from, especially in the context of debugging or in the case of a verifier failure. This change adds an option 'mlir-print-op-on-diagnostic' that attaches the operation as a note to any diagnostic that is emitted on it via Operation::emit(Error|Warning|Remark). In the case of an error, the operation is printed in the generic form. PiperOrigin-RevId: 280021438
* Expose an isSubclassOf() method on AttrConstraintLei Zhang2019-11-121-11/+13
| | | | PiperOrigin-RevId: 280021408
* Add Conversion to lower loop::ForOp to spirv::LoopOp.Mahesh Ravishankar2019-11-121-1/+83
| | | | | | | | | loop::ForOp can be lowered to the structured control flow represented by spirv::LoopOp by making the continue block of the spirv::LoopOp the loop latch and the merge block the exit block. The resulting spirv::LoopOp has a single back edge from the continue to header block, and a single exit from header to merge. PiperOrigin-RevId: 280015614
* Add a printer flag to use local scope when printing IR.River Riddle2019-11-123-8/+22
| | | | | | This causes the AsmPrinter to use a local value numbering when printing the IR, allowing for the printer to be used safely in a local context, e.g. to ensure thread-safety when printing the IR. This means that the IR printing instrumentation can also be used during multi-threading when module-scope is disabled. Operation::dump and DiagnosticArgument(Operation*) are also updated to always print local scope, as this is the most common use case when debugging. PiperOrigin-RevId: 279988203
* Add LLVM lowering of std.subviewNicolas Vasilache2019-11-121-0/+113
| | | | | | A followup CL will replace usage of linalg.subview by std.subview. PiperOrigin-RevId: 279961981
* Adds affine.min operation which returns the minimum value from a ↵Andy Davis2019-11-121-0/+75
| | | | | | multi-result affine map. This operation is useful for things like computing the dynamic value of affine loop bounds, and is trivial to constant fold. PiperOrigin-RevId: 279959714
* Add support for alignment attribute in std.alloc.Nicolas Vasilache2019-11-124-99/+188
| | | | | | | | | | | | This CL adds an extra pointer to the memref descriptor to allow specifying alignment. In a previous implementation, we used 2 types: `linalg.buffer` and `view` where the buffer type was the unit of allocation/deallocation/alignment and `view` was the unit of indexing. After multiple discussions it was decided to use a single type, which conflates both, so the memref descriptor now needs to carry both pointers. This is consistent with the [RFC-Proposed Changes to MemRef and Tensor MLIR Types](https://groups.google.com/a/tensorflow.org/forum/#!searchin/mlir/std.view%7Csort:date/mlir/-wKHANzDNTg/4K6nUAp8AAAJ). PiperOrigin-RevId: 279959463
* Restructure comment lexing to not recurse.River Riddle2019-11-112-100/+95
| | | | | | In some files that have large amounts of comments, this can lead to a stack overflow. PiperOrigin-RevId: 279867330
* Add support for nested symbol references.River Riddle2019-11-1115-34/+126
| | | | | | | | | | | | | | | | | | This change allows for adding additional nested references to a SymbolRefAttr to allow for further resolving a symbol if that symbol also defines a SymbolTable. If a referenced symbol also defines a symbol table, a nested reference can be used to refer to a symbol within that table. Nested references are printed after the main reference in the following form: symbol-ref-attribute ::= symbol-ref-id (`::` symbol-ref-id)* Example: module @reference { func @nested_reference() } my_reference_op @reference::@nested_reference Given that SymbolRefAttr is now more general, the existing functionality centered around a single reference is moved to a derived class FlatSymbolRefAttr. Followup commits will add support to lookups, rauw, etc. for scoped references. PiperOrigin-RevId: 279860501
* Adds std.subview operation which takes dynamic offsets, sizes and strides ↵Andy Davis2019-11-117-50/+152
| | | | | | | | and returns a memref type which represents sub/reduced-size view of its memref argument. This operation is a companion operation to the std.view operation added as proposed in "Updates to the MLIR MemRefType" RFC. PiperOrigin-RevId: 279766410
* Look for SymbolRefAttr in KernelOutlining instead of hard-coding CallOpMLIR Team2019-11-081-15/+17
| | | | | | | | This code should be exercised using the existing kernel outlining unit test, but let me know if I should add a dedicated unit test using a fake call instruction as well. PiperOrigin-RevId: 279436321
* Explicitly initialize isRecursivelyLegalJacques Pienaar2019-11-081-1/+1
| | | | | | | | | This also previously triggered the warning: warning: missing field 'isRecursivelyLegal' initializer [-Wmissing-field-initializers] legalOperations[op] = {action}; ^ PiperOrigin-RevId: 279399175
* [spirv] Add bit opsDenis Khalikov2019-11-081-0/+34
| | | | | | | | | | | | | | | | | | | This CL added op definitions for a few bit operations: * OpShiftLeftLogical * OpShiftRightArithmetic * OpShiftRightLogical * OpBitCount * OpBitReverse * OpNot Also moved the definition of spv.BitwiseAnd to follow the lexicographical order. Closes tensorflow/mlir#215 COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/215 from denis0x0D:sandbox/bit_ops d9b0852b689ac6c4879a9740b1740a2357f44d24 PiperOrigin-RevId: 279350470
* mlir-translate: support -verify-diagnosticsAlex Zinenko2019-11-074-48/+62
| | | | | | | | | | | MLIR translation tools can emit diagnostics and we want to be able to check if it is indeed the case in tests. Reuse the source manager error handlers provided for mlir-opt to support the verification in mlir-translate. This requires us to change the signature of the functions that are registered to translate sources to MLIR: it now takes a source manager instead of a memory buffer. PiperOrigin-RevId: 279132972
* Fix asm printer for affine exprUday Bondhugula2019-11-071-1/+4
| | | | | | | | | | | - fixes tensorflow/mlir#201 Signed-off-by: Uday Bondhugula <uday@polymagelabs.com> Closes tensorflow/mlir#204 COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/204 from bondhugula:printfix 3f8a5b65391f45598258b2735fecaa409fbde848 PiperOrigin-RevId: 279115720
* Swap operand order in std.view operation so that offset appears before ↵Andy Davis2019-11-071-30/+42
| | | | | | 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/+112
| | | | | | shape and layout map strides and offset. PiperOrigin-RevId: 279088023
* Update Linalg to use std.viewNicolas Vasilache2019-11-076-390/+59
| | | | | | Now that a view op has graduated to the std dialect, we can update Linalg to use it and remove ops that have become obsolete. As a byproduct, the linalg buffer and associated ops can also disappear. PiperOrigin-RevId: 279073591
* Add IndexedGenericOp to Linalg.Alexander Belyaev2019-11-062-27/+99
| | | | PiperOrigin-RevId: 279013404
* Replace some remnant uses of "inst" with "op".Sean Silva2019-11-067-41/+38
| | | | PiperOrigin-RevId: 278961676
* Add lowering of std.view to LLVMNicolas Vasilache2019-11-061-0/+126
| | | | | | | | | | | | | This CL ports the lowering of linalg.view to the newly introduced std.view. Differences in implementation relate to std.view having slightly different semantics: 1. a static or dynamic offset can be specified. 2. the size of the (contiguous) shape is passed instead of a range. 3. static size and stride information is extracted from the memref type rather than the range. Besides these differences, lowering behaves the same. A future CL will update Linalg to use this unified infrastructure. PiperOrigin-RevId: 278948853
OpenPOWER on IntegriCloud