summaryrefslogtreecommitdiffstats
path: root/mlir/lib/Dialect/VectorOps/VectorOps.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Make helper functions static or move them into anonymous namespaces. NFC.Benjamin Kramer2020-01-141-14/+19
|
* [mlir] [VectorOps] fixed typo in verifier of slice opAart Bik2020-01-131-1/+1
| | | | | | | | | | | | Reviewers: nicolasvasilache, andydavis1, rriddle Reviewed By: nicolasvasilache, rriddle Subscribers: merge_guards_bot, mehdi_amini, rriddle, jpienaar, burmako, shauheen, antiagainst, nicolasvasilache, arpith-jacob, mgester, lucyrfox, liufengdb, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D72664
* [mlir] NFC: Remove Value::operator* and Value::operator-> now that Value is ↵River Riddle2020-01-111-55/+54
| | | | | | | | | | properly value-typed. Summary: These were temporary methods used to simplify the transition. Reviewed By: antiagainst Differential Revision: https://reviews.llvm.org/D72548
* Sprinkle some constexpr on default ctors so the compiler can diagnose unused ↵Benjamin Kramer2020-01-101-1/+0
| | | | instances. NFCI.
* [mlir] Fix -Wrange-loo-analysis warningsFangrui Song2020-01-011-1/+1
| | | | | | | | | | | | for (const auto &x : llvm::zip(..., ...)) -> for (auto x : llvm::zip(..., ...)) The return type of zip() is a wrapper that wraps a tuple of references. > warning: loop variable 'p' is always a copy because the range of type 'detail::zippy<detail::zip_shortest, ArrayRef<long> &, ArrayRef<long> &>' does not return a reference [-Wrange-loop-analysis]
* NFC: Replace ValuePtr with Value and remove it now that Value is value-typed.River Riddle2019-12-231-13/+12
| | | | | | 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-15/+15
| | | | | | | | | | 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
* [VectorOps] unify vector dialect "subscripts"Aart Bik2019-12-201-15/+15
| | | | PiperOrigin-RevId: 286650682
* [VectorOps] Update vector transfer_read/write ops to operatate on memrefs ↵Andy Davis2019-12-191-34/+87
| | | | | | | | | 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
* [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-191-3/+12
| | | | | | | | 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
* [VectorOps] Add vector.print definition, with lowering supportAart Bik2019-12-181-0/+17
| | | | | | | | | | | | | | | | 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 pattern rewrite which splits a vector TransferWriteOp into slices ↵Andy Davis2019-12-171-1/+2
| | | | | | according to the unrolling/slicing scheme of its InsertSlicesOp operand. PiperOrigin-RevId: 286042578
* Update vector op unrolling transformation to generate ExtractSlicesOp and ↵Andy Davis2019-12-171-2/+2
| | | | | | InsertSlicesOp (instead of less structured chain of StridedSliceOps and InsertStridedSliceOps). PiperOrigin-RevId: 285968051
* Add InsertSlicesOp to the VectorOps dialect.Andy Davis2019-12-161-0/+54
| | | | PiperOrigin-RevId: 285830394
* [VectorOps] Add [insert/extract]element definition together with lowering to ↵Aart Bik2019-12-161-0/+74
| | | | | | | | | | | | | | 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
* Try to fold operations in DialectConversion when trying to legalize.River Riddle2019-12-131-1/+9
| | | | | | 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-40/+24
| | | | | | 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
* Add VectorOp transform pattern which splits vector TransferReadOps to target ↵Andy Davis2019-12-101-6/+10
| | | | | | vector unroll size. PiperOrigin-RevId: 284880592
* [VectorOps] Add a ShuffleOp to the VectorOps dialectAart Bik2019-12-091-0/+86
| | | | | | | | | | For example %0 = vector.shuffle %x, %y [3 : i32, 2 : i32, 1 : i32, 0 : i32] : vector<2xf32>, vector<2xf32> yields a vector<4xf32> result with a permutation of the elements of %x and %y PiperOrigin-RevId: 284657191
* [VectorOps] Fix off-by-one error in insert/extract validationAart Bik2019-12-091-2/+2
| | | | PiperOrigin-RevId: 284652653
* Factor out commonly reusable names across structured ops dialectsNicolas Vasilache2019-12-091-3/+5
| | | | | | This CL starts extracting commonalities between dialects that use the structured ops abstractions. Also fixes an OSS build issue where StringRef were incorrectly used with constexpr. PiperOrigin-RevId: 284591114
* [StructuredOps][Linalg] Add a primitive pattern to rewrite the ↵Nicolas Vasilache2019-12-091-2/+14
| | | | | | | | | | | linalg.generic form of matmul to vector form. This CL uses the newly expanded matcher support to easily detect when a linalg.generic has a multiply-accumulate body. A linalg.generic with such a body is rewritten as a vector contraction. This CL additionally limits the rewrite to the case of matrix multiplication on contiguous and statically shaped memrefs for now. Before expanding further, we should harden the infrastructure for expressing custom ops with the structured ops abstraction. PiperOrigin-RevId: 284566659
* [VecOps] Rename vector.[insert|extract]element to just vector.[insert|extract]Aart Bik2019-12-061-25/+19
| | | | | | | Since these operations lower to [insert|extract][element|value] at LLVM dialect level, neither element nor value would correctly reflect the meaning. PiperOrigin-RevId: 284240727
* [VectorOps] Add lowering of vector.broadcast to LLVM IRAart Bik2019-12-061-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For example, a scalar broadcast %0 = vector.broadcast %x : f32 to vector<2xf32> return %0 : vector<2xf32> which expands scalar x into vector [x,x] by lowering to the following LLVM IR dialect to implement the duplication over the leading dimension. %0 = llvm.mlir.undef : !llvm<"<2 x float>"> %1 = llvm.mlir.constant(0 : index) : !llvm.i64 %2 = llvm.insertelement %x, %0[%1 : !llvm.i64] : !llvm<"<2 x float>"> %3 = llvm.shufflevector %2, %0 [0 : i32, 0 : i32] : !llvm<"<2 x float>">, !llvm<"<2 x float>"> return %3 : vector<2xf32> In the trailing dimensions, the operand is simply "passed through", unless a more elaborate "stretch" is required. For example %0 = vector.broadcast %arg0 : vector<1xf32> to vector<4xf32> return %0 : vector<4xf32> becomes %0 = llvm.mlir.undef : !llvm<"<4 x float>"> %1 = llvm.mlir.constant(0 : index) : !llvm.i64 %2 = llvm.extractelement %arg0[%1 : !llvm.i64] : !llvm<"<1 x float>"> %3 = llvm.mlir.constant(0 : index) : !llvm.i64 %4 = llvm.insertelement %2, %0[%3 : !llvm.i64] : !llvm<"<4 x float>"> %5 = llvm.shufflevector %4, %0 [0 : i32, 0 : i32, 0 : i32, 0 : i32] : !llvm<"<4 x float>">, !llvm<"<4 x float>"> llvm.return %5 : !llvm<"<4 x float>"> PiperOrigin-RevId: 284219926
* Unroll vector masks along with their associated vector arguments.Andy Davis2019-12-061-43/+10
| | | | | | | | | Updates vector ContractionOp to use proper vector masks (produced by CreateMaskOp/ConstantMaskOp). Leverages the following canonicalizations in unrolling unit test: CreateMaskOp -> ConstantMaskOp, StridedSliceOp(ConstantMaskOp) -> ConstantMaskOp Removes IndexTupleOp (no longer needed now that we have vector mask ops). Updates all unit tests. PiperOrigin-RevId: 284182168
* Add canonicalization patterns for vector CreateMaskOp and StridedSliceOp to ↵Andy Davis2019-12-041-4/+158
| | | | | | | | | | | be used in the unroll vector op transformation. Adds a ConstantMaskOp to the vector ops dialect. Adds the following canonicalization patterns: CreateMaskOp -> ConstantMaskOp StridedSliceOp(ConstantMaskOp) -> ConstantMaskOp PiperOrigin-RevId: 283816752
* Adds support for unrolling single-result vector operations with iterator ↵Andy Davis2019-12-041-0/+38
| | | | | | | | type lists and indexing maps to a target vector size. Adds unit tests for unrolling the vector ContractionOp with different iteration orders. PiperOrigin-RevId: 283747503
* Add CreateMaskOp to the VectorOps dialect.Andy Davis2019-12-031-0/+31
| | | | PiperOrigin-RevId: 283591888
* [VectorOps] Add legality rules to broadcastAart Bik2019-12-021-3/+10
| | | | PiperOrigin-RevId: 283360101
* [VectorOps] Refine BroadcastOp in VectorOps dialectAart Bik2019-11-261-10/+8
| | | | | | | | Since second argument is always fully overwritten and shape is define in "to" clause, it is not needed. Also renamed "into" to "to" now that arg is dropped. PiperOrigin-RevId: 282686475
* [VectorOps] Add a BroadcastOp to the VectorOps dialectAart Bik2019-11-261-0/+41
| | | | PiperOrigin-RevId: 282643305
* Use vector.InsertStridedSlice in Vector -> Vector unrollingNicolas Vasilache2019-11-251-12/+9
| | | | | | | | This CL uses the recently added op to finish the implementation of Vector -> Vector unrolling by replacing the "fake join op" by a series of InsertStridedSliceOp. Test is updated accordingly PiperOrigin-RevId: 282451126
* Add a vector.InsertStridedSliceOpNicolas Vasilache2019-11-251-117/+211
| | | | | | This new op is the counterpart of vector.StridedSliceOp and will be used for in the pattern rewrites for vector unrolling. PiperOrigin-RevId: 282447414
* Update VectorContractionOp to take iterator types and index mapping ↵Andy Davis2019-11-251-17/+87
| | | | | | attributes compatible with linalg ops. PiperOrigin-RevId: 282412311
* Add vector.insertelement opNicolas Vasilache2019-11-251-1/+73
| | | | | | | | | This is the counterpart of vector.extractelement op and has the same limitations at the moment (static I64IntegerArrayAttr to express position). This restriction will be filterd in the future. LLVM lowering will be added in a subsequent commit. PiperOrigin-RevId: 282365760
* Unify vector op names with other dialects.Jean-Michel Gorius2019-11-221-66/+63
| | | | | | | | | | Change vector op names from VectorFooOp to Vector_FooOp and from vector::VectorFooOp to vector::FooOp. Closes tensorflow/mlir#257 COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/257 from Kayjukh:master dfc3a0e04114885aaec8740d5951d6984d6e1577 PiperOrigin-RevId: 281967461
* Add VectorContractionOp to the VectorOps dialect.Andy Davis2019-11-201-0/+209
| | | | PiperOrigin-RevId: 281605471
* Add VectorOps.StridedSliceOpNicolas Vasilache2019-11-191-2/+176
| | | | | | | | | | | | | | | | | | | | | The `vector.strided_slice` takes an n-D vector, k-D `offsets` integer array attribute, a k-D `sizes` integer array attribute, a k-D `strides` integer array attribute and extracts the n-D subvector at the proper offset. Returns an n-D vector where the first k-D dimensions match the `sizes` attribute. The returned subvector contains the elements starting at offset `offsets` and ending at `offsets + sizes`. Example: ``` %1 = vector.strided_slice %0 {offsets : [0, 2], sizes : [2, 4], strides : [1, 1]}: vector<4x8x16xf32> // returns a vector<2x4x16xf32> ``` This op will be useful for progressive lowering within the VectorOp dialect. PiperOrigin-RevId: 281352749
* Standardize all VectorOps class names to be prefixed by Vector - NFCNicolas Vasilache2019-11-181-17/+29
| | | | | | This improves consistency and will concretely avoid collisions between VectorExtractElementOp and ExtractElementOp when they are included in the same transforms / rewrites. PiperOrigin-RevId: 281101588
* Move VectorOps to Tablegen - (almost) NFCNicolas Vasilache2019-11-141-288/+97
| | | | | | | | | | | | | | | | This CL moves VectorOps to Tablegen and cleans up the implementation. This is almost NFC but 2 changes occur: 1. an interface change occurs in the padding value specification in vector_transfer_read: the value becomes non-optional. As a shortcut we currently use %f0 for all paddings. This should become an OpInterface for vectorization in the future. 2. the return type of vector.type_cast is trivial and simplified to `memref<vector<...>>` Relevant roundtrip and invalid tests that used to sit in core are moved to the vector dialect. The op documentation is moved to the .td file. PiperOrigin-RevId: 280430869
* NFC: Rename parseOptionalAttributeDict -> parseOptionalAttrDict to match the ↵River Riddle2019-11-051-4/+4
| | | | | | name of the print method. PiperOrigin-RevId: 278696668
* NFC: Remove trivial builder get methods.River Riddle2019-10-171-2/+2
| | | | | | These don't add any value, and some are even more restrictive than the respective static 'get' method. PiperOrigin-RevId: 275391240
* NFC: Pass OpAsmPrinter by reference instead of by pointer.River Riddle2019-09-201-35/+35
| | | | | | MLIR follows the LLVM style of pass-by-reference. PiperOrigin-RevId: 270401378
* NFC: Pass OperationState by reference instead of by pointer.River Riddle2019-09-201-39/+39
| | | | | | MLIR follows the LLVM convention of passing by reference instead of by pointer. PiperOrigin-RevId: 270396945
* NFC: Pass OpAsmParser by reference instead of by pointer.River Riddle2019-09-201-60/+59
| | | | | | MLIR follows the LLVM style of pass-by-reference. PiperOrigin-RevId: 270315612
* Move Linalg and VectorOps dialects to the Dialect subdir - NFCNicolas Vasilache2019-08-191-0/+555
PiperOrigin-RevId: 264277760
OpenPOWER on IntegriCloud