summaryrefslogtreecommitdiffstats
path: root/mlir
Commit message (Collapse)AuthorAgeFilesLines
...
* Add Linalg CopyOpNicolas Vasilache2019-06-196-6/+207
| | | | | | | | | | This CL adds a generic CopyOp to Linalg and its lowering to loops. The CopyOp supports input and output permutation maps. When combined with tiling and allocating a new local buffer, this should provide basic support for implementing simple memory transfers with coalescing. At the moment, lowering copies to a library call is not supported. PiperOrigin-RevId: 253250497
* Add an overloaded 'get' method to DenseElementsAttr that accepts an ↵River Riddle2019-06-192-8/+13
| | | | | | initializer_list. PiperOrigin-RevId: 253234385
* Explicitly construct ArrayRef in AttributeTest.cppAlex Zinenko2019-06-191-4/+8
| | | | | | | | Some compilers find initializer list constructors from boolean literals ambiguous between ArrayRef<bool> and ArrayRef<Attribute>. Call the ArrayRef<bool> constructor explicitly to disambiguate. PiperOrigin-RevId: 253224859
* Convert a nest affine loops to a GPU kernelAlex Zinenko2019-06-1918-34/+621
| | | | | | | | | This converts entire loops into threads/blocks. No check on the size of the block or grid, or on the validity of parallelization is performed, it is under the responsibility of the caller to strip-mine the loops and to perform the dependence analysis before calling the conversion. PiperOrigin-RevId: 253189268
* Refactor SplatElementsAttr to inherit from DenseElementsAttr as opposed to ↵River Riddle2019-06-1933-446/+299
| | | | | | being a separate Attribute type. DenseElementsAttr provides a better internal representation for splat values as well as better API for accessing elements. PiperOrigin-RevId: 253138287
* NFC: Fix a narrowing conversion from size_t to int64_t when constructing a ↵River Riddle2019-06-191-1/+1
| | | | | | VectorType. PiperOrigin-RevId: 253125435
* NFC: Fix a warning for casting away const qualifiers.River Riddle2019-06-191-3/+3
| | | | PiperOrigin-RevId: 253124057
* Add ability to verify type matching between operands/resultsGeoffrey Martin-Noble2019-06-193-13/+80
| | | | | | This extends and generalizes the functionality for checking that element types match PiperOrigin-RevId: 253110512
* Add a definition of the library function to use when Linalg ops areMahesh Ravishankar2019-06-193-64/+123
| | | | | | lowered to LLVM, instead of expecting one to exist in the Module PiperOrigin-RevId: 253097382
* Add several utility 'getValues<T>' functions to DenseElementsAttr that ↵River Riddle2019-06-192-129/+170
| | | | | | return ranges as opposed to filling a SmallVector. This is much more efficient for the general case and allows for avoiding constructing APInt/APFloat/Attribute when possible. PiperOrigin-RevId: 253092550
* Disallow non-index operands and results in affine.applyAlex Zinenko2019-06-192-0/+29
| | | | | | | | | `affine.apply` is supposed to operate on values of index types in context of affine loops. It is possible to programmatically constuct an `affine.apply` that takes values of other types as operands or returns them, but it would not be parseable. Disallow such cases in the verifier. PiperOrigin-RevId: 253021704
* GPU Dialect: introduce gpu.returnAlex Zinenko2019-06-196-14/+68
| | | | | | | | | | | | | | This terminator operation should appear at the end of the blocks in the body region of `gpu.launch` when the control flow needs to be returned from the kernel. Using `std.return` in this place is ambiguous: it may exit the body region or the enclosing function. Furthermore, this allows the GPU dialect to impose the absence of return values as required by the underlying kernel execution models. Update outlining transformation from `gpu.launch` to `gpu.launch_func` so that it replaces `gpu.return` with `std.return`. PiperOrigin-RevId: 252985992
* [spirv] Add SPV_StorageClassAttr and PointerTypeLei Zhang2019-06-197-11/+207
| | | | | | | | | Pointer types need to specify the storage class. We use the utility functions generated from SPV_StorageClassAttr to parse and print the storage classes. Also improved the case that no element type is provided for (runtime) array. PiperOrigin-RevId: 252935599
* Update the Parser to support parsing/printing DenseElementAttrs with a splat ↵River Riddle2019-06-197-114/+108
| | | | | | | | | value. The syntax for this is the same as 0-D tensors: dense<tensor<100x100x100xi32>, 10> dense<tensor<1x1x1xi64>, -5> PiperOrigin-RevId: 252907880
* [spirv] Use mlir::parseType in type parsers and add more checksLei Zhang2019-06-194-56/+124
| | | | PiperOrigin-RevId: 252874386
* [ODG] Fix value indices in verification error messagesLei Zhang2019-06-193-24/+29
| | | | | | | we should use the dynamic index for the specific value instead of the static one for ODS-declared values. PiperOrigin-RevId: 252873052
* Add Linalg FillOpNicolas Vasilache2019-06-194-17/+78
| | | | | | | | | | This CL adds a generic FillOp to Linalg and its lowering to loops. This is achieved by avoiding to specify the static NLoopTypes and ViewRanks type traits but instead defines the relevant methods as `extraClassDeclaration`. The relevant AffineMap and scalar emission code are added, with relevant tests. This gives us a first rank-agnostic Linalg op with its generic lowering to loops that should compose with view-based tiling and fusion. PiperOrigin-RevId: 252869205
* Fix static assertion in AttributeDetail.hAlex Zinenko2019-06-191-1/+1
| | | | | | llvm::maskTrailingOnes<char> runs into a static assertion on the type not being unsigned. Use `unsigned char` instead of `char`. PiperOrigin-RevId: 252827214
* Update 2 instances of isa<BlockArgument>Nicolas Vasilache2019-06-191-2/+2
| | | | PiperOrigin-RevId: 252739405
* Fix OSS buildNicolas Vasilache2019-06-191-5/+5
| | | | | | | | | | | | Missing a spot with std::make_pair causes a compiler error in OSS. Also fixes the warning: ``` warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses] it->getSecond()->getType().isa<BufferType>() && ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~ "Buffer or block argument expected"); ``` PiperOrigin-RevId: 252738323
* Refactor DenseElementsAttr to support auto-splatting the dense data on ↵River Riddle2019-06-198-104/+444
| | | | | | construction. This essentially means that we always auto-detect splat data and only store the minimum amount of data necessary. Support for parsing dense splats, and removing SplatElementsAttr(now that it is redundant) will come in followup cls PiperOrigin-RevId: 252720561
* Add basic cost modeling to the dialect conversion infrastructure. This ↵River Riddle2019-06-194-10/+169
| | | | | | | | | | | | initial cost model favors specific patterns based upon two criteria: 1) Lowest minimum pattern stack depth when legalizing. - This leads the system to favor patterns that have lower legalization stacks, i.e. represent a more direct mapping to the target. 2) Pattern benefit. - When considering multiple patterns with the same legalization depth, this favors patterns with a larger specified benefit. PiperOrigin-RevId: 252713470
* Add a Linalg fusion pass.Nicolas Vasilache2019-06-1914-51/+1117
| | | | | | | | | | | | | | | | This CL adds a fusion pass for the Linalg dialect. Fusion is backed by a simple analysis on SSA values and proceeds as follows: 1. A dependence and alias analyses are performed on views. 2. A Linalg op is tiled by a particular tile size. This creates a new Linalg op operating on tiled loops and tiled views. 3. The dependence analysis is used to obtain ops that produce views that are consumed by the original Linalg op. 4. Dependence analysis is used to determine whether op-level fusion would violate any dependence. 5. If fusion is safe, matching tiled views are sliced for the producing op. 6. A tiled clone of the producer op is written before the tiled consumer op. If a producer is fused, its entire output view has been computed in tiled form. The original producer op is then erased. PiperOrigin-RevId: 252695194
* Add a lowering for Linalg matmul to LLVMNicolas Vasilache2019-06-199-89/+282
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This CL adds a lowering to LLVM for MamulOp and a corresponding integration test. View descriptor manipulation is moved from MLIR's LLVM dialect to C++ code compiled on the side. To this end a separation is introduced between `cblas.cpp` and `cblas_interface.cpp`, the latter operating on view types whose ABI correspond to the LLVM signature generated by MLIR. An intermediary step is introduced that allocates a new descriptor on the MLIR side for the purpose of passing it to LLVM. The reason for this extra step is that the ABI for by-value ViewType objects wants aligned descriptors, e.g.: ``` extern "C" void linalg_dot_impl(ViewType<float, 1> X, ViewType<float, 1> Y, BaseViewType<float> Z) { ... } ``` produces LLVM IR with the signature: ``` %struct.ViewType = type { %struct.BaseViewType, [1 x i64], [1 x i64] } %struct.BaseViewType = type { float*, i64 } define void @linalg_dot_impl(%struct.ViewType* byval align 8, %struct.ViewType* byval align 8, float*, i64) tensorflow/mlir#0 { ... } ``` We don't seem to be able to make such aligned allocations in the MLIR -> LLVM converter atm. Going through a level of indirection allows the test to pass. The temporary tradeoff is that the MLIR shims have to be written by hand. They will disappear in the future. PiperOrigin-RevId: 252670672
* Simplify trait naming for verifying argument/result constraints.Jacques Pienaar2019-06-194-57/+66
| | | | | | Improve the naming to something more intuitive. PiperOrigin-RevId: 252662347
* [spirv] Add a skeleton to translate standard ops into SPIR-V dialectMahesh Ravishankar2019-06-197-1/+193
| | | | PiperOrigin-RevId: 252651994
* Add a utility to OpAsmPrinter for printing an optional trailing arrow type ↵River Riddle2019-06-192-21/+14
| | | | | | list. This is useful for any operation that wants to print a set of types in the same format as a FunctionType/Operation signature. PiperOrigin-RevId: 252647152
* NFC: Cleanup the naming scheme for registering legalization actions to be ↵River Riddle2019-06-119-37/+68
| | | | | | consistent, and move a file functions to the source file. PiperOrigin-RevId: 252639629
* Use DialectConversion to lower the Affine dialect to the Standard dialectAlex Zinenko2019-06-114-281/+396
| | | | | | | | | | | | | | | | | | | | | This introduces the support for region-containing operations to the dialect conversion framework in order to support the conversion of affine control-flow operations into the standard control flow with branches. Regions that belong to an operation are converted before the operation itself. The DialectConversionPattern can therefore access the converted regions of the original operation and process them further if necessary. In particular, the conversion is allowed to move the blocks from the original region to other regions and to split blocks into multiple blocks. All block manipulations must be performed through the PatternRewriter to ensure they will be undone if the conversion fails. Port the pass converting from the affine dialect (loops and ifs with bodies as regions) to the standard dialect (branch-based cfg) to use DialectConversion in order to exercise this new functionality. The modification to the lowering functions are minor and are focused on using the PatterRewriter instead of directly modifying the IR. PiperOrigin-RevId: 252625169
* [spirv] Include SPIRVStructureOps.td in SPIRVOps.tdLei Zhang2019-06-116-14/+7
| | | | | | | This allows us to have SPIRVOps.td as the single entry point for all SPIR-V ops, which simplifies downstream users and build rules. PiperOrigin-RevId: 252609258
* [ODG] Add support for private methods in class writersLei Zhang2019-06-111-10/+45
| | | | PiperOrigin-RevId: 252602093
* [spirv] Add missing CMake rules for enum utility generationLei Zhang2019-06-112-1/+9
| | | | PiperOrigin-RevId: 252601308
* Add bool constant attributes.Jacques Pienaar2019-06-111-0/+2
| | | | PiperOrigin-RevId: 252551030
* Fix MSVC 2019 missing <string> include (NFC)Mehdi Amini2019-06-111-0/+1
| | | | | | Fix tensorflow/mlir#31. PiperOrigin-RevId: 252547010
* Change a call to FloatAttr::getChecked to FloatAttr::get inside of ↵River Riddle2019-06-111-4/+1
| | | | | | 'parseFloatAttr'. The invariants of FloatAttr are already checked before construction. This also removes an unnecessary materialization of a mlir::Location which becomes expensive when parsing dense element literals. PiperOrigin-RevId: 252545776
* Add a general Operation::verify that verifies an operation instance and the ↵River Riddle2019-06-113-18/+55
| | | | | | dominance of operations in any nested regions. PiperOrigin-RevId: 252529850
* [spirv] Add values for enum cases and generate the enum utilitiesLei Zhang2019-06-114-15/+35
| | | | PiperOrigin-RevId: 252494957
* [spirv] NFC: use two spaces for indentation in gen_spirv_dialect.pyLei Zhang2019-06-111-87/+87
| | | | PiperOrigin-RevId: 252469663
* Expose a minimal type parser to dialects.Nicolas Vasilache2019-06-115-37/+67
| | | | | | | | | | | This CL exposes a parseType method which allows standalone reuse of the MLIR type parsing mechanism. This is a free function for now because the underlying MLIR parser is not guaranteed to receive a StringRef which lives in the proper MemBuffer. This requires building a new MemBuffer/SourceMgr and modifying the Parser constructor to not require an mlir::Module. The error diagnostic emitted by parseType has context limited to the local string. For now the dialect has the additional option to emit its own extra error that has the FileLineColLoc context. In the future, both error messages should be combined into a single error. PiperOrigin-RevId: 252468911
* [spirv] Add array and run-time array typesLei Zhang2019-06-116-4/+350
| | | | PiperOrigin-RevId: 252458108
* [ODG] Address compiler warnings of comparing signed and unsigned integer ↵Lei Zhang2019-06-111-1/+1
| | | | | | expressions PiperOrigin-RevId: 252442613
* Return dependence result enum to distiguish between dependence result and ↵Andy Davis2019-06-116-35/+59
| | | | | | error cases (NFC). PiperOrigin-RevId: 252437616
* [ODS] Support variadic operand/result verificationLei Zhang2019-06-0913-86/+152
| | | | | | | | | This CL enables verification code generation for variadic operands and results. In verify(), we use fallback getter methods to access all the dynamic values belonging to one static variadic operand/result to reuse the value range calculation there. PiperOrigin-RevId: 252288219
* [ODG] Use getODSOperands() and getODSResults() to back accessorsLei Zhang2019-06-094-251/+123
| | | | | | | | | This CL added getODSOperands() and getODSResults() as fallback getter methods for getting all the dynamic values corresponding to a static operand/result (which can be variadic). It should provide a uniform way of calculating the value ranges. All named getter methods are layered on top of these methods now. PiperOrigin-RevId: 252284270
* [TableGen] Generating enum definitions and utility functionsLei Zhang2019-06-099-2/+472
| | | | | | | | | | | | | Enum attributes can be defined using `EnumAttr`, which requires all its cases to be defined with `EnumAttrCase`. To facilitate the interaction between `EnumAttr`s and their C++ consumers, add a new EnumsGen TableGen backend to generate a few common utilities, including an enum class, `llvm::DenseMapInfo` for the enum class, conversion functions from/to strings. This is controlled via the `-gen-enum-decls` and `-gen-enum-defs` command-line options of `mlir-tblgen`. PiperOrigin-RevId: 252209623
* Update function comment, since we added FP16 support for getZeroAttr.MLIR Team2019-06-091-2/+2
| | | | PiperOrigin-RevId: 252110998
* NFC: Cleanup the grouping of DenseElementsAttr 'get' methods, and move the ↵River Riddle2019-06-092-108/+109
| | | | | | bit write/read functions to static functions in Attributes.cpp. PiperOrigin-RevId: 252094145
* Remove the ability to directly construct a DenseElementsAttr with a raw ↵River Riddle2019-06-096-41/+81
| | | | | | | | | character buffer. This made assumptions about how DenseElementsAttr structured its internal storage, which may change in the future. To replace the existing use cases, a few utility methods have been added: * 'get' methods that allow constructing from an ArrayRef of integer or floating point values. * A 'reshape' method to allow for changing the shape without changing the underlying data. PiperOrigin-RevId: 252067898
* NFC: Cleanup FuncVerifier and refactor it into a general OperationVerifier. ↵River Riddle2019-06-092-144/+139
| | | | | | The function specific verification has been moved into Function::verify. This is in preparation for adding a general Operation::verify method. PiperOrigin-RevId: 252065646
* Remove unnecessary StandardOps dependencyGeoffrey Martin-Noble2019-06-091-1/+1
| | | | PiperOrigin-RevId: 252032386
OpenPOWER on IntegriCloud