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
Lucy Fox [Fri, 15 Nov 2019 01:54:10 +0000 (17:54 -0800)]
Expand on operation definition to clarify the difference between operation and op.
PiperOrigin-RevId:
280555742
Nicolas Vasilache [Thu, 14 Nov 2019 23:39:36 +0000 (15:39 -0800)]
Refactor the LowerVectorTransfers pass to use the RewritePattern infra - NFC
This is step 1/n in refactoring infrastructure along the Vector dialect to make it ready for retargetability and composable progressive lowering.
PiperOrigin-RevId:
280529784
Mahesh Ravishankar [Thu, 14 Nov 2019 20:31:32 +0000 (12:31 -0800)]
NFC: Refactor Dialect Conversion targeting SPIR-V.
Refactoring the conversion from StandardOps/GPU dialect to SPIR-V
dialect:
1) Move the SPIRVTypeConversion and SPIRVOpLowering class into SPIR-V
dialect.
2) Add header files that expose functions to add patterns for the
dialects to SPIR-V lowering, as well as a pass that does the
dialect to SPIR-V lowering.
3) Make SPIRVOpLowering derive from OpLowering class.
PiperOrigin-RevId:
280486871
Andy Davis [Thu, 14 Nov 2019 20:22:28 +0000 (12:22 -0800)]
Adds canonicalizer to SubViewOp which folds constants from base memref and 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
Alex Zinenko [Thu, 14 Nov 2019 19:16:47 +0000 (11:16 -0800)]
Add CMakeLists.txt for AffineToStandard conversion
PiperOrigin-RevId:
280470142
Lei Zhang [Thu, 14 Nov 2019 19:02:52 +0000 (11:02 -0800)]
[ODS] Fix operation argument population to avoid crash
The `Operator` class keeps an `arguments` field, which contains pointers
to `operands` and `attributes` elements. Thus it must be populated after
`operands` and `attributes` are finalized so to have stable pointers.
SmallVector may re-allocate when still having new elements added, which
will invalidate pointers.
PiperOrigin-RevId:
280466896
Alex Zinenko [Thu, 14 Nov 2019 18:34:46 +0000 (10:34 -0800)]
Move Affine to Standard conversion to lib/Conversion
This is essentially a dialect conversion and conceptually belongs to
conversions.
PiperOrigin-RevId:
280460034
Alex Zinenko [Thu, 14 Nov 2019 17:10:27 +0000 (09:10 -0800)]
Make positions of elements in MemRef descriptor private
Previous commits removed all uses of LLVMTypeConverter::k*PosInMemRefDescriptor
outside of the MemRefDescriptor class. These numbers are an implementation
detail and can be hidden under a layer of more semantic APIs.
PiperOrigin-RevId:
280442444
Alex Zinenko [Thu, 14 Nov 2019 17:05:11 +0000 (09:05 -0800)]
Use MemRefDescriptor in Vector-to-LLVM convresion
Following up on the consolidation of MemRef descriptor conversion, update
Vector-to-LLVM conversion to use the helper class that abstracts away the
implementation details of the MemRef descriptor. This also makes the types of
the attributes in emitted llvm.insert/extractelement operations consistently
i64 instead of a mix of index and i64.
PiperOrigin-RevId:
280441451
MLIR Team [Thu, 14 Nov 2019 16:15:25 +0000 (08:15 -0800)]
Adapt code to LLVM API updates.
PiperOrigin-RevId:
280431812
Nicolas Vasilache [Thu, 14 Nov 2019 16:10:36 +0000 (08:10 -0800)]
Move VectorOps to Tablegen - (almost) NFC
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
Alex Zinenko [Thu, 14 Nov 2019 16:03:39 +0000 (08:03 -0800)]
Use MemRefDescriptor in Linalg-to-LLVM conversion
Following up on the consolidation of MemRef descriptor conversion, update
Linalg-to-LLVM conversion to use the helper class that abstracts away the
implementation details of the MemRef descriptor. This required MemRefDescriptor
to become publicly visible. Since this conversion is heavily EDSC-based,
introduce locally an additional wrapper that uses builder and location pointed
to by the EDSC context while emitting descriptor manipulation operations.
PiperOrigin-RevId:
280429228
Lei Zhang [Thu, 14 Nov 2019 12:25:56 +0000 (04:25 -0800)]
[doc] Add debugging tips in ODS and DRR doc regarding mlir-tblgen
PiperOrigin-RevId:
280398956
Alex Zinenko [Thu, 14 Nov 2019 08:48:41 +0000 (00:48 -0800)]
Concentrate memref descriptor manipulation logic in one place
Memref descriptor is becoming increasingly complex. Memrefs are manipulated by
multiple standard instructions, each of which has a non-trivial lowering to the
LLVM dialect. This leads to verbose code that manipulates the descriptors
exposing the internals of insert/extractelement opreations. Implement a wrapper
class that contains a memref descriptor and provides semantically named methods
that build the primitive IR operations instead.
PiperOrigin-RevId:
280371225
Jacques Pienaar [Wed, 13 Nov 2019 22:21:16 +0000 (14:21 -0800)]
Do not emit aliases when printing local form
Expand local scope printing to skip printing aliases as aliases are printed out at the top of a module and may not be part of the output generated by local scope print.
PiperOrigin-RevId:
280278617
Nicolas Vasilache [Wed, 13 Nov 2019 20:54:02 +0000 (12:54 -0800)]
Replace explicit concatenation by llvm::concat
PiperOrigin-RevId:
280258938
Nicolas Vasilache [Wed, 13 Nov 2019 20:09:40 +0000 (12:09 -0800)]
Deprecate linalg.subview in favor of std.subview
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
Lucy Fox [Wed, 13 Nov 2019 19:09:10 +0000 (11:09 -0800)]
Fix glossary formatting.
PiperOrigin-RevId:
280236761
Sean Silva [Wed, 13 Nov 2019 18:59:24 +0000 (10:59 -0800)]
Add FuncOp::eraseArgument
This is a quite complex operation that users are likely to attempt to write
themselves and get wrong (citation: users=me).
Ideally, we could pull this into FunctionLike, but for now, the
FunctionType rewriting makes it FuncOp specific. We would need some hook
for rewriting the function type (which for LLVM's func op, would need to
rewrite the underlying LLVM type).
PiperOrigin-RevId:
280234164
River Riddle [Wed, 13 Nov 2019 18:27:21 +0000 (10:27 -0800)]
NFC: Refactor block signature conversion to not erase the original arguments.
This refactors the implementation of block signature(type) conversion to not insert fake cast operations to perform the type conversion, but to instead create a new block containing the proper signature. This has the benefit of enabling the use of pre-computed analyses that rely on mapping values. It also leads to a much cleaner implementation overall. The major user facing change is that applySignatureConversion will now replace the entry block of the region, meaning that blocks generally shouldn't be cached over calls to applySignatureConversion.
PiperOrigin-RevId:
280226936
Lucy Fox [Wed, 13 Nov 2019 17:58:53 +0000 (09:58 -0800)]
Create and begin writing glossary.
This creates a central place in the documentation where MLIR-specific terminology is defined. See discussion on the MLIR forum (https://groups.google.com/a/tensorflow.org/g/mlir/c/5YXDSdu76Hk).
PiperOrigin-RevId:
280220365
River Riddle [Wed, 13 Nov 2019 17:31:45 +0000 (09:31 -0800)]
Rename the current parseSymbolName to parseOptionalSymbolName
The current implementation silently fails if the '@' identifier isn't present, making it similar to the 'optional' parse methods. This change renames the current implementation to 'Optional' and adds a new 'parseSymbolName' that emits an error.
PiperOrigin-RevId:
280214610
Hanhan Wang [Wed, 13 Nov 2019 02:58:36 +0000 (18:58 -0800)]
Make VariableOp instructions be in the first block in the function.
Since VariableOp is serialized during processBlock, we add two more fields,
`functionHeader` and `functionBody`, to collect instructions for a function.
After all the blocks have been processed, we append them to the `functions`.
Also, fix a bug in processGlobalVariableOp. The global variables should be
encoded into `typesGlobalValues`.
PiperOrigin-RevId:
280105366
Mahesh Ravishankar [Tue, 12 Nov 2019 21:19:33 +0000 (13:19 -0800)]
Add operations needed to support lowering of AffineExpr to SPIR-V.
Lowering of CmpIOp, DivISOp, RemISOp, SubIOp and SelectOp to SPIR-V
dialect enables the lowering of operations generated by AffineExpr ->
StandardOps conversion into the SPIR-V dialect.
PiperOrigin-RevId:
280039204
River Riddle [Tue, 12 Nov 2019 21:03:39 +0000 (13:03 -0800)]
NFC: Change DictionaryAttr::get(StringRef) to use binary search instead of a linear scan.
The elements of a DictionaryAttr are guaranteed to be sorted by name, so we can use a more efficient lookup when searching for an attribute.
PiperOrigin-RevId:
280035488
Mahesh Ravishankar [Tue, 12 Nov 2019 20:52:18 +0000 (12:52 -0800)]
Make legality check in GPU->SPIR-V lowering of FuncOp kernel specific.
Existing check that sets FuncOp to be dynamically legal was just
checking that the types of the argument are SPIR-V compatible. Since
the current conversion from GPU to SPIR-V does not handle lowering
non-kernel functions, change the legality check to verify that the
FuncOp has the gpu.kernel attribute and has void(void) return type.
PiperOrigin-RevId:
280032782
Lei Zhang [Tue, 12 Nov 2019 19:59:34 +0000 (11:59 -0800)]
Add support for OpPhi in loop header block
During deserialization, the loop header block will be moved into the
spv.loop's region. If the loop header block has block arguments,
we need to make sure it is correctly carried over to the block where
the new spv.loop resides.
During serialization, we need to make sure block arguments from the
spv.loop's entry block are not silently dropped.
PiperOrigin-RevId:
280021777
River Riddle [Tue, 12 Nov 2019 19:57:47 +0000 (11:57 -0800)]
Add an option to print an operation if a diagnostic is emitted on it
It is often helpful to inspect the operation that the error/warning/remark/etc. originated from, especially in the context of debugging or in the case of a verifier failure. This change adds an option 'mlir-print-op-on-diagnostic' that attaches the operation as a note to any diagnostic that is emitted on it via Operation::emit(Error|Warning|Remark). In the case of an error, the operation is printed in the generic form.
PiperOrigin-RevId:
280021438
Lei Zhang [Tue, 12 Nov 2019 19:57:40 +0000 (11:57 -0800)]
Expose an isSubclassOf() method on AttrConstraint
PiperOrigin-RevId:
280021408
Mahesh Ravishankar [Tue, 12 Nov 2019 19:32:54 +0000 (11:32 -0800)]
Add Conversion to lower loop::ForOp to spirv::LoopOp.
loop::ForOp can be lowered to the structured control flow represented
by spirv::LoopOp by making the continue block of the spirv::LoopOp the
loop latch and the merge block the exit block. The resulting
spirv::LoopOp has a single back edge from the continue to header
block, and a single exit from header to merge.
PiperOrigin-RevId:
280015614
Lei Zhang [Tue, 12 Nov 2019 18:33:36 +0000 (10:33 -0800)]
[spirv] Properly return when finding error in serialization
PiperOrigin-RevId:
280001339
River Riddle [Tue, 12 Nov 2019 17:36:40 +0000 (09:36 -0800)]
Add a printer flag to use local scope when printing IR.
This causes the AsmPrinter to use a local value numbering when printing the IR, allowing for the printer to be used safely in a local context, e.g. to ensure thread-safety when printing the IR. This means that the IR printing instrumentation can also be used during multi-threading when module-scope is disabled. Operation::dump and DiagnosticArgument(Operation*) are also updated to always print local scope, as this is the most common use case when debugging.
PiperOrigin-RevId:
279988203
Jacques Pienaar [Tue, 12 Nov 2019 17:30:08 +0000 (09:30 -0800)]
Update textmate syntax file
Allow comments in more places and fix function params.
PiperOrigin-RevId:
279986797
Lei Zhang [Tue, 12 Nov 2019 17:25:41 +0000 (09:25 -0800)]
Update outdated comment for NativeCodeCall
PiperOrigin-RevId:
279986050
Nicolas Vasilache [Tue, 12 Nov 2019 15:22:51 +0000 (07:22 -0800)]
Add LLVM lowering of std.subview
A followup CL will replace usage of linalg.subview by std.subview.
PiperOrigin-RevId:
279961981
Andy Davis [Tue, 12 Nov 2019 15:08:23 +0000 (07:08 -0800)]
Adds affine.min operation which returns the minimum value from a multi-result affine map. This operation is useful for things like computing the dynamic value of affine loop bounds, and is trivial to constant fold.
PiperOrigin-RevId:
279959714
Nicolas Vasilache [Tue, 12 Nov 2019 15:06:18 +0000 (07:06 -0800)]
Add support for alignment attribute in std.alloc.
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
River Riddle [Tue, 12 Nov 2019 03:14:43 +0000 (19:14 -0800)]
Restructure comment lexing to not recurse.
In some files that have large amounts of comments, this can lead to a stack overflow.
PiperOrigin-RevId:
279867330
River Riddle [Tue, 12 Nov 2019 02:18:02 +0000 (18:18 -0800)]
Add support for nested symbol references.
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
Andy Davis [Mon, 11 Nov 2019 18:32:52 +0000 (10:32 -0800)]
Adds std.subview operation which takes dynamic offsets, sizes and strides 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
Stephan Herhut [Mon, 11 Nov 2019 10:33:49 +0000 (02:33 -0800)]
Also consider index constants when folding integer arithmetics with constants.
PiperOrigin-RevId:
279698088
Mehdi Amini [Sun, 10 Nov 2019 05:30:42 +0000 (21:30 -0800)]
Fix segfault (nullptr dereference) when passing a non-existent file to the Toy tutorial compiler
Fix tensorflow/mlir#229
PiperOrigin-RevId:
279557863
Manuel Freiberger [Sat, 9 Nov 2019 20:14:39 +0000 (12:14 -0800)]
Add a short TableGen HowTo to tutorial chapter 2.
Add a note to chapter 2 of the Toy tutorial stating how to invoke
mlir-tblgen to check the generated C++ code. IMHO this is incredibly
useful when getting acquainted with TableGen/ODS.
Closes tensorflow/mlir#228
COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/228 from ombre5733:toy-ch2-howto-mlir-tblgen
a051a3734ca8bbf4f12027fe737aca07c64ca59d
PiperOrigin-RevId:
279518989
MLIR Team [Sat, 9 Nov 2019 03:12:40 +0000 (19:12 -0800)]
Look for SymbolRefAttr in KernelOutlining instead of hard-coding CallOp
This code should be exercised using the existing kernel outlining unit test, but
let me know if I should add a dedicated unit test using a fake call instruction
as well.
PiperOrigin-RevId:
279436321
Jacques Pienaar [Fri, 8 Nov 2019 23:06:03 +0000 (15:06 -0800)]
Explicitly initialize isRecursivelyLegal
This also previously triggered the warning:
warning: missing field 'isRecursivelyLegal' initializer [-Wmissing-field-initializers]
legalOperations[op] = {action};
^
PiperOrigin-RevId:
279399175
Denis Khalikov [Fri, 8 Nov 2019 19:05:32 +0000 (11:05 -0800)]
[spirv] Add bit ops
This CL added op definitions for a few bit operations:
* OpShiftLeftLogical
* OpShiftRightArithmetic
* OpShiftRightLogical
* OpBitCount
* OpBitReverse
* OpNot
Also moved the definition of spv.BitwiseAnd to follow the
lexicographical order.
Closes tensorflow/mlir#215
COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/215 from denis0x0D:sandbox/bit_ops
d9b0852b689ac6c4879a9740b1740a2357f44d24
PiperOrigin-RevId:
279350470
Alexander Belyaev [Thu, 7 Nov 2019 22:50:25 +0000 (14:50 -0800)]
Move description from GenericOpBase to linalg.(indexed_)generic.
PiperOrigin-RevId:
279173284
Alex Zinenko [Thu, 7 Nov 2019 19:42:11 +0000 (11:42 -0800)]
mlir-translate: support -verify-diagnostics
MLIR translation tools can emit diagnostics and we want to be able to check if
it is indeed the case in tests. Reuse the source manager error handlers
provided for mlir-opt to support the verification in mlir-translate. This
requires us to change the signature of the functions that are registered to
translate sources to MLIR: it now takes a source manager instead of a memory
buffer.
PiperOrigin-RevId:
279132972
Uday Bondhugula [Thu, 7 Nov 2019 18:26:51 +0000 (10:26 -0800)]
Fix asm printer for affine expr
- fixes tensorflow/mlir#201
Signed-off-by: Uday Bondhugula <uday@polymagelabs.com>
Closes tensorflow/mlir#204
COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/204 from bondhugula:printfix
3f8a5b65391f45598258b2735fecaa409fbde848
PiperOrigin-RevId:
279115720
Andy Davis [Thu, 7 Nov 2019 18:19:54 +0000 (10:19 -0800)]
Swap operand order in std.view operation so that offset appears before dynamic sizes in the operand list.
PiperOrigin-RevId:
279114236
River Riddle [Thu, 7 Nov 2019 17:53:27 +0000 (09:53 -0800)]
Add Ch-7 of the toy tutorial detailing how to define new types.
This chapter adds a new composite type to Toy, and shows the process of adding a new type to the IR, adding and updating operations to use it, and constant folding operations producing it.
PiperOrigin-RevId:
279107885
Andy Davis [Thu, 7 Nov 2019 16:04:33 +0000 (08:04 -0800)]
Add canonicalizer for ViewOp which folds constants into the ViewOp memref shape and layout map strides and offset.
PiperOrigin-RevId:
279088023
Nicolas Vasilache [Thu, 7 Nov 2019 15:55:49 +0000 (07:55 -0800)]
Fix parameter name and document option in linalg::promoteSubViews
PiperOrigin-RevId:
279086352
Jacques Pienaar [Thu, 7 Nov 2019 15:51:12 +0000 (07:51 -0800)]
Add compatible query method to infer type interface
A return type that differs from the inferred return type need not indicate that an operation is invalid (e.g., tensor<*xf32> vs tensor<10xf32>) but they should be compatible for the operation to be considered valid. Add method to query if inferred type is compatible with return type.
Also add InferTypeOpIntefaceDefault trait that considers equality and compatibility as the same. Currently an op has to opt in to using it explicitly.
PiperOrigin-RevId:
279085639
Nicolas Vasilache [Thu, 7 Nov 2019 14:32:39 +0000 (06:32 -0800)]
Update Linalg to use std.view
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
Alexander Belyaev [Thu, 7 Nov 2019 06:35:51 +0000 (22:35 -0800)]
Add IndexedGenericOp to Linalg.
PiperOrigin-RevId:
279013404
River Riddle [Thu, 7 Nov 2019 02:21:04 +0000 (18:21 -0800)]
NFC: Tidy up the implementation of operations in the Toy tutorial
Use header blocks to separate operation implementations, and switch the build methods to be out-of-line when possible.
PiperOrigin-RevId:
278982913
River Riddle [Thu, 7 Nov 2019 02:20:24 +0000 (18:20 -0800)]
NFC: Uniformize parser naming scheme in Toy tutorial to camelCase and tidy a bit of the implementation.
PiperOrigin-RevId:
278982817
Sean Silva [Thu, 7 Nov 2019 00:08:51 +0000 (16:08 -0800)]
Replace some remnant uses of "inst" with "op".
PiperOrigin-RevId:
278961676
Nicolas Vasilache [Thu, 7 Nov 2019 00:00:22 +0000 (16:00 -0800)]
Drop spurious test file
PiperOrigin-RevId:
278959717