Lei Zhang [Wed, 27 Nov 2019 21:46:20 +0000 (13:46 -0800)]
[spirv] Add folders for spv.IAdd and spv.IMul
Adding zero and multiplying one can be common when generating code
for index calculation.
This CL also sorted canonicalize.mlir to alphabetical order.
PiperOrigin-RevId:
282828055
Aart Bik [Wed, 27 Nov 2019 19:58:08 +0000 (11:58 -0800)]
Fixed typo in Toy tutorial (second var e -> var f)
PiperOrigin-RevId:
282810649
Nicolas Vasilache [Wed, 27 Nov 2019 15:31:41 +0000 (07:31 -0800)]
Implement Linalg to loops lowering as a pattern
This CL rewrites the linalg ops to loops transformations as patterns that can be targeted directly from Tablegen. Reliance on OpFolder is removed and to cope with it we introduce local folding patterns that are applied greedily.
PiperOrigin-RevId:
282765550
Aart Bik [Wed, 27 Nov 2019 03:52:02 +0000 (19:52 -0800)]
[VectorOps] Refine BroadcastOp in VectorOps dialect
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
Jacques Pienaar [Tue, 26 Nov 2019 23:30:04 +0000 (15:30 -0800)]
Add create method that takes equivalent of OperationState with NamedAttributeList
This method is close to creating an OperationState first and then unpacking it
but avoids creating the OperationState and takes a NamedAttributeList for
attributes rather than array of NamedAttribute (to enable reusing an already
created NamedAttributeList).
Reuse this new method via create that takes OperationState. I'll update inferReturnTypes in follow up to also take NamedAttributeList and so a build method that uses both inferReturnTypes and create can reuse the same list.
PiperOrigin-RevId:
282651642
Aart Bik [Tue, 26 Nov 2019 22:43:03 +0000 (14:43 -0800)]
[VectorOps] Add a BroadcastOp to the VectorOps dialect
PiperOrigin-RevId:
282643305
David Truby [Tue, 26 Nov 2019 19:37:46 +0000 (11:37 -0800)]
Add OpenMP dialect to the dialect registry
Closes tensorflow/mlir#244
COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/244 from DavidTruby:openmp
30e2638ee678188575dd5aeb3f7fa51d93369f5f
PiperOrigin-RevId:
282607397
Mahesh Ravishankar [Tue, 26 Nov 2019 18:10:59 +0000 (10:10 -0800)]
Misc changes to lowering to SPIR-V.
These changes to SPIR-V lowering while adding support for lowering
SUbViewOp, but are not directly related.
- Change the lowering of MemRefType to
!spv.ptr<!spv.struct<!spv.array<...>[offset]>, ..>
This is consistent with the Vulkan spec.
- To enable testing a simple pattern of lowering functions is added to
ConvertStandardToSPIRVPass. This is just used to convert the type of
the arguments of the function. The added function lowering itself is
not meant to be the way functions are eventually lowered into SPIR-V
dialect.
PiperOrigin-RevId:
282589644
Nicolas Vasilache [Tue, 26 Nov 2019 16:47:14 +0000 (08:47 -0800)]
Automated rollback of commit
d60133f89bb08341718bb3132b19bc891f7d4f4d
PiperOrigin-RevId:
282574110
Nicolas Vasilache [Tue, 26 Nov 2019 15:38:33 +0000 (07:38 -0800)]
Relax restriction on affine_apply dim and symbol operands
The affine_apply operation is currently "doubly" affine and conflates two things:
1. it applies an affine map to a list of values of type `index` that are defined as either dim or symbol
2. it restricts (and propagates constraints on) the provenance of dims and symbols to a small subset of ops for which more restrictive polyhedral constraints apply.
Point 2. is related to the ability to form so-called static control parts and is related to dependence analysis and legality of transformations.
Point 1. however is completely independent, the only local implication of dims and symbol for affine_apply is that dims compose while symbols concatenate as well as the structural constraint that dims may not be multiplied.
The properties of composition and canonicalization in affine_apply are more generally useful. This CL relaxes the verifier on affine_apply so it can be used more generally.
The relevant affine.for/if/load/store op verifiers already implement the dim and symbol checking.
See this thread for the related discussion: https://groups.google.com/a/tensorflow.org/g/mlir/c/HkwCbV8D9N0/m/8srUNrX6CAAJ
PiperOrigin-RevId:
282562517
Andrew Anderson [Tue, 26 Nov 2019 01:53:20 +0000 (17:53 -0800)]
Some minor corrections and improvements to LangRef
Some productions in the LangRef were using undefined terminals and non-terminals, which have been added to the EBNF.
The dialect type and dialect attribute productions matched precisely the same structure and have been deduplicated.
The production for ssa-id was ambiguous but the fix is trivial (merging the leading '%') and has been applied.
Closes tensorflow/mlir#265
PiperOrigin-RevId:
282470892
Lei Zhang [Tue, 26 Nov 2019 01:26:16 +0000 (17:26 -0800)]
Add support for AttrSizedOperandSegments/AttrSizedResultSegments
Certain operations can have multiple variadic operands and their size
relationship is not always known statically. For such cases, we need
a per-op-instance specification to divide the operands into logical
groups or segments. This can be modeled by attributes.
This CL introduces C++ trait AttrSizedOperandSegments for operands and
AttrSizedResultSegments for results. The C++ trait just guarantees
such size attribute has the correct type (1D vector) and values
(non-negative), etc. It serves as the basis for ODS sugaring that
with ODS argument declarations we can further verify the number of
elements match the number of ODS-declared operands and we can generate
handy getter methods.
PiperOrigin-RevId:
282467075
Nicolas Vasilache [Mon, 25 Nov 2019 23:56:06 +0000 (15:56 -0800)]
Use vector.InsertStridedSlice in Vector -> Vector unrolling
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
Nicolas Vasilache [Mon, 25 Nov 2019 23:36:45 +0000 (15:36 -0800)]
Add a vector.InsertStridedSliceOp
This new op is the counterpart of vector.StridedSliceOp and will be used for in the pattern rewrites for vector unrolling.
PiperOrigin-RevId:
282447414
MLIR Team [Mon, 25 Nov 2019 22:44:20 +0000 (14:44 -0800)]
Allow LLVM::ExtractElementOp to have non-i32 indices.
Also change the text format a bit, so that indices are braced by squares.
PiperOrigin-RevId:
282437095
Ben Vanik [Mon, 25 Nov 2019 22:31:12 +0000 (14:31 -0800)]
Make std.divis and std.diviu support ElementsAttr folding.
PiperOrigin-RevId:
282434465
Mahesh Ravishankar [Mon, 25 Nov 2019 21:19:19 +0000 (13:19 -0800)]
NFC: Actually expose the implementation of createGPUToSPIRVLoweringPass.
A mismatch in the function declaration and function definition,
prevented the implementation of the createGPUToSPIRVLoweringPass from
being exposed.
PiperOrigin-RevId:
282419815
Mahesh Ravishankar [Mon, 25 Nov 2019 20:56:46 +0000 (12:56 -0800)]
Add missing rule to generate SPIR-V ABI Attribute using tblgen to CMake.
PiperOrigin-RevId:
282415592
Andy Davis [Mon, 25 Nov 2019 20:39:30 +0000 (12:39 -0800)]
Update VectorContractionOp to take iterator types and index mapping attributes compatible with linalg ops.
PiperOrigin-RevId:
282412311
Christian Sigg [Mon, 25 Nov 2019 20:30:22 +0000 (12:30 -0800)]
Changing directory shortcut for CPU/GPU runner utils.
Moving cuda-runtime-wrappers.so into subdirectory to match libmlir_runner_utils.so.
Provide parent directory when running test and load .so from subdirectory.
PiperOrigin-RevId:
282410749
Lei Zhang [Mon, 25 Nov 2019 19:29:21 +0000 (11:29 -0800)]
De-duplicate EnumAttr overrides by defining defaults
EnumAttr should provide meaningful defaults so concrete instances
do not need to duplicate the fields.
PiperOrigin-RevId:
282398431
Mahesh Ravishankar [Mon, 25 Nov 2019 18:38:31 +0000 (10:38 -0800)]
Introduce attributes that specify the final ABI for a spirv::ModuleOp.
To simplify the lowering into SPIR-V, while still respecting the ABI
requirements of SPIR-V/Vulkan, split the process into two
1) While lowering a function to SPIR-V (when the function is an entry
point function), allow specifying attributes on arguments and
function itself that describe the ABI of the function.
2) Add a pass that materializes the ABI described in the function.
Two attributes are needed.
1) Attribute on arguments of the entry point function that describe
the descriptor_set, binding, storage class, etc, of the
spv.globalVariable this argument will be replaced by
2) Attribute on function that specifies workgroup size, etc. (for now
only workgroup size).
Add the pass -spirv-lower-abi-attrs to materialize the ABI described
by the attributes.
This change makes the SPIRVBasicTypeConverter class unnecessary and is
removed, further simplifying the SPIR-V lowering path.
PiperOrigin-RevId:
282387587
Mahesh Ravishankar [Mon, 25 Nov 2019 18:10:58 +0000 (10:10 -0800)]
Allow memref_cast from static strides to dynamic strides.
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
Nicolas Vasilache [Mon, 25 Nov 2019 16:46:37 +0000 (08:46 -0800)]
Add vector.insertelement op
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
Alex Zinenko [Mon, 25 Nov 2019 15:59:52 +0000 (07:59 -0800)]
Introduce gpu.func
Introduce a new function-like operation to the GPU dialect to provide a
placeholder for the execution semantic description and to add support for GPU
memory hierarchy. This aligns with the overall goal of the dialect to expose
the common abstraction layer for GPU devices, in particular by providing an
MLIR unit of semantics (i.e. an operation) for memory modeling.
This proposal has been discussed in the mailing list:
https://groups.google.com/a/tensorflow.org/d/msg/mlir/RfXNP7Hklsc/MBNN7KhjAgAJ
As decided, the "convergence" aspect of the execution model will be factored
out into a new discussion and therefore is not included in this commit. This
commit only introduces the operation but does not hook it up with the remaining
flow. The intention is to develop the new flow while keeping the old flow
operational and do the switch in a simple, separately reversible commit.
PiperOrigin-RevId:
282357599
Ben Vanik [Mon, 25 Nov 2019 02:50:54 +0000 (18:50 -0800)]
Support folding of StandardOps with DenseElementsAttr.
PiperOrigin-RevId:
282270243
Lei Zhang [Sat, 23 Nov 2019 14:08:50 +0000 (06:08 -0800)]
NFC: Wire up DRR settings for SPIR-V canonicalization patterns
This CL added necessary files and settings for using DRR to
write SPIR-V canonicalization patterns and also converted the
patterns for spv.Bitcast and spv.LogicalNot.
PiperOrigin-RevId:
282132786
Lei Zhang [Sat, 23 Nov 2019 14:03:40 +0000 (06:03 -0800)]
[spirv] NFC: rename test files and sort tests inside
PiperOrigin-RevId:
282132339
Uday Bondhugula [Sat, 23 Nov 2019 05:47:47 +0000 (21:47 -0800)]
Make isValidSymbol more powerful
The check in isValidSymbol, as far as a DimOp result went, checked if
the dim op was on a top-level memref. However, any alloc'ed, view, or
subview memref would be fine as long as the corresponding dimension of
that memref is either a static one or was in turn created using a valid
symbol in the case of dynamic dimensions.
Reported-by: Jose Gomez
Signed-off-by: Uday Bondhugula <uday@polymagelabs.com>
Closes tensorflow/mlir#252
COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/252 from bondhugula:symbol
7b57dc394df9375e651f497231c6e4525a32a662
PiperOrigin-RevId:
282097114
River Riddle [Sat, 23 Nov 2019 01:51:23 +0000 (17:51 -0800)]
NFC: Remove unnecessarily guarded tablegen includes.
Support for including a file multiple times was added in tablegen, removing the need for these extra guards. This is because we already insert c/c++ style header guards within each of the specific .td files.
PiperOrigin-RevId:
282076728
Nicolas Vasilache [Fri, 22 Nov 2019 22:56:36 +0000 (14:56 -0800)]
Fix Windows Build
PiperOrigin-RevId:
282048102
Denis Khalikov [Fri, 22 Nov 2019 19:49:22 +0000 (11:49 -0800)]
[spirv] Add a canonicalizer for `spirv::LogicalNotOp`.
Add a canonicalizer for `spirv::LogicalNotOp`.
Converts:
* spv.LogicalNot(spv.IEqual(...)) -> spv.INotEqual(...)
* spv.LogicalNot(spv.INotEqual(...)) -> spv.IEqual(...)
* spv.LogicalNot(spv.LogicalEqual(...)) -> spv.LogicalNotEqual(...)
* spv.LogicalNot(spv.LogicalNotEqual(...)) -> spv.LogicalEqual(...)
Also moved the test for spv.IMul to arithemtic tests.
Closes tensorflow/mlir#256
COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/256 from denis0x0D:sandbox/canon_logical_not
76ab5787b2c777f948c8978db061d99e76453d44
PiperOrigin-RevId:
282012356
Mahesh Ravishankar [Fri, 22 Nov 2019 19:41:29 +0000 (11:41 -0800)]
Add more canonicalizations for SubViewOp.
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
Lucy Fox [Fri, 22 Nov 2019 18:42:57 +0000 (10:42 -0800)]
Small formatting fix in Tutorial Ch2.
PiperOrigin-RevId:
281998069
Jean-Michel Gorius [Fri, 22 Nov 2019 15:52:02 +0000 (07:52 -0800)]
Unify vector op names with other dialects.
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
Lucy Fox [Fri, 22 Nov 2019 01:15:24 +0000 (17:15 -0800)]
Add more detail about locations in Chapter 2 of tutorial.
Resolves issue 241 (tensorflow/mlir#241).
PiperOrigin-RevId:
281867192
Nicolas Vasilache [Thu, 21 Nov 2019 23:19:52 +0000 (15:19 -0800)]
Move Linalg Transforms that are actually Conversions - NFC
PiperOrigin-RevId:
281844602
River Riddle [Thu, 21 Nov 2019 22:34:03 +0000 (14:34 -0800)]
Add support for using the ODS result names as the Asm result names for multi-result operations.
This changes changes the OpDefinitionsGen to automatically add the OpAsmOpInterface for operations with multiple result groups using the provided ODS names. We currently just limit the generation to multi-result ops as most single result operations don't have an interesting name(result/output/etc.). An example is shown below:
// The following operation:
def MyOp : ... {
let results = (outs AnyType:$first, Variadic<AnyType>:$middle, AnyType);
}
// May now be printed as:
%first, %middle:2, %0 = "my.op" ...
PiperOrigin-RevId:
281834156
Christian Sigg [Thu, 21 Nov 2019 19:16:02 +0000 (11:16 -0800)]
Change CUDA tests to use print_memref.
Swap dimensions in all-reduce-op test.
PiperOrigin-RevId:
281791744
River Riddle [Thu, 21 Nov 2019 17:57:43 +0000 (09:57 -0800)]
NFC: Add wrappers around DenseIntElementsAttr/DenseFPElementsAttr::get to avoid the need to cast.
This avoids the need to cast back to the derived type when calling get, i.e. removes the need to do DenseIntElementsAttr::get(...).cast<DenseIntElementsAttr>().
PiperOrigin-RevId:
281772163
Nicolas Vasilache [Thu, 21 Nov 2019 16:46:14 +0000 (08:46 -0800)]
Fix OSS builds - NFC
PiperOrigin-RevId:
281757979
Nicolas Vasilache [Thu, 21 Nov 2019 15:08:41 +0000 (07:08 -0800)]
Drop unused function - NFC
PiperOrigin-RevId:
281741923
Nicolas Vasilache [Thu, 21 Nov 2019 14:29:41 +0000 (06:29 -0800)]
Split Linalg declarative patterns from specific test patterns - NFC
This will make it easier to scale out test patterns and build specific passes that do not interfere with independent testing.
PiperOrigin-RevId:
281736335
Benjamin Kramer [Thu, 21 Nov 2019 14:01:35 +0000 (06:01 -0800)]
Add missing include after LLVM
049043b598ef5b12a5894c0c22db8608be70f517
PiperOrigin-RevId:
281732683
Alex Zinenko [Thu, 21 Nov 2019 12:24:52 +0000 (04:24 -0800)]
Don't force newline before function attributes
Due to legacy reasons, a newline character followed by two spaces was always
inserted before the attributes of the function Op in pretty form. This breaks
formatting when functions are nested in some other operations. Don't print the
newline and just put the attributes on the same line, which is also more
consistent with module Op. Line breaking aware of indentation can be introduced
separately into the parser if deemed useful.
PiperOrigin-RevId:
281721793
Nicolas Vasilache [Thu, 21 Nov 2019 12:24:13 +0000 (04:24 -0800)]
Fix OSS build
Add include of ADT/SmallVector.h.
Fixes tensorflow/mlir#254.
PiperOrigin-RevId:
281721705
Aart Bik [Thu, 21 Nov 2019 05:22:13 +0000 (21:22 -0800)]
Fixed typo in 2-d tiled layout
PiperOrigin-RevId:
281671097
River Riddle [Thu, 21 Nov 2019 03:20:04 +0000 (19:20 -0800)]
NFC: Use Region::getBlocks to fix build failure with drop_begin.
PiperOrigin-RevId:
281656603
River Riddle [Thu, 21 Nov 2019 02:19:38 +0000 (18:19 -0800)]
Add a document detailing operation traits, how to define them, and the current list.
Traits are an important piece of operation definition, but don't really have a good documentation presence at the moment.
PiperOrigin-RevId:
281649025
MLIR Team [Thu, 21 Nov 2019 00:30:14 +0000 (16:30 -0800)]
Correctly parse empty affine maps.
Previously the test case crashes / produces an error.
PiperOrigin-RevId:
281630540
River Riddle [Wed, 20 Nov 2019 23:23:52 +0000 (15:23 -0800)]
Merge DCE and unreachable block elimination into a new utility 'simplifyRegions'.
This moves the different canonicalizations of regions into one place and invokes them in the fixed-point iteration of the canonicalizer.
PiperOrigin-RevId:
281617072
Andy Davis [Wed, 20 Nov 2019 22:43:15 +0000 (14:43 -0800)]
Add VectorContractionOp to the VectorOps dialect.
PiperOrigin-RevId:
281605471
Mahesh Ravishankar [Wed, 20 Nov 2019 21:43:20 +0000 (13:43 -0800)]
Verify subview op result has dynamic shape, when sizes are specified.
If the sizes are specified as arguments to the subview op, then the
shape must be dynamic as well.
PiperOrigin-RevId:
281591608
MLIR Team [Wed, 20 Nov 2019 20:46:54 +0000 (12:46 -0800)]
missing outer index %i in search_body
PiperOrigin-RevId:
281580028
Sean Silva [Wed, 20 Nov 2019 19:48:57 +0000 (11:48 -0800)]
Add multi-level DCE pass.
This is a simple multi-level DCE pass that operates pretty generically on
the IR. Its key feature compared to the existing peephole dead op folding
that happens during canonicalization is being able to delete recursively
dead cycles of the use-def graph, including block arguments.
PiperOrigin-RevId:
281568202
Mahesh Ravishankar [Wed, 20 Nov 2019 19:16:37 +0000 (11:16 -0800)]
Changes to SubViewOp to make it more amenable to canonicalization.
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
Nicolas Vasilache [Wed, 20 Nov 2019 18:54:45 +0000 (10:54 -0800)]
Implement unrolling of vector ops to finer-grained vector ops as a pattern.
This CL uses the pattern rewrite infrastructure to implement a simple VectorOps -> VectorOps legalization strategy to unroll coarse-grained vector operations into finer grained ones.
The transformation is written using local pattern rewrites to allow composition with other rewrites. It proceeds by iteratively introducing fake cast ops and cleaning canonicalizing or lowering them away where appropriate.
This is an example of writing transformations as compositions of local pattern rewrites that should enable us to make them significantly more declarative.
PiperOrigin-RevId:
281555100
River Riddle [Wed, 20 Nov 2019 18:19:01 +0000 (10:19 -0800)]
Add a new OpAsmOpInterface to allow for ops to directly hook into the 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
Nicolas Vasilache [Wed, 20 Nov 2019 18:06:35 +0000 (10:06 -0800)]
Add StridedMemRef<>::operator[] - NFC
This operator is used for internal debugging purposes.
PiperOrigin-RevId:
281544152
Alexander Belyaev [Wed, 20 Nov 2019 14:20:08 +0000 (06:20 -0800)]
Fix the comment to Region block iterators.
PiperOrigin-RevId:
281506693
Alexander Belyaev [Wed, 20 Nov 2019 13:37:49 +0000 (05:37 -0800)]
Fix 'the the' typo.
PiperOrigin-RevId:
281501234
Stephan Herhut [Wed, 20 Nov 2019 10:59:02 +0000 (02:59 -0800)]
Extend kernel outlining to also consider dim worth inlining.
PiperOrigin-RevId:
281483447
Eric Schweitz [Wed, 20 Nov 2019 05:04:45 +0000 (21:04 -0800)]
Add some CMake rules for installing headers, mlir-tblgen, and mlir-opt
Closes tensorflow/mlir#246
PiperOrigin-RevId:
281442685
Christian Sigg [Tue, 19 Nov 2019 21:12:19 +0000 (13:12 -0800)]
Make type and rank explicit in mcuMemHostRegister function.
Fix registered size of indirect MemRefType kernel arguments.
PiperOrigin-RevId:
281362940
Nicolas Vasilache [Tue, 19 Nov 2019 20:22:00 +0000 (12:22 -0800)]
Add VectorOps.StridedSliceOp
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
Nicolas Vasilache [Tue, 19 Nov 2019 19:51:53 +0000 (11:51 -0800)]
Fix pretty printer corner case in mlir_runner_utils.cpp.
In the particular case where the size of a memref dimension is 1, double printing would happen because printLast was called unconditionally.
This CL fixes the print and updates an incorrect test that should have caught this in the first place.
PiperOrigin-RevId:
281345142
Mehdi Amini [Tue, 19 Nov 2019 19:26:45 +0000 (11:26 -0800)]
Add a note on commit messages to our developer guide
PiperOrigin-RevId:
281338738
Mehdi Amini [Tue, 19 Nov 2019 19:25:37 +0000 (11:25 -0800)]
Add mention to avoid cl::opt for MLIR passes in the developer guide
PiperOrigin-RevId:
281338448
Diego Caballero [Tue, 19 Nov 2019 18:15:36 +0000 (10:15 -0800)]
Add getRemappedValue to ConversionPatternRewriter
This method is needed for N->1 conversion patterns to retrieve remapped
Values used in the original N operations.
Closes tensorflow/mlir#237
COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/237 from dcaballe:dcaballe/getRemappedValue
1f64fadcf2b203f7b336ff0c5838b116ae3625db
PiperOrigin-RevId:
281321881
Eric Schweitz [Tue, 19 Nov 2019 18:13:33 +0000 (10:13 -0800)]
Add '*' and '?' and optional brace parse calls to the Parser
Closes tensorflow/mlir#245
PiperOrigin-RevId:
281321459
Alex Zinenko [Tue, 19 Nov 2019 08:34:20 +0000 (00:34 -0800)]
Change conversion CLI flag from -lower-to-llvm to -convert-std-to-llvm
The command-line flag name `lower-to-llvm` for the pass performing dialect
conversion from the Standard dialect to the LLVM dialect is misleading and
inconsistent with most of the conversion passses. It leads the user to believe
that there are no restrictions on what can be converted, while in fact only a
subset of the Standard dialect can be converted (with operations from other
dialects converted by separate passes). Use `convert-std-to-llvm` that better
reflects what the pass does and is consistent with most other conversions.
PiperOrigin-RevId:
281238797
Logan Chien [Tue, 19 Nov 2019 06:49:49 +0000 (22:49 -0800)]
Add dialect-attribute-entry requirement to docs
This commit add `dialect-attribute-entry` requirements on function arguments,
function results, and function attributes to the documentation.
PiperOrigin-RevId:
281227740
Manuel Freiberger [Tue, 19 Nov 2019 05:51:48 +0000 (21:51 -0800)]
Fix the shape of the outcome in the example code.
The toy language uses element-wise multiplication. Transposing and multiplying
two tensors with shape <2, 3> gives a tensor with shape <3, 2>.
Closes tensorflow/mlir#227
COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/227 from ombre5733:toy-ch1-docu-fix
d79e5d3f9e3d5150a7ac8aac28b899df5a0d10a0
PiperOrigin-RevId:
281221671
Hanhan Wang [Tue, 19 Nov 2019 04:01:28 +0000 (20:01 -0800)]
Support SPIR-V constant op to take DenseElementsAttr as input.
Iterates each element to build the array. This includes a little refactor to
combine bool/int/float into a function, since they are similar. The only
difference is calling different function in the end.
PiperOrigin-RevId:
281210288
Tian Jin [Tue, 19 Nov 2019 00:58:32 +0000 (16:58 -0800)]
Use SmallVectorImpl instead of SmallVector for function parameters (NFC)
Closes tensorflow/mlir#247
PiperOrigin-RevId:
281185661
Alexander Belyaev [Mon, 18 Nov 2019 23:39:56 +0000 (15:39 -0800)]
Lower linalg.indexed_generic to loops.
PiperOrigin-RevId:
281169885
Uday Bondhugula [Mon, 18 Nov 2019 23:30:57 +0000 (15:30 -0800)]
Drop unnecessary dependences from mlir-translate
Closes tensorflow/mlir#243
COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/243 from bondhugula:patch-2
fb682996efde001189414a4c7aa59ce42ace7831
PiperOrigin-RevId:
281167834
Andy Davis [Mon, 18 Nov 2019 23:00:34 +0000 (15:00 -0800)]
Fix SubViewOp stride calculation in constant folding.
Adds unit tests for subview offset and stride argument constant folding.
PiperOrigin-RevId:
281161041
River Riddle [Mon, 18 Nov 2019 21:11:00 +0000 (13:11 -0800)]
Add a parseAttribute<AttrType> overload for the non-type case.
The variant that accepts a type will check that the parsed attribute is a valid instance of AttrType. The non-type variant would silently fail in this case, leading to garbage attribute values.
PiperOrigin-RevId:
281136528
Lei Zhang [Mon, 18 Nov 2019 20:47:54 +0000 (12:47 -0800)]
Fix gen_spirv_dialect.py regarding 1D/2D/3D Dim symbol name
PiperOrigin-RevId:
281131561
Denis Khalikov [Mon, 18 Nov 2019 20:36:16 +0000 (12:36 -0800)]
[spirv] Add a canonicalizer for BitcastOp.
Convert chained `spirv::BitcastOp` operations into
one `spirv::BitcastOp` operation.
Closes tensorflow/mlir#238
COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/238 from denis0x0D:sandbox/canon_bitcast
4352ed4f81b959ec92f849c599e733b62a99c010
PiperOrigin-RevId:
281129234
Jing Pu [Mon, 18 Nov 2019 19:27:08 +0000 (11:27 -0800)]
Also elide large array attribute in OpGraph Dump
PiperOrigin-RevId:
281114034
Alex Zinenko [Mon, 18 Nov 2019 19:25:52 +0000 (11:25 -0800)]
ConvertStandardToLLVM: replace assertion with graceful failure
The assertion was introduced in the early days of dialect conversion
infrastructure when we had the matching function separate from the rewriting
function. The infrastructure evolved to have a common matchAndRewrite function
and the separate matching function was dropped without chaning the rewriting
that became matchAndRewrite. This has led to assertion being triggered. Return
a matchFailure instead of failing an assertion on unsupported types.
Closes tensorflow/mlir#230
PiperOrigin-RevId:
281113741
Andy Davis [Mon, 18 Nov 2019 19:20:03 +0000 (11:20 -0800)]
Fix Affine Loop Fusion test case reported on github.
This CL utilizies the more robust fusion feasibility analysis being built out in LoopFusionUtils, which will eventually be used to replace the current affine loop fusion pass.
PiperOrigin-RevId:
281112340
Nicolas Vasilache [Mon, 18 Nov 2019 18:38:35 +0000 (10:38 -0800)]
Standardize all VectorOps class names to be prefixed by Vector - NFC
This improves consistency and will concretely avoid collisions between VectorExtractElementOp and ExtractElementOp when they are included in the same transforms / rewrites.
PiperOrigin-RevId:
281101588
Stephan Herhut [Mon, 18 Nov 2019 12:31:02 +0000 (04:31 -0800)]
Implement folding of pattern dim(subview(_)[...][s1, ..., sn][...], i) -> si.
PiperOrigin-RevId:
281042016
Alex Zinenko [Mon, 18 Nov 2019 10:42:39 +0000 (02:42 -0800)]
Rename CLI flags -lower-gpu-ops-to-*-ops to -convert-gpu-to-*
This makes the flags consistent with the naming scheme used elsewhere in the
codebase for dialect conversions.
PiperOrigin-RevId:
281027517
Jacques Pienaar [Sun, 17 Nov 2019 05:13:19 +0000 (21:13 -0800)]
Fix mismatched-tags warning
PiperOrigin-RevId:
280888290
Logan Chien [Fri, 15 Nov 2019 21:40:33 +0000 (13:40 -0800)]
Fix attribute dict syntax in the docs
This commit fixes several attribute dict syntax errors in the documentation.
PiperOrigin-RevId:
280726269
Denis Khalikov [Fri, 15 Nov 2019 18:51:42 +0000 (10:51 -0800)]
[spirv] Add bit ops
This CL added op definitions for a few bit operations:
* OpBitFieldInsert
* OpBitFieldSExtract
* OpBitFieldUExtract
Closes tensorflow/mlir#233
COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/233 from denis0x0D:sandbox/bit_field_ops
e7fd85b00d72d483d7992dc42b9cc4d673903455
PiperOrigin-RevId:
280691816
Alex Zinenko [Fri, 15 Nov 2019 18:19:26 +0000 (10:19 -0800)]
Clarify that identity maps are discarded from the MemRef type
Update LangRef to explicitly mention the type canonicalization rule applied to
MemRef types: identity maps do not contribute to type identification.
PiperOrigin-RevId:
280684904
Lei Zhang [Fri, 15 Nov 2019 18:16:33 +0000 (10:16 -0800)]
NFC: Convert CmpIPredicate in StandardOps to use EnumAttr
This turns several hand-written functions to auto-generated ones.
PiperOrigin-RevId:
280684326
Lucy Fox [Fri, 15 Nov 2019 17:48:54 +0000 (09:48 -0800)]
Modify tutorial and other documentation for consistency, clarity, and correctness.
PiperOrigin-RevId:
280678392
Jacques Pienaar [Fri, 15 Nov 2019 17:29:10 +0000 (09:29 -0800)]
Use simpler highlighting textmate syntax
Changes from:
https://github-lightshow.herokuapp.com/?utf8=%E2%9C%93&scope=from-url&grammar_format=auto&grammar_url=https%3A%2F%2Fraw.githubusercontent.com%2Fjpienaar%2Fmlir-grammar%2Fmaster%2Fgrammars%2Fmlir.json&grammar_text=&code_source=from-url&code_url=https%3A%2F%2Fraw.githubusercontent.com%2Fjpienaar%2Fmlir-grammar%2Fmaster%2Fsample.mlir&code=
To:
https://github-lightshow.herokuapp.com/?utf8=%E2%9C%93&scope=from-url&grammar_format=auto&grammar_url=https%3A%2F%2Fraw.githubusercontent.com%2Fjpienaar%2Fmlir-grammar%2Fsimpler%2Fgrammars%2Fmlir.json&grammar_text=&code_source=from-url&code_url=https%3A%2F%2Fraw.githubusercontent.com%2Fjpienaar%2Fmlir-grammar%2Fmaster%2Fsample.mlir&code=
Which I think is an improvement.
PiperOrigin-RevId:
280674770
Nicolas Vasilache [Fri, 15 Nov 2019 17:05:35 +0000 (09:05 -0800)]
Fix build warnings
Delete unused constexpr ints in LowerToLLVMDialect.
Add (void)toStringRef for non-debug builds.
Fixes tensorflow/mlir#232.
PiperOrigin-RevId:
280671014
Lei Zhang [Fri, 15 Nov 2019 15:33:21 +0000 (07:33 -0800)]
Use aggregate-parameter builder for ops having autogen type-deduction builder
Thus far DRR always invokes the separate-parameter builder (i.e., requiring
a separate parameter for each result-type/operand/attribute) for creating
ops, no matter whether we can auto-generate a builder with type-deduction
ability or not.
This CL changes the path for ops that we can auto-generate type-deduction
builders, i.e., with SameOperandsAndResultType/FirstAttrDerivedResultType
traits. Now they are going through a aggregate-parameter builder (i.e.,
requiring one parameter for all result-types/operands/attributes).
attributes.)
It is expected this approach will be more friendly for future shape inference
function autogen and calling those autogen'd shape inference function without
excessive packing and repacking operand/attribute lists.
Also, it would enable better support for creating ops with optional attributes
because we are not required to provide an Attribute() as placeholder for
an optional attribute anymore.
PiperOrigin-RevId:
280654800
Nicolas Vasilache [Fri, 15 Nov 2019 15:12:17 +0000 (07:12 -0800)]
Templatize linalg::LowerToLoops - NFC
This modification will allow to easily plug lowering of linalg ops to different types of loops (affine, loop.for and other future constructs).
This is purely NFC for now.
PiperOrigin-RevId:
280652186
Stephan Herhut [Fri, 15 Nov 2019 13:27:57 +0000 (05:27 -0800)]
Mark std.view as no-sideeffect.
The same reasoning as for std.subview applies.
PiperOrigin-RevId:
280639308
Stephan Herhut [Fri, 15 Nov 2019 11:59:57 +0000 (03:59 -0800)]
Mark std.subview as no-sideeffect.
In essence, std.subview is just an abstract indexing transformation (somewhat
akin to a gep in llvm) and by itself has no effect. From a practical perspective
this helps, as it allows to remove dead subview operations.
PiperOrigin-RevId:
280630046
MLIR Team [Fri, 15 Nov 2019 10:17:09 +0000 (02:17 -0800)]
Add more navigation to the MLIR toy tutorial.
This comes in the form of:
1. Missing links to next chapters.
2. Table of contents for each page.
PiperOrigin-RevId:
280619053