Commit Graph

1967 Commits

Author SHA1 Message Date
River Riddle 704a7fb13e Add support for 1->N type mappings in the dialect conversion infrastructure. To support these mappings a hook must be overridden on the type converter: 'materializeConversion' :to generate a cast operation from the new types to the old type. This operation is automatically erased if all uses are removed, otherwise it remains in the IR for the user to handle.
PiperOrigin-RevId: 254411383
2019-06-22 09:16:06 -07:00
River Riddle d080efefe0 Cache instances of several common attributes(e.g. BoolAttr, UnitAttr) and types(I1/I16/I32/etc.) when creating the MLIRContext. This allows for these symbols to be accessed without the need to perform any lookups/locking.
PiperOrigin-RevId: 254410080
2019-06-22 09:15:51 -07:00
Nicolas Vasilache 235e2fe030 Support for 0-D case in Linalg ops
This CL adds support for O-D ops in Linalg ops by:
1. making the CopyOp maps optional instead of default valued
2. allowing certain map operations to accept and return empty maps
3. making linalg::LowerToLoops aware of these changes
4. providing a proper 0-D impl for CopyOp and FillOp
5. adding the relevant tests

PiperOrigin-RevId: 254381908
2019-06-22 09:15:36 -07:00
River Riddle 3e99d99553 Add an overload to 'PatternRewriter::inlineRegionBefore' that accepts a parent region for the insertion position. This allows for inlining the given region into the end of another region.
PiperOrigin-RevId: 254367375
2019-06-22 09:15:21 -07:00
Mehdi Amini 99d8334262 Add missing override on overridden virtual method (NFC)
PiperOrigin-RevId: 254349019
2019-06-22 09:15:05 -07:00
Nicolas Vasilache 0804750c9b Uniformize usage of OpBuilder& (NFC)
Historically the pointer-based version of builders was used.
This CL uniformizes to OpBuilder &

PiperOrigin-RevId: 254280885
2019-06-22 09:14:49 -07:00
Mahesh Ravishankar e19a0857a2 Fix a warning in enum value ecoding for SPIRV image types. Instead of
using the enum class in the packed struct, use unsigned value for
encoding and convert it lazily

PiperOrigin-RevId: 254258341
2019-06-22 09:14:33 -07:00
Mehdi Amini 25050960af TensorFlow operands can be broadcasted with each other and with the result, relax the verifier.
PiperOrigin-RevId: 254206814
2019-06-22 09:14:18 -07:00
Lei Zhang 2d6bbabe4b Add definition for OperandElementTypeIterator and ResultElementTypeIterator
These are useful utility iterators helping use to get the element types of
operands/results of shaped types.

Also defined ranges for these iterators.

PiperOrigin-RevId: 254180888
2019-06-22 09:14:01 -07:00
River Riddle 7202c4e69d Rename ConversionTarget::isLegal to isDynamicallyLegal to better represent what the function is actually checking.
PiperOrigin-RevId: 254141073
2019-06-22 09:13:45 -07:00
Mahesh Ravishankar d7ba69e811 Add SPIRV Image Type according to the spec described here :
https://www.khronos.org/registry/spir-v/specs/1.0/SPIRV.html#OpTypeImage.

Add new enums to describe Image dimensionality, Image Depth, Arrayed
information, Sampling, Sampler User information, and Image format.
Doesn's support the Optional Access qualifier at this stage

Fix Enum generator for tblgen to add "_" at the beginning if the enum
starts with a number.

PiperOrigin-RevId: 254091423
2019-06-19 23:09:01 -07:00
Lei Zhang 7848505ebd Print proper message saying variadic ops are not supported in RewriterGen
Support for ops with variadic operands/results will come later; but right now
a proper message helps to avoid deciphering confusing error messages later in
the compilation stage.

PiperOrigin-RevId: 254071820
2019-06-19 23:08:52 -07:00
Lei Zhang 9552409387 Add missing MLIRStandardOps dependency for MLIRGPU
PiperOrigin-RevId: 254070969
2019-06-19 23:08:42 -07:00
River Riddle 9764ae3f24 Refactor the TypeConverter to support more robust type conversions:
* 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
2019-06-19 23:08:33 -07:00
River Riddle 927b7074a8 Extract the function symbol table functionality, i.e. mapping and name uniquing, out of Module and into a new class SymbolTable. As modules become operations it is necessary to extract out this functionality that cannot be represented with a generic operation.
PiperOrigin-RevId: 254041734
2019-06-19 23:08:22 -07:00
Geoffrey Martin-Noble fd99b6ce97 Remove unnecessary -verify-diagnostics
These were likely added in error because of confusion about the flag when it was just called "-verify". The extra flag doesn't cause much harm, but it does make mlir-opt do more work and clutter the RUN line

PiperOrigin-RevId: 254037016
2019-06-19 23:08:13 -07:00
Geoffrey Martin-Noble d7d69569e7 Rename -verify mlir-opt flag to -verify-expected-diagnostics
This name has caused some confusion because it suggests that it's running op verification (and that this verification isn't getting run by default).

PiperOrigin-RevId: 254035268
2019-06-19 23:08:03 -07:00
Lei Zhang e31c47ee8b Export symbols in cpu runner cblas library
By default MSVC does not export any symbol and does not create a companion
.lib for a .dll. This will cause problems when trying to link against the
library.

PiperOrigin-RevId: 254033454
2019-06-19 23:07:54 -07:00
Stephan Herhut 9d81081d90 Add a pass that translates GPU.launch_func into a series of runtime calls.
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
2019-06-19 23:07:43 -07:00
River Riddle 30bbd91056 Simplify usages of SplatElementsAttr now that it inherits from DenseElementsAttr.
PiperOrigin-RevId: 253910543
2019-06-19 23:07:34 -07:00
River Riddle 18743a33ac NFC: Reorder the attribute classes alphabetically to improve readability.
PiperOrigin-RevId: 253894445
2019-06-19 23:07:24 -07:00
River Riddle 34cb51743d NFC: Append 'Location' to the end of each the location kinds. This is in preparation for making the location classes attributes instead of separate IR types.
PiperOrigin-RevId: 253860058
2019-06-19 23:07:15 -07:00
River Riddle dee282c7da Replace usages of 'UniquedFilename' with 'Identifier' and remove it. Identifier already contains all of the necessary functionality/verification, so having a separate class for filenames is unnecessary.
PiperOrigin-RevId: 253855505
2019-06-19 23:07:05 -07:00
Lei Zhang 23962b0d63 [spirv] Add spv.Variable
This is a direct modelling of SPIR-V's OpVariable. The custom assembly format
parsers/prints descriptor in a nicer way if presents. There are other common
decorations that can appear on variables like builtin, which can be supported
later.

This CL additionally deduplicates the parser/printer/verifier declaration
in op definitions by adding defaults to SPV_Op base.
by adding

PiperOrigin-RevId: 253828254
2019-06-19 23:06:55 -07:00
Mehdi Amini 847e15e3c2 Add a setAttrList() method on mlir::Operation
This is an efficient method to copy attributes from one operation to
another.

PiperOrigin-RevId: 253806004
2019-06-19 23:06:45 -07:00
Alex Zinenko 14e2f4a22b Fix GPUToNVVM naming: NNVM should have been NVVM
Rename `createLowerGpuOpsToNNVMOpsPass` to `createLowerGpuOpsToNVVMOpsPass`.

PiperOrigin-RevId: 253801577
2019-06-19 23:06:36 -07:00
Andy Davis 59b68146ff Factor fusion compute cost calculation out of LoopFusion and into LoopFusionUtils (NFC).
PiperOrigin-RevId: 253797886
2019-06-19 23:06:26 -07:00
Jacques Pienaar 79ea320c75 Add missing cmake dependency from Linalg to MLIRStandardToLLVM.
PiperOrigin-RevId: 253788170
2019-06-19 23:06:16 -07:00
Alex Zinenko 4cba614c19 Put createGpuKernelOutliningPass in MLIR namespace
This function was declared in the `mlir` namespace but defined in the global
namespace, leading to linking errors when used.

PiperOrigin-RevId: 253784410
2019-06-19 23:06:07 -07:00
Alex Zinenko b9beff0384 Make examples/Linalg3 depend on the new standard to LLVM conversion library.
PiperOrigin-RevId: 253767820
2019-06-19 23:05:57 -07:00
Stephan Herhut e0596a4d63 Use llvm::StringSwitch in lowering of GPU ops to NVVM ops.
PiperOrigin-RevId: 253767688
2019-06-19 23:05:48 -07:00
Stephan Herhut 893374bfa2 Add a pass that translates a CUDA kernel function (tagged with nvvm.kernel) to
a CUBIN blob for execution on CUDA GPUs.

This is a first in a series of patches to build a simple CUDA runner to allow
experimenting with MLIR code on GPUs.

PiperOrigin-RevId: 253758915
2019-06-19 23:05:37 -07:00
Stephan Herhut b4ab7763c6 Add mlir::Function::eraseBody helper to remove the body of a function.
This does not add any new functionality but gives clearing the blocks of the
body region a more obvious name.

PiperOrigin-RevId: 253751382
2019-06-19 23:05:28 -07:00
River Riddle 2b67821b90 Fix the detection of boolean splat values in DenseElementsAttr for arrays with <=15 values.
PiperOrigin-RevId: 253711372
2019-06-19 23:05:19 -07:00
Mehdi Amini 92d4eb69b5 Add a TableGen Type predicate to check that an operand type can be broadcasted to a particular output type
PiperOrigin-RevId: 253694397
2019-06-19 23:05:09 -07:00
Mehdi Amini 74df13fdda Refactor generic op printing: extract a public printFunctionalType() on OpAsmPrinter (NFC)
PiperOrigin-RevId: 253674584
2019-06-19 23:04:59 -07:00
Lei Zhang 980bf61b4b [spirv] Add spv.constant
This CL defines a single `spv.constant` op to represent various
flavors of SPIR-V constant instructions.

PiperOrigin-RevId: 253665716
2019-06-19 23:04:48 -07:00
Lei Zhang 1d4c040966 [spirv] Define common types using op definition spec
This CL also tightens spv.FMul to only accept 16/32/64-bit floats.

PiperOrigin-RevId: 253649352
2019-06-19 23:04:39 -07:00
Stephan Herhut cf74e41277 Verification for gpu.launch_func should rely on function type and not on the
actual body of a kernel function. This enables using gpu.launch_func with
external kernel declarations.

PiperOrigin-RevId: 253639770
2019-06-19 23:04:29 -07:00
Lei Zhang 31e2a6efe5 Also consider attributes when getting context for Operation
This CL also updates to use containing region as a fallback way to find
context since functions will eventually become ops with regions.

PiperOrigin-RevId: 253627322
2019-06-19 23:04:19 -07:00
Lei Zhang 2091ed5e30 [spirv] Add doc regarding the SPIR-V dialect
* Add basic design philosophy
* Add type syntax to both the doc and type parser comments

PiperOrigin-RevId: 253625782
2019-06-19 23:04:10 -07:00
Alex Zinenko f218519cc2 Introduce std.index_cast and its lowering+translation to LLVM
Index types integers of platform-specific bit width.  They are used to index
memrefs and as loop induction variables, however they could not be obtained
from an integer until now, making it virtually impossible to express indirect
accesses (given that memrefs of indices are not allowed) or data-dependent
loops.  Introduce `std.index_cast` to transform indices into integers and vice
versa.  The semantics of this cast is to sign-extend when casting to a wider
integer, and to truncate when casting to a narrower integer.  It belongs to
StandardOps because both types it operates on are standard types, and because
its results are likely to be used in std.load and std.store.

Introduce llvm.sext, llvm.zext and llvm.trunc operations to the LLVM dialect.
Provide the conversion of `std.index_cast` to llvm.sext or llvm.trunc,
depending on the actual bitwidth of `index` known during the conversion.

PiperOrigin-RevId: 253624100
2019-06-19 23:04:01 -07:00
Alex Zinenko 4291ae7431 Factor Region::getUsedValuesDefinedAbove into Transforms/RegionUtils
Arguably, this function is only useful for transformations and should not
pollute the main IR.  Also make sure it accepts a the resulting container
by-reference instead of returning it.

PiperOrigin-RevId: 253622981
2019-06-19 23:03:51 -07:00
Andy Davis 898cf0e968 LoopFusion: adds support for computing forward computation slices, which will enable fusion of consumer loop nests into their producers in subsequent CLs.
PiperOrigin-RevId: 253601994
2019-06-19 23:03:42 -07:00
Stephan Herhut a14eeacf2c Add lowering pass from GPU dialect operations to LLVM/NVVM intrinsics.
PiperOrigin-RevId: 253551452
2019-06-19 23:03:30 -07:00
Chris Lattner 05cf32162e Move the Region type out to its own .h/.cpp file instead of putting it into
Block.h/cpp.

This doesn't change much but makes it easier to find.

PiperOrigin-RevId: 253423041
2019-06-19 23:03:20 -07:00
River Riddle 06eb2fc06a Use braces when building an 'llvm_return' via EDSC intrinsics. This fixes a build error on MSVC where it is unable to properly handled template type aliases.
PiperOrigin-RevId: 253339204
2019-06-19 23:03:10 -07:00
Jing Pu 580a77fef5 Remove dead code.
PiperOrigin-RevId: 253314416
2019-06-19 23:03:00 -07:00
Alex Zinenko ebea5767fb Start moving conversions to {lib,include/mlir}/Conversion
Conversions from dialect A to dialect B depend on both A and B.  Therefore, it
is reasonable for them to live in a separate library that depends on both
DialectA and DialectB library, and does not forces dependees of DialectA or
DialectB to also link in the conversion.  Create the directory layout for the
conversions and move the Standard to LLVM dialect conversion as the first
example.

PiperOrigin-RevId: 253312252
2019-06-19 23:02:50 -07:00
River Riddle 3682936982 Disallow using NOperands/NResults when N < 2. We have special traits for the case of 0/1 that we explicitly check for throughout the codebase. This also fixes weird build failures in MSVC where it doesn't properly handle template type aliases.
PiperOrigin-RevId: 253269936
2019-06-19 23:02:40 -07:00