summaryrefslogtreecommitdiffstats
path: root/mlir/lib
Commit message (Collapse)AuthorAgeFilesLines
...
* NFC: Remove forbidden include of <iostream>River Riddle2019-12-181-2/+0
| | | | | See: https://llvm.org/docs/CodingStandards.html#include-iostream-is-forbidden PiperOrigin-RevId: 286226467
* Add support for providing a default implementation for an interface method.River Riddle2019-12-181-0/+6
| | | | | | | | | | | | | | | | | | | | This enables providing a default implementation of an interface method. This method is defined on the Trait that is attached to the operation, and thus has all of the same constraints and properties as any other interface method. This allows for interface authors to provide a conservative default implementation for certain methods, without requiring that all users explicitly define it. The default implementation can be specified via the argument directly after the interface method body: StaticInterfaceMethod< /*desc=*/"Returns whether two array of types are compatible result types for an op.", /*retTy=*/"bool", /*methodName=*/"isCompatibleReturnTypes", /*args=*/(ins "ArrayRef<Type>":$lhs, "ArrayRef<Type>":$rhs), /*methodBody=*/[{ return ConcreteOp::isCompatibleReturnTypes(lhs, rhs); }], /*defaultImplementation=*/[{ /// Returns whether two arrays are equal as strongest check for /// compatibility by default. return lhs == rhs; }] PiperOrigin-RevId: 286226054
* Update code block designationsJacques Pienaar2019-12-181-1/+1
| | | | | | | | | | | | | '```mlir' is used to indicate the code block is MLIR code/should use MLIR syntax highlighting, while '{.mlir}' was a markdown extension that used a style file to color the background differently of the code block. The background color extension was a custom one that we can retire given we have syntax highlighting. Also change '```td' to '```tablegen' to match chroma syntax highlighting designation. PiperOrigin-RevId: 286222976
* NFC: Cleanup non-conforming usages of namespaces.River Riddle2019-12-1813-111/+88
| | | | | | | * Fixes use of anonymous namespace for static methods. * Uses explicit qualifiers(mlir::) instead of wrapping the definition with the namespace. PiperOrigin-RevId: 286222654
* Introduce prefetch op: affine -> std -> llvm intrinsicUday Bondhugula2019-12-186-9/+263
| | | | | | | | | | | | | | | | | | | Introduce affine.prefetch: op to prefetch using a multi-dimensional subscript on a memref; similar to affine.load but has no effect on semantics, but only on performance. Provide lowering through std.prefetch, llvm.prefetch and map to llvm's prefetch instrinsic. All attributes reflected through the lowering - locality hint, rw, and instr/data cache. affine.prefetch %0[%i, %j + 5], false, 3, true : memref<400x400xi32> Signed-off-by: Uday Bondhugula <uday@polymagelabs.com> Closes tensorflow/mlir#225 COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/225 from bondhugula:prefetch 4c3b4e93bc64d9a5719504e6d6e1657818a2ead0 PiperOrigin-RevId: 286212997
* NFC: Remove unnecessary 'llvm::' prefix from uses of llvm symbols declared ↵River Riddle2019-12-1874-413/+379
| | | | | | | | in `mlir` namespace. Aside from being cleaner, this also makes the codebase more consistent. PiperOrigin-RevId: 286206974
* Move function template definition to the header file. NFCAlex Zinenko2019-12-181-11/+0
| | | | | | | | | The definition of the function template LLVM::ModuleTranslation::lookupValues has been located in a source file. As long as it has been the only file that actually called into the function, this did not cause any problem. However, it creates linking issues if the function is used from other translation units. PiperOrigin-RevId: 286203078
* Harden the requirements to memory attribution types in gpu.funcAlex Zinenko2019-12-182-2/+47
| | | | | | | | | | When memory attributions are present in `gpu.func`, require that they are of memref type and live in memoryspaces 3 and 5 for workgroup and private memory attributions, respectively. Adapt the conversion from the GPU dialect to the NVVM dialect to drop the private memory space from attributions as NVVM is able to model them as local `llvm.alloca`s in the default memory space. PiperOrigin-RevId: 286161763
* Add support for float and string attributes to the C API and python bindingsMLIR Team2019-12-171-0/+12
| | | | PiperOrigin-RevId: 286115042
* NFC: Use this-> to appease GCC bug related to template lambda.River Riddle2019-12-171-1/+2
| | | | | | | GCC is unable to properly implicitly capture 'this' in generic lambdas. This bug is not fixed until 7.1.0: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67274 PiperOrigin-RevId: 286083427
* NFC: Use TypeSwitch to simplify existing code.River Riddle2019-12-174-77/+47
| | | | PiperOrigin-RevId: 286066371
* Add pattern rewrite which splits a vector TransferWriteOp into slices ↵Andy Davis2019-12-172-30/+98
| | | | | | according to the unrolling/slicing scheme of its InsertSlicesOp operand. PiperOrigin-RevId: 286042578
* Add missing virtual inliner interface method in SPIR-V dialect.Mahesh Ravishankar2019-12-171-0/+11
| | | | | | | | | | | The inline interface uses two methods to check legality of inling: 1) Can a region be inlined into another. 2) Can an operation be inlined into another. Setting the former to true, allows the inliner to use the second for legality checks. Add this method to the SPIR-V dialect inlining interface. PiperOrigin-RevId: 286041734
* Make it possible to override the lowering of MemRef to the LLVM dialect. NFC.Alex Zinenko2019-12-171-12/+25
| | | | | | | | | | | | | The lowering of MemRef types to the LLVM dialect is connected to the underlying runtime representation of structured memory buffers. It has changed several times in the past and reached the current state of a LLVM structured-typed descriptor containing two pointers and all sizes. In several reported use cases, a different, often simpler, lowering scheme is required. For example, lowering statically-shaped memrefs to bare LLVM pointers to simplify aliasing annotation. Split the pattern population functions into those include memref-related operations and the remaining ones. Users are expected to extend TypeConverter::convertType to handle the memref types differently. PiperOrigin-RevId: 286030610
* StdToLLVM conversion: drop getMemRefElementType utility functionAlex Zinenko2019-12-171-12/+1
| | | | | | | | This function has become redundant with MemRefDescriptor::getElementType and is no longer necessary. Use the MemRefDescriptor pervasively to concentrate descriptor-related logic in one place and drop the utility function. PiperOrigin-RevId: 286024168
* Add pattern rewrite to forward vector tuple elements to their users.Andy Davis2019-12-171-1/+34
| | | | | | User(TupleGetOp(ExtractSlicesOp(InsertSlicesOp(TupleOp(Producer))) -> User(Producer) PiperOrigin-RevId: 286020249
* Integrate from upstream at revision e4fce659a759.MLIR Team2019-12-172-0/+2
| | | | PiperOrigin-RevId: 285982330
* Add pattern rewrite which splits a vector TransferReadOp into slices ↵Andy Davis2019-12-171-34/+44
| | | | | | according to the unrolling/slicing scheme of its ExtractSlicesOp user. PiperOrigin-RevId: 285975613
* Replace code with equivalent satisfiesLLVMModule() function call.Tres Popp2019-12-171-3/+1
| | | | | | This is a general code cleanup and should be a NFC. PiperOrigin-RevId: 285972718
* Update vector op unrolling transformation to generate ExtractSlicesOp and ↵Andy Davis2019-12-172-27/+92
| | | | | | InsertSlicesOp (instead of less structured chain of StridedSliceOps and InsertStridedSliceOps). PiperOrigin-RevId: 285968051
* Add atomic operations to SPIR-V dialect.Mahesh Ravishankar2019-12-163-3/+69
| | | | | | | Some changes to the dialect generation script to allow specification of different base class to derive from in ODS. PiperOrigin-RevId: 285859230
* Add edsc::ops for pointwise, conv and dilated_convNicolas Vasilache2019-12-161-17/+146
| | | | | | | | | This CL adds more Linalg EDSC ops and tests to support building pointwise operations along with conv and dilated_conv. This also fixes a bug in the existing linalg_matmul EDSC and beefs up the test. The current set of ops is already enough to build an interesting, albeit simple, model used internally. PiperOrigin-RevId: 285838012
* Add InsertSlicesOp to the VectorOps dialect.Andy Davis2019-12-161-0/+54
| | | | PiperOrigin-RevId: 285830394
* Plug gpu.func into the GPU lowering pipelinesAlex Zinenko2019-12-165-78/+160
| | | | | | | | | | | | | | This updates the lowering pipelines from the GPU dialect to lower-level dialects (NVVM, SPIRV) to use the recently introduced gpu.func operation instead of a standard function annotated with an attribute. In particular, the kernel outlining is updated to produce gpu.func instead of std.func and the individual conversions are updated to consume gpu.funcs and disallow standard funcs after legalization, if necessary. The attribute "gpu.kernel" is preserved in the generic syntax, but can also be used with the custom syntax on gpu.funcs. The special kind of function for GPU allows one to use additional features such as memory attribution. PiperOrigin-RevId: 285822272
* Insert signature-converted blocks into a region with a parent operation.River Riddle2019-12-162-27/+58
| | | | | | This keeps the IR valid and consistent as it is expected that each block should have a valid parent region/operation. Previously, converted blocks were kept floating without a valid parent region. PiperOrigin-RevId: 285821687
* Make "LowerToCFG" an operation passAlex Zinenko2019-12-161-5/+5
| | | | | | | | | The conversion from the Loops dialect to the Standard dialect, also known as loop-to-cfg lowering, has been historically a function pass. It can be required on non-Standard function Ops, in particular the recently introduced GPU functions. Make the conversion an operation pass instead of a function pass. PiperOrigin-RevId: 285814560
* [Linalg] Expose subview promotion as a declarative patternJose Ignacio Gomez2019-12-162-7/+26
| | | | | | | | | | | | This PR targest issue tensorflow/mlir#295. It exposes the already existing subiew promotion pass as a declarative pattern Change-Id: If901ebef9fb53fcd0b12ecc536f6b174ce320b92 Closes tensorflow/mlir#315 COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/315 from tetuante:issue295 8e5f268b6d85f31015c33505329dbd7a4db97ac5 PiperOrigin-RevId: 285801463
* [VectorOps] Add [insert/extract]element definition together with lowering to ↵Aart Bik2019-12-162-1/+126
| | | | | | | | | | | | | | LLVM Similar to insert/extract vector instructions but (1) work on 1-D vectors only (2) allow for a dynamic index %c3 = constant 3 : index %0 = vector.insertelement %arg0, %arg1[%c : index] : vector<4xf32> %1 = vector.extractelement %arg0[%c3 : index] : vector<4xf32> PiperOrigin-RevId: 285792205
* Adds ExtractSlicesOp to the VectorOps dialect.Andy Davis2019-12-161-6/+201
| | | | | | | ExtractSlicesOp extracts slices of its vector operand and with a specified tiling scheme. This operation centralizes the tiling scheme around a single op, which simplifies vector op unrolling and subsequent pattern rewrite transformations. PiperOrigin-RevId: 285761129
* Make memref promotion during std->LLVM lowering the default calling conventionAlex Zinenko2019-12-161-29/+17
| | | | | | | | | | | | | | | During the conversion from the standard dialect to the LLVM dialect, memref-typed arguments are promoted from registers to memory and passed into functions by pointer. This had been introduced into the lowering to work around the abesnce of calling convention modeling in MLIR to enable better interoperability with LLVM IR generated from C, and has been exerciced for several months. Make this promotion the default calling covention when converting to the LLVM dialect. This adds the documentation, simplifies the code and makes the conversion consistent across function operations and function types used in other places, e.g. in high-order functions or attributes, which would not follow the same rule previously. PiperOrigin-RevId: 285751280
* Remove LLVM dependency on mlir::Module and instead check Traits.Tres Popp2019-12-164-17/+30
| | | | PiperOrigin-RevId: 285724678
* Add verifyCompatibleShape function overload with shapesSmit Hinsu2019-12-141-11/+18
| | | | PiperOrigin-RevId: 285574334
* Apply a level of sugaring to the linalg.generic EDSC - NFCNicolas Vasilache2019-12-131-20/+75
| | | | | | Make the declarative C++ builder API simpler to use so we can start chaining these ops together. PiperOrigin-RevId: 285496266
* Refactor various canonicalization patterns as in-place folds.River Riddle2019-12-133-229/+169
| | | | | | This is more efficient, and allows for these to fire in more situations: e.g. createOrFold, DialectConversion, etc. PiperOrigin-RevId: 285476837
* Add a layer of EDSC for linalg.GenericOpNicolas Vasilache2019-12-136-7/+81
| | | | | | | | This will be evolved into a simple programming model for custom ops and custom layers in followup CLs. This CL also deletes the obsolete tablegen's reference-impl.td that was using EDSCs. PiperOrigin-RevId: 285459545
* Try to fold operations in DialectConversion when trying to legalize.River Riddle2019-12-135-21/+128
| | | | | | This change allows for DialectConversion to attempt folding as a mechanism to legalize illegal operations. This also expands folding support in OpBuilder::createOrFold to generate new constants when folding, and also enables it to work in the context of a PatternRewriter. PiperOrigin-RevId: 285448440
* Fix maskAndClamp in gpu.all_reduce.Christian Sigg2019-12-131-2/+5
| | | | | | The clamp value determines the returned predicate. Previously, the clamp value was fixed to 31 and the predicate was therefore always true. This is incorrect for partial warp reductions, but went unnoticed because the returned values happened to be zero (but it could be anything). PiperOrigin-RevId: 285343160
* NFC: Cleanup the various Op::print methods.River Riddle2019-12-129-279/+146
| | | | | | This cleans up the implementation of the various operation print methods. This is done via a combination of code cleanup, adding new streaming methods to the printer(e.g. operand ranges), etc. PiperOrigin-RevId: 285285181
* [VectorOps] Add lowering of vector.shuffle to LLVM IRAart Bik2019-12-121-55/+114
| | | | | | | | | | | | | | | | | | | | | | | | | | | For example, a shuffle %1 = vector.shuffle %arg0, %arg1 [0 : i32, 1 : i32] : vector<2xf32>, vector<2xf32> becomes a direct LLVM shuffle 0 = llvm.shufflevector %arg0, %arg1 [0 : i32, 1 : i32] : !llvm<"<2 x float>">, !llvm<"<2 x float>"> but %1 = vector.shuffle %a, %b[1 : i32, 0 : i32, 2: i32] : vector<1x4xf32>, vector<2x4xf32> becomes the more elaborate (note the index permutation that drives argument selection for the extract operations) %0 = llvm.mlir.undef : !llvm<"[3 x <4 x float>]"> %1 = llvm.extractvalue %arg1[0] : !llvm<"[2 x <4 x float>]"> %2 = llvm.insertvalue %1, %0[0] : !llvm<"[3 x <4 x float>]"> %3 = llvm.extractvalue %arg0[0] : !llvm<"[1 x <4 x float>]"> %4 = llvm.insertvalue %3, %2[1] : !llvm<"[3 x <4 x float>]"> %5 = llvm.extractvalue %arg1[1] : !llvm<"[2 x <4 x float>]"> %6 = llvm.insertvalue %5, %4[2] : !llvm<"[3 x <4 x float>]"> PiperOrigin-RevId: 285268164
* Retire !linalg.buffer type - NFCNicolas Vasilache2019-12-123-118/+5
| | | | | | This type is not used anymore now that Linalg view and subview have graduated to std and that alignment is supported on alloc. PiperOrigin-RevId: 285213424
* Added lowering of `std.tanh` to llvm function call to `tanh` and `tanhf`.Ehsan Toosi2019-12-121-0/+51
| | | | | | | Closes tensorflow/mlir#312 COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/312 from dfki-ehna:tanh 9e89b072ff91ff390ad739501745114feb3ac856 PiperOrigin-RevId: 285205674
* Automated rollback of commit f68ac464d818629e0fe10c23b44ac782d64a12d2Christian Sigg2019-12-123-9/+9
| | | | PiperOrigin-RevId: 285162061
* Switch from shfl.bfly to shfl.down.Christian Sigg2019-12-123-9/+9
| | | | | | | Both work for the current use case, but the latter allows implementing prefix sums and is a little easier to understand for partial warps. PiperOrigin-RevId: 285145287
* Make OpBuilder::insert virtual instead of OpBuilder::createOperation.River Riddle2019-12-113-29/+18
| | | | | | It is sometimes useful to create operations separately from the builder before insertion as it may be easier to erase them in isolation if necessary. One example use case for this is folding, as we will only want to insert newly generated constant operations on success. This has the added benefit of fixing some silent PatternRewriter failures related to cloning, as the OpBuilder 'clone' methods don't call createOperation. PiperOrigin-RevId: 285086242
* Add std.log* and llvm.intr.log* that correspond to the LLVMIR intrinsicsNicolas Vasilache2019-12-111-0/+12
| | | | PiperOrigin-RevId: 285073483
* Expose a convenience function to add interface attributes to a function.Mahesh Ravishankar2019-12-112-7/+14
| | | | PiperOrigin-RevId: 285036647
* [spirv] Add lowering for std.fdiv, std.frem, std.fsubDenis Khalikov2019-12-111-0/+3
| | | | | | | Closes tensorflow/mlir#313 COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/313 from denis0x0D:sandbox/lowering_std_farith 41715070a74d13bfa9401957478978c1bb8006c0 PiperOrigin-RevId: 285023586
* Continue refactoring StructuredOps utilitiesNicolas Vasilache2019-12-113-12/+39
| | | | | | | This CL adds more common information to StructuredOpsUtils.h The n_view attribute is retired in favor of args_in + args_out but the CL is otherwise NFC. PiperOrigin-RevId: 285000621
* NFC: Fix naming inconsistency: FuncOpLowering -> GPUFuncOpLowering.Christian Sigg2019-12-111-7/+3
| | | | | | Remove nested anonymous namespace. PiperOrigin-RevId: 284987357
* Roll-forward initial liveness analysis including test cases.Alexander Belyaev2019-12-112-0/+383
| | | | | | Fix the usage of the map size when appending to the map with []. PiperOrigin-RevId: 284985916
OpenPOWER on IntegriCloud