summaryrefslogtreecommitdiffstats
path: root/mlir/lib/Conversion
Commit message (Collapse)AuthorAgeFilesLines
...
* NFC: Update usages of OwningRewritePatternList to pass by & instead of &&.River Riddle2019-08-094-6/+4
| | | | | | This will allow for reusing the same pattern list, which may be costly to continually reconstruct, on multiple invocations. PiperOrigin-RevId: 262664599
* Add support for floating-point comparison 'fcmp' to the LLVM dialect.Nagy Mostafa2019-08-081-8/+28
| | | | | | | | This adds support for fcmp to the LLVM dialect and adds any necessary lowerings, as well as support for EDSCs. Closes tensorflow/mlir#69 PiperOrigin-RevId: 262475255
* NFC: Implement OwningRewritePatternList as a class instead of a using directive.River Riddle2019-08-054-8/+5
| | | | | | This allows for proper forward declaration, as opposed to leaking the internal implementation via a using directive. This also allows for all pattern building to go through 'insert' methods on the OwningRewritePatternList, replacing uses of 'push_back' and 'RewriteListBuilder'. PiperOrigin-RevId: 261816316
* Remove non-needed includes from ConvertControlFlowToCFG.cpp (NFC)Mehdi Amini2019-08-041-5/+0
| | | | | | | | The includes related to the LLVM dialect are not used in this file and introduce an implicit dependencies between the two libraries which isn't reflected in the CMakeLists.txt, causing non-deterministic build failures. PiperOrigin-RevId: 261576935
* Initial implementation to translate kernel fn in GPU Dialect to SPIR-V DialectMahesh Ravishankar2019-07-308-73/+414
| | | | | | | | | | | | | | | This CL adds an initial implementation for translation of kernel function in GPU Dialect (used with a gpu.launch_kernel) op to a spv.Module. The original function is translated into an entry function. Most of the heavy lifting is done by adding TypeConversion and other utility functions/classes that provide most of the functionality to translate from Standard Dialect to SPIR-V Dialect. These are intended to be reusable in implementation of different dialect conversion pipelines. Note : Some of the files for have been renamed to be consistent with the norm used by the other Conversion frameworks. PiperOrigin-RevId: 260759165
* Move GPU dialect to {lib,include/mlir}/DialectAlex Zinenko2019-07-255-5/+5
| | | | | | | Per tacit agreement, individual dialects should now live in lib/Dialect/Name with headers in include/mlir/Dialect/Name and tests in test/Dialect/Name. PiperOrigin-RevId: 259896851
* Add a utility function to populate StdOp to SPIRV Conversion PatternsMahesh Ravishankar2019-07-231-2/+9
| | | | | | | | The function populateStdOpsToSPIRVPatterns appends the conversion patterns automatically generated from StdOpsToSPIRVConversion.td to a list of patterns PiperOrigin-RevId: 259677890
* Add sitofp to the standard dialectMLIR Team2019-07-231-2/+8
| | | | | | Conversion from integers (window or input size, padding etc) to floating point is required to express many ML kernels, for example average pooling. PiperOrigin-RevId: 259575284
* NFC: Update the LoopToStd conversion patterns to use RewritePattern instead ↵River Riddle2019-07-221-35/+23
| | | | | | | | of ConversionPattern. These patterns don't require type changes so they don't need to be using ConversionPattern. PiperOrigin-RevId: 259393151
* Refactor region type signature conversion to be explicit via patterns.River Riddle2019-07-201-25/+45
| | | | | | This cl enforces that the conversion of the type signatures for regions, and thus their entry blocks, is handled via ConversionPatterns. A new hook 'applySignatureConversion' is added to the ConversionPatternRewriter to perform the desired conversion on a region. This also means that the handling of rewriting the signature of a FuncOp is moved to a pattern. A default implementation is provided via 'mlir::populateFuncOpTypeConversionPattern'. This removes the hacky implicit 'dynamically legal' status of FuncOp that was present previously, and leaves it up to the user to decide when/how to convert the signature of a function. PiperOrigin-RevId: 259161999
* Place generated StandardOps to SPIR-V patterns in anonymous namespaceLei Zhang2019-07-191-4/+2
| | | | | | This avoids polluting the mlir namespace. PiperOrigin-RevId: 258826497
* NFC: Expose a ConversionPatternRewriter for use with ConversionPatterns.River Riddle2019-07-192-37/+49
| | | | | | This specific PatternRewriter will allow for exposing hooks in the future that are only useful for the conversion framework, e.g. type conversions. PiperOrigin-RevId: 258818122
* Refactor the conversion of block argument types in DialectConversion.River Riddle2019-07-191-7/+5
| | | | | | | | This cl begins a large refactoring over how signature types are converted in the DialectConversion infrastructure. The signatures of blocks are now converted on-demand when an operation held by that block is being converted. This allows for handling the case where a region is created as part of a pattern, something that wasn't possible previously. This cl also generalizes the region signature conversion used by FuncOp to work on any region of any operation. This generalization allows for removing the 'apply*Conversion' functions that were specific to FuncOp/ModuleOp. The implementation currently uses a new hook on TypeConverter, 'convertRegionSignature', but this should ideally be removed in favor of using Patterns. That depends on adding support to the PatternRewriter used by ConversionPattern to allow applying signature conversions to regions, which should be coming in a followup. PiperOrigin-RevId: 258645733
* Move affine.for and affine.if to ODSNicolas Vasilache2019-07-161-16/+10
| | | | | | As the move to ODS is made, body and region names across affine and loop dialects are uniformized. PiperOrigin-RevId: 258416590
* Refactor DialectConversion to support different conversion modes.River Riddle2019-07-162-4/+4
| | | | | | | | | | | Users generally want several different modes of conversion. This cl refactors DialectConversion to provide two: * Partial (applyPartialConversion) - This mode allows for illegal operations to exist in the IR, and does not fail if an operation fails to be legalized. * Full (applyFullConversion) - This mode fails if any operation is not properly legalized to the conversion target. This allows for ensuring that the IR after a conversion only contains operations legal for the target. PiperOrigin-RevId: 258412243
* NFC: Move SPIR-V dialect to Dialect/ subdirectoryLei Zhang2019-07-162-4/+4
| | | | PiperOrigin-RevId: 258345603
* Replace linalg.for by loop.forNicolas Vasilache2019-07-163-40/+46
| | | | | | | With the introduction of the Loop dialect, uses of the `linalg.for` operation can now be subsumed 1-to-1 by `loop.for`. This CL performs the replacement and tests are updated accordingly. PiperOrigin-RevId: 258322565
* Remove lowerAffineConstructs and lowerControlFlow in favor of providing ↵River Riddle2019-07-162-17/+15
| | | | | | | | patterns. These methods don't compose well with the rest of conversion framework, and create artificial breaks in conversion. Replace these methods with two(populateAffineToStdConversionPatterns and populateLoopToStdConversionPatterns respectively) that populate a list of patterns to perform the same behavior. PiperOrigin-RevId: 258219277
* Decouple LLVM dialect from Standard dialectAlex Zinenko2019-07-161-3/+24
| | | | | | | | | | | | | | | Due to the absence of ODS support for enum attributes, the implementation of the LLVM dialect `icmp` operation was reusing the comparison predicate from the Standard dialect, creating an avoidable library dependency. With ODS support and ICmpPredicate attribute recently introduced, the dependency is no longer justified. Update the Standard to LLVM convresion to also convert the CmpIPredicate into LLVM::ICmpPredicate and remove the unnecessary includes. Note that the MLIRLLVMIR library did not explicitly depend on MLIRStandardOps, requiring dependees of MLIRLLVMIR to also depend on MLIRStandardOps, which should no longer be the case. PiperOrigin-RevId: 258148456
* Extract std.for std.if and std.terminator in their own dialectNicolas Vasilache2019-07-162-8/+6
| | | | | | | These ops should not belong to the std dialect. This CL extracts them in their own dialect and updates the corresponding conversions and tests. PiperOrigin-RevId: 258123853
* Remove the 'region' field from OpBuilder.River Riddle2019-07-121-1/+1
| | | | | | This field wasn't updated as the insertion point changed, making it potentially dangerous given the multi-level of MLIR(e.g. 'createBlock' would always insert the new block in 'region'). This also allows for building an OpBuilder with just a context. PiperOrigin-RevId: 257829135
* Lower affine control flow to std control flow to LLVM dialectNicolas Vasilache2019-07-125-1/+325
| | | | | | | | | | | | | This CL splits the lowering of affine to LLVM into 2 parts: 1. affine -> std 2. std -> LLVM The conversions mostly consists of splitting concerns between the affine and non-affine worlds from existing conversions. Short-circuiting of affine `if` conditions was never tested or exercised and is removed in the process, it can be reintroduced later if needed. LoopParametricTiling.cpp is updated to reflect the newly added ForOp::build. PiperOrigin-RevId: 257794436
* LoopsToGPU: use PassRegistration with constructorAlex Zinenko2019-07-121-11/+8
| | | | | | | | | | PassRegistration with an optional constructor was introduced after the LoopsToGPUPass, which resorted to deriving one pass from another as a means of accepting options supplied as command-line arguments. Use PassRegistration with constructor instead of defining a derived pass for LoopsToGPU. Also rename the pass to better reflect its current nature. PiperOrigin-RevId: 257786923
* Rename FunctionAttr to SymbolRefAttr.River Riddle2019-07-123-10/+10
| | | | | | This allows for the attribute to hold symbolic references to other operations than FuncOp. This also allows for removing the dependence on FuncOp from the base Builder. PiperOrigin-RevId: 257650017
* NFC: Replace Module::getNamedFunction with lookupSymbol<FuncOp>.River Riddle2019-07-123-14/+15
| | | | | | This allows for removing the last direct reference to FuncOp from ModuleOp. PiperOrigin-RevId: 257498296
* NFC: Remove Function::getModule.River Riddle2019-07-121-6/+5
| | | | | | There is already a more general 'getParentOfType' method, and 'getModule' is likely to be misused as functions get placed within different regions than ModuleOp. PiperOrigin-RevId: 257442243
* NFC: Rename Module to ModuleOp.River Riddle2019-07-103-4/+4
| | | | | | Module is a legacy name that only exists as a typedef of ModuleOp. PiperOrigin-RevId: 257427248
* Update ModuleOp::create(...) to take a Location instead of a context.River Riddle2019-07-101-1/+1
| | | | | | This allows for giving a Module a more interesting location than 'Unknown'. PiperOrigin-RevId: 257310117
* NFC: Rename Function to FuncOp.River Riddle2019-07-104-48/+46
| | | | PiperOrigin-RevId: 257293379
* Extend AffineToGPU to support Linalg loopsAlex Zinenko2019-07-096-250/+376
| | | | | | | | | | | | | | | | Extend the utility that converts affine loop nests to support other types of loops by abstracting away common behavior through templates. This also slightly simplifies the existing Affine to GPU conversion by always passing in the loop step as an additional kernel argument even though it is a known constant. If it is used, it will be propagated into the loop body by the existing canonicalization pattern and can be further constant-folded, otherwise it will be dropped by canonicalization. This prepares for the common loop abstraction that will be used for converting to GPU kernels, which is conceptually close to Linalg loops, while maintaining the existing conversion operational. PiperOrigin-RevId: 257172216
* NFC: Remove `Module::getFunctions` in favor of a general `getOps<T>`.River Riddle2019-07-084-4/+4
| | | | | | Modules can now contain more than just Functions, this just updates the iteration API to reflect that. The 'begin'/'end' methods have also been updated to iterate over opaque Operations. PiperOrigin-RevId: 257099084
* Add dependencies for standard ops to SPIR-V conversionLei Zhang2019-07-082-1/+5
| | | | PiperOrigin-RevId: 257026374
* NFC: Remove the various "::getFunction" methods.River Riddle2019-07-081-4/+5
| | | | | | These methods assume that a function is a valid builtin top-level operation, and removing these methods allows for decoupling FuncOp and IR/. Utility "getParentOfType" methods have been added to Operation/OpState to allow for querying the first parent operation of a given type. PiperOrigin-RevId: 257018913
* Add an mlir-cuda-runner tool.Stephan Herhut2019-07-042-10/+15
| | | | | | | | This tool allows to execute MLIR IR snippets written in the GPU dialect on a CUDA capable GPU. For this to work, a working CUDA install is required and the build has to be configured with MLIR_CUDA_RUNNER_ENABLED set to 1. PiperOrigin-RevId: 256551415
* Add missing mlir:: namespace in definition of createConvertToLLVMIRPass.Stephan Herhut2019-07-041-2/+2
| | | | PiperOrigin-RevId: 256546769
* Make ConvertStandardToLLVMPass extendable with other patternsAlex Zinenko2019-07-041-7/+43
| | | | | | | | | | | Extend the LLVM lowering pass to accept callbacks that construct an instance of (a subclass of) LLVMTypeConverter and populate a list of conversion patterns. These callbacks will be called when the pass processes a module and their results will be used to set up the dialect conversion infrastructure. Clients can now provide additional conversion patterns to avoid the need of materializing type conversions between LLVM and other types. PiperOrigin-RevId: 256532415
* NFC: Move Standard to SPIR-V conversion to lib/ConversionLei Zhang2019-07-034-0/+125
| | | | PiperOrigin-RevId: 256271759
* NFC: Refactor Module to be value typed.River Riddle2019-07-024-15/+16
| | | | | | As with Functions, Module will soon become an operation, which are value-typed. This eases the transition from Module to ModuleOp. A new class, OwningModuleRef is provided to allow for owning a reference to a Module, and will auto-delete the held module on destruction. PiperOrigin-RevId: 256196193
* NFC: Refactor Function to be value typed.River Riddle2019-07-014-78/+78
| | | | | | Move the data members out of Function and into a new impl storage class 'FunctionStorage'. This allows for Function to become value typed, which will greatly simplify the transition of Function to FuncOp(given that FuncOp is also value typed). PiperOrigin-RevId: 255983022
* Expose AffineToGPUPass for use with PassManagerAlex Zinenko2019-07-011-4/+21
| | | | | | | | Originally, AffineToGPUPass was created and registered in the source file mainly for testing purposes. Provide a factory function that constructs AffineToGPU pass to make it usable in pass pipelines. PiperOrigin-RevId: 255902831
* Add a pass that inserts getters for all cubins found via nvvm.cubinStephan Herhut2019-06-262-0/+148
| | | | | | | | | annotations. Getters are required as there are currently no global constants in MLIR and this is an easy way to unblock CUDA execution while waiting for those. PiperOrigin-RevId: 255169002
* Make GPU to CUDA transformations independent of CUDA runtime.Stephan Herhut2019-06-262-113/+69
| | | | | | | | | | | The actual transformation from PTX source to a CUDA binary is now factored out, enabling compiling and testing the transformations independently of a CUDA runtime. MLIR has still to be built with NVPTX target support for the conversions to be built and tested. PiperOrigin-RevId: 255167139
* Move the emitError/Warning/Remark utility methods out of MLIRContext and ↵River Riddle2019-06-252-13/+8
| | | | | | | | into the mlir namespace. Now that Locations are attributes, they have direct access to the MLIR context. This allows for simplifying error emission by removing unnecessary context lookups. PiperOrigin-RevId: 255112791
* GPUtoNVVM: adjust integer bitwidth when lowering special register opsAlex Zinenko2019-06-251-6/+27
| | | | | | | | | | | | | | GPU dialect operations (launch and launch_func) use `index` type for thread and block index values inside the kernel, for compatibility with affine loops. NVVM dialect operations, following the NVVM intrinsics, use `!llvm.i32` type, which does not necessarily have the same bit width as the lowered `index` type. Optionally sign-extend (indices are signed) or truncate the result of the NVVM dialect operation to the bit width of the lowered `index` type before passing it to other operations. This behavior is consistent with `std.index_cast`. We cannot use the latter since we are targeting LLVM dialect types directly, rather than standard integer types. PiperOrigin-RevId: 254980868
* Add gpu::GPUDialect::isKernel helper.Stephan Herhut2019-06-251-8/+4
| | | | | | Also some mild cleanup of the kernel to cubin conversion pass. PiperOrigin-RevId: 254959303
* NVVM target: emit nvvm.annotations for kernel functionsAlex Zinenko2019-06-251-16/+0
| | | | | | | | | | PTX backend in LLVM expects additional module-level metadata `!nvvm.annotations` that lists functions that can be used as GPU kernels. Generate this metadata based on the `gpu.kernel` attribute attached to functions. This attribute is added automatically by the kernel outlining pass in the GPU dialect lowering flow. PiperOrigin-RevId: 254957345
* Refactor the TypeConverter to support more robust type conversions:River Riddle2019-06-191-19/+14
| | | | | | | | | | | | * Support for 1->0 type mappings, i.e. when the argument is being removed. * Reordering types when converting a type signature. * Adding new inputs when converting a type signature. This cl also lays down the initial foundation for supporting 1->N type mappings, but full support will come in a followup. Moving forward, function signature changes will be driven by populating a SignatureConversion instance. This class contains all of the necessary information for adding/removing/remapping function signatures; e.g. addInputs, addResults, remapInputs, etc. PiperOrigin-RevId: 254064665
* Add a pass that translates GPU.launch_func into a series of runtime calls.Stephan Herhut2019-06-192-0/+394
| | | | | | | | This does not map the calls to the CUDA libary directly but uses a slim wrapper ABI on top that has more convenient types for code generation and is stable. Such ABI is expected to be provided by the actual runner. PiperOrigin-RevId: 253983833
* Fix GPUToNVVM naming: NNVM should have been NVVMAlex Zinenko2019-06-191-1/+1
| | | | | | Rename `createLowerGpuOpsToNNVMOpsPass` to `createLowerGpuOpsToNVVMOpsPass`. PiperOrigin-RevId: 253801577
* Make examples/Linalg3 depend on the new standard to LLVM conversion library.Alex Zinenko2019-06-191-2/+16
| | | | PiperOrigin-RevId: 253767820
OpenPOWER on IntegriCloud