summaryrefslogtreecommitdiffstats
path: root/mlir/include
Commit message (Collapse)AuthorAgeFilesLines
...
* ReImplement the Value classes as value-typed objects wrapping an internal ↵River Riddle2019-12-2315-114/+321
| | | | | | | | pointer storage. This will enable future commits to reimplement the internal implementation of OpResult without needing to change all of the existing users. This is part of a chain of commits optimizing the size of operation results. PiperOrigin-RevId: 286919966
* Adjust License.txt file to use the LLVM licenseMehdi Amini2019-12-23220-2860/+880
| | | | PiperOrigin-RevId: 286906740
* NFC: Introduce new ValuePtr/ValueRef typedefs to simplify the transition to ↵River Riddle2019-12-2260-511/+558
| | | | | | | | | | Value being value-typed. This is an initial step to refactoring the representation of OpResult as proposed in: https://groups.google.com/a/tensorflow.org/g/mlir/c/XXzzKhqqF_0/m/v6bKb08WCgAJ This change will make it much simpler to incrementally transition all of the existing code to use value-typed semantics. PiperOrigin-RevId: 286844725
* Add integer bit-shift operations to the standard dialect.Manuel Freiberger2019-12-221-6/+43
| | | | | | | | | | | | | | | | | | | Rename the 'shlis' operation in the standard dialect to 'shift_left'. Add tests for this operation (these have been missing so far) and add a lowering to the 'shl' operation in the LLVM dialect. Add also 'shift_right_signed' (lowered to LLVM's 'ashr') and 'shift_right_unsigned' (lowered to 'lshr'). The original plan was to name these operations 'shift.left', 'shift.right.signed' and 'shift.right.unsigned'. This works if the operations are prefixed with 'std.' in MLIR assembly. Unfortunately during import the short form is ambigous with operations from a hypothetical 'shift' dialect. The best solution seems to omit dots in standard operations for now. Closes tensorflow/mlir#226 PiperOrigin-RevId: 286803388
* Make Type and Attribute classes trivially copyableAlex Zinenko2019-12-212-10/+4
| | | | | | | | | | This requires using explicitly default copy constructor and copy assignment operator instead of hand-rolled ones. These classes are indeed cheap to copy since they are wrappers around a pointer to the implementation. This change makes sure templated code can use standard type traits to understand that copying such objects is cheap and appeases analysis tools such as clang-tidy. PiperOrigin-RevId: 286725565
* NFC: Move the classes related to Pass options into a new header file ↵River Riddle2019-12-202-67/+98
| | | | | | | | PassOptions.h This will make refactoring and adding additional features to the pass options infrastructure simpler in followup commits. PiperOrigin-RevId: 286687564
* [VectorOps] unify vector dialect "subscripts"Aart Bik2019-12-203-15/+15
| | | | PiperOrigin-RevId: 286650682
* Add gpu.shuffle op.Christian Sigg2019-12-202-0/+36
| | | | | | | | This will allow us to lower most of gpu.all_reduce (when all_reduce doesn't exist in the target dialect) within the GPU dialect, and only do target-specific lowering for the shuffle op. PiperOrigin-RevId: 286548256
* Allow dialect to create friendly names for region argumentsFrank Laub2019-12-191-0/+5
| | | | | | | | | This is the block argument equivalent of the existing `getAsmResultNames` hook. Closes tensorflow/mlir#329 COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/329 from plaidml:flaub-region-arg-names fc7876f2d1335024e441083cd25263fd6247eb7d PiperOrigin-RevId: 286523299
* Unique trait list during ODS Operator trait constructionJacques Pienaar2019-12-191-0/+1
| | | | | | Concatting lists in TableGen is easy, creating unique lists less so. There is no reason for duplicated op traits so we could throw an error instead but duplicates could occur due to concatting different list of traits in ODS (e.g., for convenience reasons), so just dedup them during Operator trait construction instead. PiperOrigin-RevId: 286488423
* [VectorOps] Update vector transfer_read/write ops to operatate on memrefs ↵Andy Davis2019-12-191-9/+29
| | | | | | | | | with vector element type. Update vector transfer_read/write ops to operatate on memrefs with vector element type. This handle cases where the memref vector element type represents the minimal memory transfer unit (or multiple of the minimal memory transfer unit). PiperOrigin-RevId: 286482115
* Restructure and update Linalg ODS and documentation - NFCNicolas Vasilache2019-12-1914-21/+677
| | | | | | | | This CL allows specifying an additional name for specifying the .td file that is used to generate the doc for a dialect. This is necessary for a dialect like Linalg which has different "types" of ops that are used in different contexts. This CL also restructures the Linalg documentation and renames LinalgLibraryOps -> LinalgStructuredOps but is otherwise NFC. PiperOrigin-RevId: 286450414
* [VectorOps] Add vector ReshapeOp to the VectorOps dialect.Andy Davis2019-12-191-0/+117
| | | | | | Adds vector ReshapeOp to the VectorOps dialect. An aggregate vector reshape operation, which aggregates multiple hardware vectors, can enable optimizations during decomposition (e.g. loading one input hardware vector and performing multiple rotate and scatter store operations to the vector output). PiperOrigin-RevId: 286440658
* [VectorOps] minor cleanup: vector dialect "subscripts" are i32Aart Bik2019-12-192-2/+9
| | | | | | | | Introduces some centralized methods to move towards consistent use of i32 as vector subscripts. Note: sizes/strides/offsets attributes are still i64 PiperOrigin-RevId: 286434133
* Detemplatize ModuleTranslation::lookupValuesAlex Zinenko2019-12-191-10/+2
| | | | | | | | | This function template has been introduced in the early days of MLIR to work around the absence of common type for ranges of values (operands, block argumeents, vectors, etc). Core IR now provides ValueRange for exactly this purpose. Use it instead of the template parameter. PiperOrigin-RevId: 286431338
* Added LLVM ops and lowering phases from standard dialect for FAbs, FCeil, ↵Marcel Koester2019-12-181-28/+39
| | | | | | | | | | | Cos, FNeg, CopySign. Added test cases for the newly added LLVM operations and lowering features. Closes tensorflow/mlir#300 COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/300 from dfki-jugr:std_to_llvm da6168bbc1a369ae2e99ad3881fdddd82f075dd4 PiperOrigin-RevId: 286231169
* [VectorOps] Add vector.print definition, with lowering supportAart Bik2019-12-181-0/+32
| | | | | | | | | | | | | | | | Examples: vector.print %f : f32 vector.print %x : vector<4xf32> vector.print %y : vector<3x4xf32> vector.print %z : vector<2x3x4xf32> LLVM lowering replaces these with fully unrolled calls into a small runtime support library that provides some basic printing operations (single value, opening closing bracket, comma, newline). PiperOrigin-RevId: 286230325
* Add support for providing a default implementation for an interface method.River Riddle2019-12-183-8/+18
| | | | | | | | | | | | | | | | | | | | 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-183-8/+8
| | | | | | | | | | | | | '```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
* Introduce prefetch op: affine -> std -> llvm intrinsicUday Bondhugula2019-12-185-1/+146
| | | | | | | | | | | | | | | | | | | 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-1871-287/+271
| | | | | | | | 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-1/+9
| | | | | | | | | 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-181-1/+5
| | | | | | | | | | 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/+6
| | | | PiperOrigin-RevId: 286115042
* Add pattern rewrite which splits a vector TransferWriteOp into slices ↵Andy Davis2019-12-171-2/+2
| | | | | | according to the unrolling/slicing scheme of its InsertSlicesOp operand. PiperOrigin-RevId: 286042578
* Make it possible to override the lowering of MemRef to the LLVM dialect. NFC.Alex Zinenko2019-12-171-0/+11
| | | | | | | | | | | | | 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
* Add a new utility class TypeSwitch to ADT.River Riddle2019-12-172-0/+223
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This class provides a simplified mechanism for defining a switch over a set of types using llvm casting functionality. More specifically, this allows for defining a switch over a value of type T where each case corresponds to a type(CaseT) that can be used with dyn_cast<CaseT>(...). An example is shown below: // Traditional piece of code: Operation *op = ...; if (auto constant = dyn_cast<ConstantOp>(op)) ...; else if (auto return = dyn_cast<ReturnOp>(op)) ...; else ...; // New piece of code: Operation *op = ...; TypeSwitch<Operation *>(op) .Case<ConstantOp>([](ConstantOp constant) { ... }) .Case<ReturnOp>([](ReturnOp return) { ... }) .Default([](Operation *op) { ... }); Aside from the above, TypeSwitch supports return values, void return, multiple types per case, etc. The usability is intended to be very similar to StringSwitch. (Using c++14 template lambdas makes everything even nicer) More complex example of how this makes certain things easier: LogicalResult process(Constant op); LogicalResult process(ReturnOp op); LogicalResult process(FuncOp op); TypeSwitch<Operation *, LogicalResult>(op) .Case<ConstantOp, ReturnOp, FuncOp>([](auto op) { return process(op); }) .Default([](Operation *op) { return op->emitError() << "could not be processed"; }); PiperOrigin-RevId: 286003613
* Add atomic operations to SPIR-V dialect.Mahesh Ravishankar2019-12-162-8/+509
| | | | | | | 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-164-12/+186
| | | | | | | | | 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-1/+53
| | | | PiperOrigin-RevId: 285830394
* Plug gpu.func into the GPU lowering pipelinesAlex Zinenko2019-12-162-11/+16
| | | | | | | | | | | | | | 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-161-1/+5
| | | | | | 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-3/+2
| | | | | | | | | 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-163-0/+30
| | | | | | | | | | | | 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-161-0/+59
| | | | | | | | | | | | | | 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-0/+119
| | | | | | | 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
* Remove LLVM dependency on mlir::Module and instead check Traits.Tres Popp2019-12-164-17/+31
| | | | PiperOrigin-RevId: 285724678
* Splat op doc - fix misformat / update tablegen op desc. commentUday Bondhugula2019-12-141-1/+10
| | | | | | | | | | | | - bring op description comment in sync with the doc - fix misformat in doc Signed-off-by: Uday Bondhugula <uday@polymagelabs.com> Closes tensorflow/mlir#317 COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/317 from bondhugula:quickfix 7fcd945b318c973b2488b702874c87526855c8ef PiperOrigin-RevId: 285574527
* Add verifyCompatibleShape function overload with shapesSmit Hinsu2019-12-141-0/+6
| | | | PiperOrigin-RevId: 285574334
* Reconcile struct and class for NestedPatternMatchers - NFCNicolas Vasilache2019-12-131-8/+11
| | | | | | This removes a warning and fixes a potential ABI issue on Windows. PiperOrigin-RevId: 285502010
* Apply a level of sugaring to the linalg.generic EDSC - NFCNicolas Vasilache2019-12-131-5/+67
| | | | | | 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-135-14/+18
| | | | | | 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-5/+75
| | | | | | | | 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-134-6/+31
| | | | | | 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
* Add a type range for the XLA HLO dialect.Prakalp Srivastava2019-12-131-0/+1
| | | | PiperOrigin-RevId: 285437835
* NFC: Cleanup the various Op::print methods.River Riddle2019-12-122-2/+29
| | | | | | 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
* Retire !linalg.buffer type - NFCNicolas Vasilache2019-12-121-22/+1
| | | | | | 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
* Automated rollback of commit f68ac464d818629e0fe10c23b44ac782d64a12d2Christian Sigg2019-12-121-4/+4
| | | | PiperOrigin-RevId: 285162061
* Switch from shfl.bfly to shfl.down.Christian Sigg2019-12-121-4/+4
| | | | | | | 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-28/+15
| | | | | | 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
OpenPOWER on IntegriCloud