summaryrefslogtreecommitdiffstats
path: root/mlir/lib/Dialect/StandardOps/Ops.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [mlir] : Fix ViewOp shape folder for identity affine mapsAhmed Taei2020-01-151-2/+5
| | | | | | | | | | | | Summary: Fix the ViewOpShapeFolder in case of no affine mapping associated with a Memref construct identity mapping. Reviewers: nicolasvasilache Subscribers: mehdi_amini, rriddle, jpienaar, burmako, shauheen, antiagainst, arpith-jacob, mgester, lucyrfox, liufengdb, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D72735
* [mlir] NFC: Remove Value::operator* and Value::operator-> now that Value is ↵River Riddle2020-01-111-84/+82
| | | | | | | | | | properly value-typed. Summary: These were temporary methods used to simplify the transition. Reviewed By: antiagainst Differential Revision: https://reviews.llvm.org/D72548
* Canonicalize static alloc followed by memref_cast and std.viewAhmed Taei2020-01-081-1/+21
| | | | | | | | | | | | Summary: Rewrite alloc, memref_cast, std.view into allo, std.view by droping memref_cast. Reviewers: nicolasvasilache Subscribers: mehdi_amini, rriddle, jpienaar, burmako, shauheen, antiagainst, arpith-jacob, mgester, lucyrfox, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D72379
* [MLIR] [NFC] fix unused var warningUday Bondhugula2019-12-271-0/+1
| | | | | | | | | | | | | | | | | | | | | Summary: Fix this warning: ` [69/106] Building CXX object tools/mlir/lib/Dialect/StandardOps/CMakeFiles/MLIRStandardOps.dir/Ops.cpp.o /home/uday/llvm-project/mlir/lib/Dialect/StandardOps/Ops.cpp: In member function ‘virtual mlir::PatternMatchResult {anonymous}::ViewOpShapeFolder::matchAndRewrite(mlir::ViewOp, mlir::PatternRewriter&) const’: /home/uday/llvm-project/mlir/lib/Dialect/StandardOps/Ops.cpp:2575:14: warning: variable ‘dynamicOffsetOperandCount’ set but not used [-Wunused-but-set-variable] 2575 | unsigned dynamicOffsetOperandCount = 0; ` Reviewers: rriddle, mehdi_amini, ftynse Reviewed By: ftynse Subscribers: jpienaar, burmako, shauheen, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D71922
* Remove an unused static function.Eric Christopher2019-12-261-15/+0
|
* Fix a -Wcovered-switch-default warning by moving the unreachable out of theEric Christopher2019-12-261-2/+1
| | | | covered switch.
* NFC: Replace ValuePtr with Value and remove it now that Value is value-typed.River Riddle2019-12-231-31/+29
| | | | | | ValuePtr was a temporary typedef during the transition to a value-typed Value. PiperOrigin-RevId: 286945714
* Adjust License.txt file to use the LLVM licenseMehdi Amini2019-12-231-13/+4
| | | | PiperOrigin-RevId: 286906740
* NFC: Introduce new ValuePtr/ValueRef typedefs to simplify the transition to ↵River Riddle2019-12-221-33/+33
| | | | | | | | | | 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-10/+10
| | | | | | | | | | | | | | | | | | | 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
* Introduce prefetch op: affine -> std -> llvm intrinsicUday Bondhugula2019-12-181-0/+70
| | | | | | | | | | | | | | | | | | | 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-181-8/+7
| | | | | | | | in `mlir` namespace. Aside from being cleaner, this also makes the codebase more consistent. PiperOrigin-RevId: 286206974
* Refactor various canonicalization patterns as in-place folds.River Riddle2019-12-131-43/+33
| | | | | | This is more efficient, and allows for these to fire in more situations: e.g. createOrFold, DialectConversion, etc. PiperOrigin-RevId: 285476837
* Try to fold operations in DialectConversion when trying to legalize.River Riddle2019-12-131-0/+8
| | | | | | 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
* NFC: Cleanup the various Op::print methods.River Riddle2019-12-121-83/+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
* Refactor the various operand/result/type iterators to use ↵River Riddle2019-12-101-3/+3
| | | | | | | | | | | | | | indexed_accessor_range. This has several benefits: * The implementation is much cleaner and more efficient. * The ranges now have support for many useful operations: operator[], slice, drop_front, size, etc. * Value ranges can now directly query a range for their types via 'getTypes()': e.g: void foo(Operation::operand_range operands) { auto operandTypes = operands.getTypes(); } PiperOrigin-RevId: 284834912
* NFC: Expose constFoldBinaryOp via a headerLei Zhang2019-12-081-48/+1
| | | | | | | This allows other dialects to reuse the logic to support constant folding binary operations and reduces code duplication. PiperOrigin-RevId: 284428721
* Update the builder API to take ValueRange instead of ArrayRef<Value *>River Riddle2019-12-071-32/+21
| | | | | | This allows for users to provide operand_range and result_range in builder.create<> calls, instead of requiring an explicit copy into a separate data structure like SmallVector/std::vector. PiperOrigin-RevId: 284360710
* Add a new ValueRange class.River Riddle2019-12-061-1/+1
| | | | | | | | This class represents a generic abstraction over the different ways to represent a range of Values: ArrayRef<Value *>, operand_range, result_range. This class will allow for removing the many instances of explicit SmallVector<Value *, N> construction. It has the same memory cost as ArrayRef, and only suffers cost from indexing(if+elsing the different underlying representations). This change only updates a few of the existing usages, with more to be changed in followups; e.g. 'build' API. PiperOrigin-RevId: 284307996
* DimOp folding for alloc/view dynamic dimensionsUday Bondhugula2019-12-061-2/+17
| | | | | | | | | Signed-off-by: Uday Bondhugula <uday@polymagelabs.com> Closes tensorflow/mlir#253 COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/253 from bondhugula:dimop a4b464f24ae63fd259114558d87e11b8ee4dae86 PiperOrigin-RevId: 284169689
* Add UnrankedMemRef Typenmostafa2019-12-051-31/+55
| | | | | | | Closes tensorflow/mlir#261 COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/261 from nmostafa:nmostafa/unranked 96b6e918f6ed64496f7573b2db33c0b02658ca45 PiperOrigin-RevId: 284037040
* Add a pass to legalize operations before lowering to SPIR-V.Mahesh Ravishankar2019-12-031-0/+36
| | | | | | | | | | | | Not all StandardOps can be lowered to SPIR-V. For example, subview op implementation requires use of pointer bitcasts which is not valid according to SPIR-V spec (or at least is ambiguous about it). Such ops need to be removed/transformed before lowering to SPIR-V. The SPIRVLegalizationPass is added a place where such legalizations can be added. Current implementation folds the subview ops with load/stores so that the lowering itself does not have to convert a subview op. PiperOrigin-RevId: 283642981
* Fix ViewOp to have at most one offset operandAlex Zinenko2019-12-031-2/+8
| | | | | | | | | | | | | | | | | | | | | As described in the documentation, ViewOp is expected to take an optional dynamic offset followed by a list of dynamic sizes. However, the ViewOp parser did not include a check for the offset being a single value and accepeted a list of values instead. Furthermore, several tests have been exercising the wrong syntax of a ViewOp, passing multiple values to the dyanmic stride list, which was not caught by the parser. The trailing values could have been erronously interpreted as dynamic sizes. This is likely due to resyntaxing of the ViewOp, with the previous syntax taking the list of sizes before the offset. Update the tests to use the syntax with the offset preceding the sizes. Worse, the conversion of ViewOp to the LLVM dialect assumed the wrong order of operands with offset in the trailing position, and erronously relied on the permissive parsing that interpreted trailing dynamic offset values as leading dynamic sizes. Fix the lowering to use the correct order of operands. PiperOrigin-RevId: 283532506
* NFC: Update std.subview op to use AttrSizedOperandSegmentsLei Zhang2019-12-021-77/+46
| | | | | | This turns a few manually written helper methods into auto-generated ones. PiperOrigin-RevId: 283339617
* Make std.divis and std.diviu support ElementsAttr folding.Ben Vanik2019-11-251-24/+20
| | | | PiperOrigin-RevId: 282434465
* Allow memref_cast from static strides to dynamic strides.Mahesh Ravishankar2019-11-251-2/+22
| | | | | | | | Memref_cast supports cast from static shape to dynamic shape memrefs. The same should be true for strides as well, i.e a memref with static strides can be casted to a memref with dynamic strides. PiperOrigin-RevId: 282381862
* Support folding of StandardOps with DenseElementsAttr.Ben Vanik2019-11-241-14/+30
| | | | PiperOrigin-RevId: 282270243
* Add more canonicalizations for SubViewOp.Mahesh Ravishankar2019-11-221-92/+122
| | | | | | | | | | Depending on which of the offsets, sizes, or strides are constant, the subview op can be canonicalized in different ways. Add such canonicalizations, which generalize the existing approach of canonicalizing subview op only if all of offsets, sizes and shapes are constants. PiperOrigin-RevId: 282010703
* Verify subview op result has dynamic shape, when sizes are specified.Mahesh Ravishankar2019-11-201-0/+14
| | | | | | | If the sizes are specified as arguments to the subview op, then the shape must be dynamic as well. PiperOrigin-RevId: 281591608
* Changes to SubViewOp to make it more amenable to canonicalization.Mahesh Ravishankar2019-11-201-37/+118
| | | | | | | | | | | | | | The current SubViewOp specification allows for either all offsets, shape and stride to be dynamic or all of them to be static. There are opportunities for more fine-grained canonicalization based on which of these are static. For example, if the sizes are static, the result memref is of static shape. The specification of SubViewOp is modified to allow on or more of offsets, shapes and strides to be statically specified. The verification is updated to ensure that the result type of the subview op is consistent with which of these are static and which are dynamic. PiperOrigin-RevId: 281560457
* Add a new OpAsmOpInterface to allow for ops to directly hook into the ↵River Riddle2019-11-201-32/+26
| | | | | | | | | | | | | | | | | | | | | | | AsmPrinter. This interface provides more fine-grained hooks into the AsmPrinter than the dialect interface, allowing for operations to define the asm name to use for results directly on the operations themselves. The hook is also expanded to enable defining named result "groups". Get a special name to use when printing the results of this operation. The given callback is invoked with a specific result value that starts a result "pack", and the name to give this result pack. To signal that a result pack should use the default naming scheme, a None can be passed in instead of the name. For example, if you have an operation that has four results and you want to split these into three distinct groups you could do the following: setNameFn(getResult(0), "first_result"); setNameFn(getResult(1), "middle_results"); setNameFn(getResult(3), ""); // use the default numbering. This would print the operation as follows: %first_result, %middle_results:2, %0 = "my.op" ... PiperOrigin-RevId: 281546873
* Use SmallVectorImpl instead of SmallVector for function parameters (NFC)Tian Jin2019-11-181-1/+1
| | | | | | Closes tensorflow/mlir#247 PiperOrigin-RevId: 281185661
* Fix SubViewOp stride calculation in constant folding.Andy Davis2019-11-181-6/+8
| | | | | | Adds unit tests for subview offset and stride argument constant folding. PiperOrigin-RevId: 281161041
* Implement folding of pattern dim(subview(_)[...][s1, ..., sn][...], i) -> si.Stephan Herhut2019-11-181-1/+9
| | | | PiperOrigin-RevId: 281042016
* NFC: Convert CmpIPredicate in StandardOps to use EnumAttrLei Zhang2019-11-151-70/+19
| | | | | | This turns several hand-written functions to auto-generated ones. PiperOrigin-RevId: 280684326
* Adds canonicalizer to SubViewOp which folds constants from base memref and ↵Andy Davis2019-11-141-4/+161
| | | | | | | | operands into the subview result memref type. Changes SubViewOp to support zero operands case, when offset, strides and sizes are all constant. PiperOrigin-RevId: 280485075
* Deprecate linalg.subview in favor of std.subviewNicolas Vasilache2019-11-131-0/+54
| | | | | | | | | | | This CL uses the now standard std.subview in linalg. Two shortcuts are currently taken to allow this port: 1. the type resulting from a view is currently degraded to fully dynamic to pass the SubViewOp verifier. 2. indexing into SubViewOp may access out of bounds since lowering to LLVM does not currently enforce it by construction. These will be fixed in subsequent commits after discussions. PiperOrigin-RevId: 280250129
* Add support for alignment attribute in std.alloc.Nicolas Vasilache2019-11-121-2/+2
| | | | | | | | | | | | This CL adds an extra pointer to the memref descriptor to allow specifying alignment. In a previous implementation, we used 2 types: `linalg.buffer` and `view` where the buffer type was the unit of allocation/deallocation/alignment and `view` was the unit of indexing. After multiple discussions it was decided to use a single type, which conflates both, so the memref descriptor now needs to carry both pointers. This is consistent with the [RFC-Proposed Changes to MemRef and Tensor MLIR Types](https://groups.google.com/a/tensorflow.org/forum/#!searchin/mlir/std.view%7Csort:date/mlir/-wKHANzDNTg/4K6nUAp8AAAJ). PiperOrigin-RevId: 279959463
* Add support for nested symbol references.River Riddle2019-11-111-5/+5
| | | | | | | | | | | | | | | | | | This change allows for adding additional nested references to a SymbolRefAttr to allow for further resolving a symbol if that symbol also defines a SymbolTable. If a referenced symbol also defines a symbol table, a nested reference can be used to refer to a symbol within that table. Nested references are printed after the main reference in the following form: symbol-ref-attribute ::= symbol-ref-id (`::` symbol-ref-id)* Example: module @reference { func @nested_reference() } my_reference_op @reference::@nested_reference Given that SymbolRefAttr is now more general, the existing functionality centered around a single reference is moved to a derived class FlatSymbolRefAttr. Followup commits will add support to lookups, rauw, etc. for scoped references. PiperOrigin-RevId: 279860501
* Adds std.subview operation which takes dynamic offsets, sizes and strides ↵Andy Davis2019-11-111-15/+106
| | | | | | | | and returns a memref type which represents sub/reduced-size view of its memref argument. This operation is a companion operation to the std.view operation added as proposed in "Updates to the MLIR MemRefType" RFC. PiperOrigin-RevId: 279766410
* Swap operand order in std.view operation so that offset appears before ↵Andy Davis2019-11-071-30/+42
| | | | | | dynamic sizes in the operand list. PiperOrigin-RevId: 279114236
* Add canonicalizer for ViewOp which folds constants into the ViewOp memref ↵Andy Davis2019-11-071-0/+112
| | | | | | shape and layout map strides and offset. PiperOrigin-RevId: 279088023
* Update Linalg to use std.viewNicolas Vasilache2019-11-071-0/+1
| | | | | | Now that a view op has graduated to the std dialect, we can update Linalg to use it and remove ops that have become obsolete. As a byproduct, the linalg buffer and associated ops can also disappear. PiperOrigin-RevId: 279073591
* Adding an m_NonZero constant integer matcher.Ben Vanik2019-11-061-20/+13
| | | | | | This is useful for making matching cases where a non-zero value is required more readable, such as the results of a constant comparison that are expected to be equal. PiperOrigin-RevId: 278932874
* Add ViewOp verification for dynamic strides, and address some comments from ↵Andy Davis2019-11-061-12/+20
| | | | | | previous change. PiperOrigin-RevId: 278903187
* Add ViewOp to the StandardOps dialect, which casts a 1D/i8 element type ↵Andy Davis2019-11-061-0/+77
| | | | | | | | | | | memref type to an N-D memref type. Proposed in RFC: https://groups.google.com/a/tensorflow.org/forum/#!searchin/mlir/std.view%7Csort:date/mlir/-wKHANzDNTg/4K6nUAp8AAAJ Supports creating the N-D memref type with dynamic sizes and at a dynamic offset within the 1D base memref. This change contains op definition/parsing/printing and tests. Follow up changes will handle constant shape/layout map folding and llvm lowering. PiperOrigin-RevId: 278869990
* NFC: Rename parseOptionalAttributeDict -> parseOptionalAttrDict to match the ↵River Riddle2019-11-051-14/+14
| | | | | | name of the print method. PiperOrigin-RevId: 278696668
* Add a PatternRewriter hook to merge blocks, and use it to support for ↵River Riddle2019-11-051-0/+27
| | | | | | | | | | | | | | | | | | | folding branches. A pattern rewriter hook, mergeBlock, is added that allows for merging the operations of one block into the end of another. This is used to support a canonicalization pattern for branch operations that folds the branch when the successor has a single predecessor(the branch block). Example: ^bb0: %c0_i32 = constant 0 : i32 br ^bb1(%c0_i32 : i32) ^bb1(%x : i32): return %x : i32 becomes: ^bb0: %c0_i32 = constant 0 : i32 return %c0_i32 : i32 PiperOrigin-RevId: 278677825
* Wrap ODS to 80 lines and remove const qualifier for local `int` variable (NFC)Alexander Belyaev2019-10-231-3/+3
| | | | | | This addresses post-submit comments on 00d2a37e32 PiperOrigin-RevId: 276419770
* NFC: Remove trivial builder get methods.River Riddle2019-10-171-4/+4
| | | | | | These don't add any value, and some are even more restrictive than the respective static 'get' method. PiperOrigin-RevId: 275391240
OpenPOWER on IntegriCloud