Lei Zhang [Sat, 14 Sep 2019 15:36:53 +0000 (08:36 -0700)]
Update QuickstartRewrites.md regarding op definition and rewrites
This CL updates the doc with recent changes. It also adds a section
on registering and using the auto-generated patterns.
PiperOrigin-RevId:
269086830
Uday Bondhugula [Sat, 14 Sep 2019 05:11:23 +0000 (22:11 -0700)]
Add pattern to canonicalize for loop bounds
- add pattern to canonicalize affine.for loop bounds (using
canonicalizeMapAndOperands)
- rename AffineForLoopBoundFolder -> AffineForLoopBoundFolder for
consistency
Signed-off-by: Uday Bondhugula <uday@polymagelabs.com>
Closes tensorflow/mlir#111
COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/111 from bondhugula:bound-canonicalize
ee8fb7f43a7ffd45f6df3f53c95098d8b7e494c7
PiperOrigin-RevId:
269041220
River Riddle [Sat, 14 Sep 2019 01:18:22 +0000 (18:18 -0700)]
Verify that ModuleOps only contain dialect specific attributes.
ModuleOp has no expected operations, so only dialect-specific attributes are valid.
PiperOrigin-RevId:
269020062
Uday Bondhugula [Sat, 14 Sep 2019 01:18:21 +0000 (18:18 -0700)]
add missing memref cast fold pattern for dim op
- add missing canonicalization pattern to fold memref_cast + dim to
dim (needed to propagate constant when folding a dynamic shape to
a static one)
- also fix an outdated/inconsistent comment in StandardOps/Ops.td
Signed-off-by: Uday Bondhugula <uday@polymagelabs.com>
Closes tensorflow/mlir#126
COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/126 from bondhugula:quickfix
4566e75e49685c532faffff91d64c5d83d4da524
PiperOrigin-RevId:
269020058
River Riddle [Sat, 14 Sep 2019 00:53:28 +0000 (17:53 -0700)]
Publicly expose the functionality to parse a textual pass pipeline.
This allows for users other than those on the command line to apply a textual description of a pipeline to a given pass manager.
PiperOrigin-RevId:
269017028
Geoffrey Martin-Noble [Fri, 13 Sep 2019 23:05:06 +0000 (16:05 -0700)]
Add type constraints for shaped types with same rank and element count
PiperOrigin-RevId:
269000237
Lei Zhang [Fri, 13 Sep 2019 22:25:56 +0000 (15:25 -0700)]
Update SPIR-V symbols and use GLSL450 instead of VulkanKHR
SPIR-V recently publishes v1.5, which brings a bunch of symbols
into core. So the suffix "KHR"/"EXT"/etc. is removed from the
symbols. We use a script to pull information from the spec
directly.
Also changed conversion and tests to use GLSL450 instead of
VulkanKHR memory model. GLSL450 is still the main memory model
supported by Vulkan shaders and it does not require extra
capability to enable.
PiperOrigin-RevId:
268992661
River Riddle [Fri, 13 Sep 2019 20:33:46 +0000 (13:33 -0700)]
NFC: Finish replacing FunctionPassBase/ModulePassBase with OpPassBase.
These directives were temporary during the generalization of FunctionPass/ModulePass to OpPass.
PiperOrigin-RevId:
268970259
Geoffrey Martin-Noble [Fri, 13 Sep 2019 20:21:57 +0000 (13:21 -0700)]
Add tablegen class for memrefs with rank constraints
PiperOrigin-RevId:
268968004
River Riddle [Fri, 13 Sep 2019 20:18:44 +0000 (13:18 -0700)]
Forward diagnostics from untracked threads in ParallelDiagnosticHandler.
This allows for the use of multiple ParallelDiagnosticHandlers without having them conflict with each other.
PiperOrigin-RevId:
268967407
MLIR Team [Fri, 13 Sep 2019 19:46:07 +0000 (12:46 -0700)]
Improve verifier error reporting on type mismatch (NFC)
Before this change, it only reports expected type but not exact type, so
it's hard to troubleshoot.
PiperOrigin-RevId:
268961078
River Riddle [Fri, 13 Sep 2019 19:09:50 +0000 (12:09 -0700)]
Refactor pass pipeline command line parsing to support explicit pipeline strings.
This allows for explicitly specifying the pipeline to add to the pass manager. This includes the nesting structure, as well as the passes/pipelines to run. A textual pipeline string is defined as a series of names, each of which may in itself recursively contain a nested pipeline description. A name is either the name of a registered pass, or pass pipeline, (e.g. "cse") or the name of an operation type (e.g. "func").
For example, the following pipeline:
$ mlir-opt foo.mlir -cse -canonicalize -lower-to-llvm
Could now be specified as:
$ mlir-opt foo.mlir -pass-pipeline='func(cse, canonicalize), lower-to-llvm'
This will allow for running pipelines on nested operations, like say spirv modules. This does not remove any of the current functionality, and in fact can be used in unison. The new option is available via 'pass-pipeline'.
PiperOrigin-RevId:
268954279
Geoffrey Martin-Noble [Fri, 13 Sep 2019 17:28:53 +0000 (10:28 -0700)]
NFC: Update comments about rank constraints
These refer to ranked tensors, but are actually applicable to any shaped type
PiperOrigin-RevId:
268931789
MLIR Team [Fri, 13 Sep 2019 11:07:33 +0000 (04:07 -0700)]
Fixing typo in documentation.
PiperOrigin-RevId:
268877189
Smit Hinsu [Fri, 13 Sep 2019 08:37:07 +0000 (01:37 -0700)]
Log name of the generated illegal operation name in DialectConversion debug mode
PiperOrigin-RevId:
268859399
Geoffrey Martin-Noble [Thu, 12 Sep 2019 22:43:26 +0000 (15:43 -0700)]
Cmpf constant folding for nan and inf
PiperOrigin-RevId:
268783645
Geoffrey Martin-Noble [Thu, 12 Sep 2019 22:29:59 +0000 (15:29 -0700)]
NFC: Clean up constant fold tests
Use variable captures to make constant folding tests less sensitive to printer/parser implementation details.
See guidelines at https://github.com/tensorflow/mlir/blob/master/g3doc/TestingGuide.md
PiperOrigin-RevId:
268780812
Lei Zhang [Wed, 11 Sep 2019 21:02:23 +0000 (14:02 -0700)]
[spirv] Add support for spv.loop (de)serialization
This CL adds support for serializing and deserializing spv.loop ops.
This adds support for spv.Branch and spv.BranchConditional op
(de)serialization, too, because they are needed for spv.loop.
PiperOrigin-RevId:
268536962
Alex Zinenko [Wed, 11 Sep 2019 17:18:01 +0000 (10:18 -0700)]
Rename SDBMPositiveExpr to SDBMTermExpr
This better reflects how this kind of expressions is used and avoids the
potential confusion since the expression can take negative values. Term
expressions comprise dimensions, symbols and stripe expressions. In an SDBM
domain, a stripe expression always corresponds to a variable, input or
temporary. This expression can appear anywhere an input variable can,
including on the LHS of other stripe expressions.
PiperOrigin-RevId:
268486066
Alex Zinenko [Wed, 11 Sep 2019 13:11:03 +0000 (06:11 -0700)]
Fix typos in SDBMTest.cpp
PiperOrigin-RevId:
268443146
MLIR Team [Wed, 11 Sep 2019 12:09:23 +0000 (05:09 -0700)]
Add logical groups to NVVM op definitions.
PiperOrigin-RevId:
268436116
MLIR Team [Wed, 11 Sep 2019 06:53:58 +0000 (23:53 -0700)]
Fix a typo in comments. The Inequality and Equality explanations were apparently reversed.
PiperOrigin-RevId:
268395163
MLIR Team [Wed, 11 Sep 2019 02:02:54 +0000 (19:02 -0700)]
Don't leak TargetMachine in ExecutionEngine::setupTargetTriple
PiperOrigin-RevId:
268361054
Lei Zhang [Wed, 11 Sep 2019 00:47:37 +0000 (17:47 -0700)]
Add folding rule for spv.CompositeExtract
If the composite is a constant, we can fold it away. This only
supports vector and array constants for now, given that struct
constant is not supported in spv.constant yet.
PiperOrigin-RevId:
268350340
Feng Liu [Tue, 10 Sep 2019 20:26:14 +0000 (13:26 -0700)]
Remove the constraint that min / max should stride zero
Since we apply nudging for the zero point to make sure the nudged zerop points
can be in the range of [qmin, qmax], the constraint that rmin / rmax should
stride zero isn't necessary.
This also matches the documentation of tensorflow's FakeQuantWithMinMaxArgs op,
where min and max don't need to stride zero:
https://www.tensorflow.org/api_docs/python/tf/quantization/fake_quant_with_min_max_args
PiperOrigin-RevId:
268296285
Feng Liu [Tue, 10 Sep 2019 17:50:16 +0000 (10:50 -0700)]
Convert ConstFakeQuantPerAxis to qcast and dcast pair
This is also to add the test to the fakeQuantAttrsToType for per-channel fake quant.
PiperOrigin-RevId:
268260032
Jacques Pienaar [Tue, 10 Sep 2019 08:30:34 +0000 (01:30 -0700)]
Remove unused variable
PiperOrigin-RevId:
268173638
Jacques Pienaar [Tue, 10 Sep 2019 02:50:19 +0000 (19:50 -0700)]
Remove redundant qualification
Address GCC error: extra qualification not allowed [-fpermissive]
PiperOrigin-RevId:
268133737
Jacques Pienaar [Tue, 10 Sep 2019 02:36:02 +0000 (19:36 -0700)]
Avoid sign-compare warning
PiperOrigin-RevId:
268132321
Jacques Pienaar [Tue, 10 Sep 2019 01:12:12 +0000 (18:12 -0700)]
Add pass generate per block in a function a GraphViz Dot graph with ops as nodes
* Add GraphTraits that treat a block as a graph, Operation* as node and use-relationship for edges;
- Just basic graph output;
* Add use iterator to iterate over all uses of an Operation;
* Add testing pass to generate op graph;
This does not support arbitrary operations other than function nor nested regions yet.
PiperOrigin-RevId:
268121782
Feng Liu [Mon, 9 Sep 2019 22:42:07 +0000 (15:42 -0700)]
Add quant.const_fake_quant_per_axis op
Comparing to the existing quant.const_fake_quant op, the min and max attributes
of this new op is for each channel of last dimension of the input.
PiperOrigin-RevId:
268093722
Feng Liu [Mon, 9 Sep 2019 22:29:30 +0000 (15:29 -0700)]
[NFC] Rename ExpressedToUniformQuantizedType to ExpressedToQuantizedType
PiperOrigin-RevId:
268090906
Feng Liu [Mon, 9 Sep 2019 21:57:29 +0000 (14:57 -0700)]
Convert per channel fake quant attributes to type
For per channel fake quant attributes, the returned type should be
UniformQuantizedPerAxisType. Currently, this method isn't under test because we
haven't added the quant_ConstFakeQuantPerAxis op and the convert method.
PiperOrigin-RevId:
268084017
River Riddle [Mon, 9 Sep 2019 20:43:51 +0000 (13:43 -0700)]
Explicitly declare the OpPassManager move constructor to avoid undefined errors.
Some compilers will try to auto-generate the destructor, instead of using the user provided destructor, when creating a default move constructor.
PiperOrigin-RevId:
268067367
MLIR Team [Mon, 9 Sep 2019 18:38:34 +0000 (11:38 -0700)]
Overload LLVM::TerminatorOp::build() for empty operands list.
PiperOrigin-RevId:
268041584
MLIR Team [Mon, 9 Sep 2019 18:37:05 +0000 (11:37 -0700)]
Add warpsize and laneid intrinsics to NVVM dialect.
PiperOrigin-RevId:
268041263
River Riddle [Mon, 9 Sep 2019 16:51:59 +0000 (09:51 -0700)]
Add support for coalescing adjacent nested pass pipelines.
This allows for parallelizing across pipelines of multiple operation types. AdaptorPasses can now hold pass managers for multiple operation types and will dispatch based upon the operation being operated on.
PiperOrigin-RevId:
268017344
Stephan Herhut [Mon, 9 Sep 2019 08:15:10 +0000 (01:15 -0700)]
Addressing some late review comments on kernel inlining.
Just formatting and better lit tests, no functional change.
PiperOrigin-RevId:
267942907
Mehdi Amini [Mon, 9 Sep 2019 06:39:34 +0000 (23:39 -0700)]
Add `parseGenericOperation()` to the OpAsmParser
This method parses an operation in its generic form, from the current parser
state. This is the symmetric of OpAsmPrinter::printGenericOp(). An immediate
use case is illustrated in the test dialect, where an operation wraps another
one in its region and makes use of a single-line pretty-print form.
PiperOrigin-RevId:
267930869
River Riddle [Mon, 9 Sep 2019 02:57:25 +0000 (19:57 -0700)]
Refactor PassTiming to support nested pipelines.
This is done via a new set of instrumentation hooks runBeforePipeline/runAfterPipeline, that signal the lifetime of a pass pipeline on a specific operation type. These hooks also provide the parent thread of the pipeline, allowing for accurate merging of timers running on different threads.
PiperOrigin-RevId:
267909193
Mehdi Amini [Sun, 8 Sep 2019 01:56:39 +0000 (18:56 -0700)]
Use "final" instead of marking method virtual in override (NFC)
This is the only example for overriding this interface in the repo, let's
try to make it right as it may be taken as a reference when implemented in
other dialects
PiperOrigin-RevId:
267811123
Mehdi Amini [Sun, 8 Sep 2019 00:02:07 +0000 (17:02 -0700)]
Refactor getUsedValuesDefinedAbove to expose a variant taking a callback (NFC)
This will allow clients to implement a different collection strategy on these
values, including collecting each uses within the region for example.
PiperOrigin-RevId:
267803978
Uday Bondhugula [Sat, 7 Sep 2019 16:59:47 +0000 (09:59 -0700)]
Set mlir-cpu-runner JIT codegen opt level correctly
- the JIT codegen was being run at the default -O0 level; instead,
propagate the opt level from the cmd line.
Signed-off-by: Uday Bondhugula <uday@polymagelabs.com>
Closes tensorflow/mlir#123
COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/123 from bondhugula:jit-runner
3b055e47f94c9a48bf487f6400787478738cda02
PiperOrigin-RevId:
267778586
Mehdi Amini [Sat, 7 Sep 2019 15:53:24 +0000 (08:53 -0700)]
Wrap debug dump in LLVM_DEBUG
PiperOrigin-RevId:
267774506
Lei Zhang [Sat, 7 Sep 2019 12:25:39 +0000 (05:25 -0700)]
Add doc for declarative rewrite rules
This doc serves as a manual for table-driven declarative rewrite rules.
It lists all the details regarding supported mechanisms.
PiperOrigin-RevId:
267761702
Mehdi Amini [Fri, 6 Sep 2019 19:30:06 +0000 (12:30 -0700)]
Fix typo in the documentation for tensor_cast (NFC)
PiperOrigin-RevId:
267650411
River Riddle [Fri, 6 Sep 2019 18:43:35 +0000 (11:43 -0700)]
Restrict affine inlining to just Function operations.
The current restrictions on dim/symbols require a top-level symbol for the conservative case of a non-affine region. This should be relaxed in the future.
PiperOrigin-RevId:
267641838
Nagy Mostafa [Fri, 6 Sep 2019 18:02:31 +0000 (11:02 -0700)]
Add custom builder for AffineIfOp
Closes tensorflow/mlir#109
COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/109 from nmostafa:nmostafa/AffineIfOp
7dbf2115f0092ffab26381ea8704aa05a0253971
PiperOrigin-RevId:
267633077
Nicolas Vasilache [Fri, 6 Sep 2019 15:30:54 +0000 (08:30 -0700)]
Simplify Linalg ABI integration with external function calls.
View descriptors are converted to *pointer to* LLVM struct to avoid ABI issues related to C struct packing. This creates unnecessary complexity and hampers unification with memrefs.
Instead, this CL makes view descriptors convert to LLVM struct (as it was originally) and promotes all structs to pointers right before calling an external function.
PiperOrigin-RevId:
267602693
Alex Zinenko [Fri, 6 Sep 2019 08:22:24 +0000 (01:22 -0700)]
Fix typos in Interfaces.md
PiperOrigin-RevId:
267548530
Uday Bondhugula [Fri, 6 Sep 2019 06:12:01 +0000 (23:12 -0700)]
Integer set + operands / affine if op canonicalization
- turn canonicalizeMapAndOperands into a template that works on both
sets and maps, and use it to introduce a utility to canonicalize an
affine integer set and its operands
- add pattern to canonicalize affine if op's.
- rename IntegerSet::getNumOperands -> IntegerSet::getNumInputs to be
consistent with AffineMap
- add missing accessors for IntegerSet
Doesn't need extensive testing since canonicalizeSetAndOperands just
reuses canonicalizeMapAndOperands' logic, and the latter is tested on
affine.apply map + operands; the new method works the same way on an
integer set + operands of an affine if op for example.
Signed-off-by: Uday Bondhugula <uday@polymagelabs.com>
Closes tensorflow/mlir#112
COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/112 from bondhugula:set-canonicalize
eff72f23250b96fa7d9f5caff3877440f5de2cec
PiperOrigin-RevId:
267532876
River Riddle [Thu, 5 Sep 2019 22:19:55 +0000 (15:19 -0700)]
Add support for conservatively inlining Affine operations.
This commit defines an initial implementation of the DialectInlinerInterface for the AffineOps dialect. This change allows for affine operations to be inlined into any region that is not an affine region. Inlining into affine regions requires special handling for dimension/symbol identifiers that will be added in followups.
PiperOrigin-RevId:
267467078
Lei Zhang [Thu, 5 Sep 2019 19:45:08 +0000 (12:45 -0700)]
[spirv] Add spv.loop
SPIR-V can explicitly declare structured control-flow constructs using merge
instructions. These explicitly declare a header block before the control
flow diverges and a merge block where control flow subsequently converges.
These blocks delimit constructs that must nest, and can only be entered
and exited in structured ways.
Instead of having a `spv.LoopMerge` op to directly model loop merge
instruction for indicating the merge and continue target, we use regions
to delimit the boundary of the loop: the merge target is the next op
following the `spv.loop` op and the continue target is the block that
has a back-edge pointing to the entry block inside the `spv.loop`'s region.
This way it's easier to discover all blocks belonging to a construct and
it plays nicer with the MLIR system.
Updated the SPIR-V.md doc.
PiperOrigin-RevId:
267431010
River Riddle [Thu, 5 Sep 2019 19:23:45 +0000 (12:23 -0700)]
Add the initial inlining infrastructure.
This defines a set of initial utilities for inlining a region(or a FuncOp), and defines a simple inliner pass for testing purposes.
A new dialect interface is defined, DialectInlinerInterface, that allows for dialects to override hooks controlling inlining legality. The interface currently provides the following hooks, but these are just premilinary and should be changed/added to/modified as necessary:
* isLegalToInline
- Determine if a region can be inlined into one of this dialect, *or* if an operation of this dialect can be inlined into a given region.
* shouldAnalyzeRecursively
- Determine if an operation with regions should be analyzed recursively for legality. This allows for child operations to be closed off from the legality checks for operations like lambdas.
* handleTerminator
- Process a terminator that has been inlined.
This cl adds support for inlining StandardOps, but other dialects will be added in followups as necessary.
PiperOrigin-RevId:
267426759
Stephan Herhut [Thu, 5 Sep 2019 08:45:40 +0000 (01:45 -0700)]
Make GPU kernel outlining test independent of value names.
PiperOrigin-RevId:
267323604
Smit Hinsu [Thu, 5 Sep 2019 06:15:33 +0000 (23:15 -0700)]
Generalize I32ElementsAttr definition and introduce I64ElementsAttr
Also, fix constBuilderCall to return attribute of the storage class DenseIntElementsAttr
PiperOrigin-RevId:
267305813
Nicolas Vasilache [Thu, 5 Sep 2019 02:16:32 +0000 (19:16 -0700)]
Use transform function on llvm::Module in the ExecutionEngine
The refactoring of ExecutionEngine dropped the usage of the irTransform function used to pass -O3 and other options to LLVM. As a consequence, the proper optimizations do not kick in in LLMV-land.
This CL makes use of the transform function and allows producing avx512 instructions, on an internal example, when using:
`mlir-cpu-runner -dump-object-file=1 -object-filename=foo.o` combined with `objdump -D foo.o`.
Assembly produced resembles:
```
2b2e: 62 72 7d 48 18 04 0e vbroadcastss (%rsi,%rcx,1),%zmm8
2b35: 62 71 7c 48 28 ce vmovaps %zmm6,%zmm9
2b3b: 62 72 3d 48 a8 c9 vfmadd213ps %zmm1,%zmm8,%zmm9
2b41: 62 f1 7c 48 28 cf vmovaps %zmm7,%zmm1
2b47: 62 f2 3d 48 a8 c8 vfmadd213ps %zmm0,%zmm8,%zmm1
2b4d: 62 f2 7d 48 18 44 0e vbroadcastss 0x4(%rsi,%rcx,1),%zmm0
2b54: 01
2b55: 62 71 7c 48 28 c6 vmovaps %zmm6,%zmm8
2b5b: 62 72 7d 48 a8 c3 vfmadd213ps %zmm3,%zmm0,%zmm8
2b61: 62 f1 7c 48 28 df vmovaps %zmm7,%zmm3
2b67: 62 f2 7d 48 a8 da vfmadd213ps %zmm2,%zmm0,%zmm3
2b6d: 62 f2 7d 48 18 44 0e vbroadcastss 0x8(%rsi,%rcx,1),%zmm0
2b74: 02
2b75: 62 f2 7d 48 a8 f5 vfmadd213ps %zmm5,%zmm0,%zmm6
2b7b: 62 f2 7d 48 a8 fc vfmadd213ps %zmm4,%zmm0,%zmm7
```
etc.
Fixes tensorflow/mlir#120
PiperOrigin-RevId:
267281097
Rob Suderman [Thu, 5 Sep 2019 00:24:04 +0000 (17:24 -0700)]
Updated StructAttr to use the struct name for StorageType and ReturnType.
PiperOrigin-RevId:
267266687
MLIR Team [Wed, 4 Sep 2019 19:26:11 +0000 (12:26 -0700)]
Retain address space during MLIR > LLVM conversion.
PiperOrigin-RevId:
267206460
Alex Zinenko [Wed, 4 Sep 2019 15:37:39 +0000 (08:37 -0700)]
Move LLVMIR dialect tests from test/LLVMIR to test/Dialect and test/Conversion
This follows up on the recent restructuring that moved the dialects under
lib/Dialect and inter-dialect conversions to lib/Conversion. Originally, the
tests for both the LLVMIR dialect itself and the conversion from Standard to
LLVMIR dialect lived under test/LLVMIR. This no longer reflects the code
structure. Move the tests to either test/Dialect/LLVMIR or
test/Conversion/StandardToLLVM depending on the features they exercise.
PiperOrigin-RevId:
267159219
Jacques Pienaar [Wed, 4 Sep 2019 14:02:37 +0000 (07:02 -0700)]
Make isIsolatedAbove robuster to invalid IR
This function is only called from the verifier.
PiperOrigin-RevId:
267145495
Uday Bondhugula [Wed, 4 Sep 2019 13:58:39 +0000 (06:58 -0700)]
pipeline-data-transfer: remove dead tag alloc's and improve test coverage for replaceMemRefUsesWith / pipeline-data-transfer
- address remaining comments from PR tensorflow/mlir#87 for better test coverage for
pipeline-data-transfer/replaceAllMemRefUsesWith
- remove dead tag allocs the same way they are removed for the replaced buffers
Signed-off-by: Uday Bondhugula <uday@polymagelabs.com>
Closes tensorflow/mlir#106
COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/106 from bondhugula:followup
9e868666d047e8d43e5f82f43e4093b838c710fa
PiperOrigin-RevId:
267144774
Alex Zinenko [Wed, 4 Sep 2019 13:32:54 +0000 (06:32 -0700)]
Move Linalg dialect tests to test/Dialect/Linalg
This was missing from the commit that moved the Linalg dialect to lib/Dialect.
PiperOrigin-RevId:
267141176
Stephan Herhut [Wed, 4 Sep 2019 13:15:40 +0000 (06:15 -0700)]
Make GPU kernel outlining inline constants.
It is generally beneficial to pass less arguments to a kernel, so cloning constants
into the kernel is beneficial.
PiperOrigin-RevId:
267139084
MLIR Team [Wed, 4 Sep 2019 10:45:38 +0000 (03:45 -0700)]
Add support for array-typed constants.
PiperOrigin-RevId:
267121729
Alex Zinenko [Wed, 4 Sep 2019 10:01:17 +0000 (03:01 -0700)]
Update the syntax of splat attribute in LLVM.md
The syntax for splat attributes changed, but was not updated in the description
of the LLVM dialect constant operations in LLVM.md. Update the document to use
the correct syntax. Also add a dialect roundtrip test for such attribute,
which was previously missing.
PiperOrigin-RevId:
267116305
Alex Zinenko [Wed, 4 Sep 2019 09:42:50 +0000 (02:42 -0700)]
Mention clang-format in the developer guide
PiperOrigin-RevId:
267114122
Nicolas Vasilache [Tue, 3 Sep 2019 22:27:49 +0000 (15:27 -0700)]
Properly clone Linalg ops with regions
This CL adds support for proper cloning of Linalg ops that have regions (i.e. the generic linalg op). This is used to properly implement tiling and fusion for such ops. Adequate tests are added.
PiperOrigin-RevId:
267027176
Uday Bondhugula [Tue, 3 Sep 2019 19:13:59 +0000 (12:13 -0700)]
Utility to normalize memrefs with non-identity layout maps
- introduce utility to convert memrefs with non-identity layout maps to
ones with identity layout maps: convert the type and rewrite/remap all
its uses
- add this utility to -simplify-affine-structures pass for testing
purposes
Signed-off-by: Uday Bondhugula <uday@polymagelabs.com>
Closes tensorflow/mlir#104
COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/104 from bondhugula:memref-normalize
f2c914aa1890e8860326c9e33f9aa160b3d65e6d
PiperOrigin-RevId:
266985317
Lei Zhang [Tue, 3 Sep 2019 19:09:07 +0000 (12:09 -0700)]
Add folding rule and dialect materialization hook for spv.constant
This will allow us to use MLIR's folding infrastructure to deduplicate
SPIR-V constants.
This CL also changed isValidSPIRVType in SPIRVDialect to a static method.
PiperOrigin-RevId:
266984403
Uday Bondhugula [Tue, 3 Sep 2019 18:52:39 +0000 (11:52 -0700)]
Fix affine data copy generation corner cases/bugs
- the [begin, end) range identified for copying could end in between the
block, which makes hoisting invalid in some cases. Change the range
identification to always end with end of block.
- add test case to exercise these (with fast mem capacity set to minimal so
that single element memref buffers are generated at the innermost loop)
- the location of begin/end of the block range for data copying was
being confused with the insert points for copy in and copy out code.
In cases, where we choose to hoist transfers, these are separate.
- when copy loops are single iteration ones, promote their bodies at
the end of the pass.
- change default fast mem space to 1 (setting it to zero made it
generate DMA op's that won't verify in the default case - since the
DMA ops have a check for src/dest memref spaces being different).
Signed-off-by: Uday Bondhugula <uday@polymagelabs.com>
Co-Authored-By: Mehdi Amini <joker.eph@gmail.com>
Closes tensorflow/mlir#88
COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/88 from bondhugula:datacopy
88697267c45e850c3ced87671e16e4a930c02a42
PiperOrigin-RevId:
266980911
MLIR Team [Tue, 3 Sep 2019 18:39:36 +0000 (11:39 -0700)]
Add information about the SIG + Open Design meetings to the README.
PiperOrigin-RevId:
266978247
River Riddle [Tue, 3 Sep 2019 18:27:00 +0000 (11:27 -0700)]
Fix an invalid assert when processing escaped strings.
The assert assumed that the escaped character could not appear at the end of the string.
Fixes tensorflow/mlir#117
PiperOrigin-RevId:
266975471
Alex Torres [Tue, 3 Sep 2019 18:12:25 +0000 (11:12 -0700)]
Remove unused variables
Remove unused variables and attributes from BaseViewConversionHelper
on mlir/lib/Dialect/Linalg/Transforms/LowerToLLVMDialect.cpp
Closes tensorflow/mlir#116
COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/116 from alexst07:fix-warnings
5f638e4677492cf71a9cc040eeb6b57427d32e06
PiperOrigin-RevId:
266972082
Alex Zinenko [Tue, 3 Sep 2019 16:10:24 +0000 (09:10 -0700)]
LLVM dialect: prefix auxiliary operations with "mlir."
Some of the operations in the LLVM dialect are required to model the LLVM IR in
MLIR, for example "constant" operations are needed to declare a constant value
since MLIR, unlike LLVM, does not support immediate values as operands. To
avoid confusion with actual LLVM operations, we prefix such axuiliary
operations with "mlir.".
PiperOrigin-RevId:
266942838
Smit Hinsu [Tue, 3 Sep 2019 06:43:36 +0000 (23:43 -0700)]
Support bf16 in Builder::getZeroAttr
PiperOrigin-RevId:
266863802
Mahesh Ravishankar [Tue, 3 Sep 2019 04:06:35 +0000 (21:06 -0700)]
Add Select operation to SPIR-V dialect.
The SelectOp models the semantics of OpSelect from SPIR-V spec.
PiperOrigin-RevId:
266849559
Smit Hinsu [Tue, 3 Sep 2019 02:59:08 +0000 (19:59 -0700)]
Enable OwningRewritePatternList insert overload with parameter pack only when
there is at least one template pattern type
Also remove the other insert overload with pattern pointer as there are no existing users nor any potential known use-case.
PiperOrigin-RevId:
266842920
River Riddle [Tue, 3 Sep 2019 02:24:47 +0000 (19:24 -0700)]
Refactor the pass manager to support operations other than FuncOp/ModuleOp.
This change generalizes the structure of the pass manager to allow arbitrary nesting pass managers for other operations, at any level. The only user visible change to existing code is the fact that a PassManager must now provide an MLIRContext on construction. A new class `OpPassManager` has been added that represents a pass manager on a specific operation type. `PassManager` will remain the top-level entry point into the pipeline, with OpPassManagers being nested underneath. OpPassManagers will still be implicitly nested if the operation type on the pass differs from the pass manager. To explicitly build a pipeline, the 'nest' methods on OpPassManager may be used:
// Pass manager for the top-level module.
PassManager pm(ctx);
// Nest a pipeline operating on FuncOp.
OpPassManager &fpm = pm.nest<FuncOp>();
fpm.addPass(...);
// Nest a pipeline under the FuncOp pipeline that operates on spirv::ModuleOp
OpPassManager &spvModulePM = pm.nest<spirv::ModuleOp>();
// Nest a pipeline on FuncOps inside of the spirv::ModuleOp.
OpPassManager &spvFuncPM = spvModulePM.nest<FuncOp>();
To help accomplish this a new general OperationPass is added that operates on opaque Operations. This pass can be inserted in a pass manager of any type to operate on any operation opaquely. An example of this opaque OperationPass is a VerifierPass, that simply runs the verifier opaquely on the current operation.
/// Pass to verify an operation and signal failure if necessary.
class VerifierPass : public OperationPass<VerifierPass> {
void runOnOperation() override {
Operation *op = getOperation();
if (failed(verify(op)))
signalPassFailure();
markAllAnalysesPreserved();
}
};
PiperOrigin-RevId:
266840344
River Riddle [Mon, 2 Sep 2019 03:06:42 +0000 (20:06 -0700)]
Add a new dialect interface for the OperationFolder `OpFolderDialectInterface`.
This interface will allow for providing hooks to interrop with operation folding. The first hook, 'shouldMaterializeInto', will allow for controlling which region to insert materialized constants into. The folder will generally materialize constants into the top-level isolated region, this allows for materializing into a lower level ancestor region if it is more profitable/correct.
PiperOrigin-RevId:
266702972
Mehdi Amini [Sun, 1 Sep 2019 23:31:40 +0000 (16:31 -0700)]
Add a `getUsedValuesDefinedAbove()` overload that takes an `Operation` pointer (NFC)
This is a convenient utility around the existing `getUsedValuesDefinedAbove()`
that take two regions.
PiperOrigin-RevId:
266686854
Mehdi Amini [Sun, 1 Sep 2019 23:15:14 +0000 (16:15 -0700)]
Add a convenient `clone()` method on the `Op` class that forward to the underlying `Operation` (NFC)
PiperOrigin-RevId:
266685852
Mehdi Amini [Sun, 1 Sep 2019 18:32:52 +0000 (11:32 -0700)]
Add missing lowering to CFG in mlir-cpu-runner + related cleanup
- the list of passes run by mlir-cpu-runner included -lower-affine and
-lower-to-llvm but was missing -lower-to-cfg (because -lower-affine at
some point used to lower straight to CFG); add -lower-to-cfg in
between. IR with affine ops can now be run by mlir-cpu-runner.
- update -lower-to-cfg to be consistent with other passes (create*Pass methods
were changed to return unique ptrs, but -lower-to-cfg appears to have been
missed).
- mlir-cpu-runner was unable to parse custom form of affine op's - fix
link options
- drop unnecessary run options from test/mlir-cpu-runner/simple.mlir
(none of the test cases had loops)
- -convert-to-llvmir was changed to -lower-to-llvm at some point, but the
create pass method name wasn't updated (this pass converts/lowers to LLVM
dialect as opposed to LLVM IR). Fix this.
(If we prefer "convert", the cmd-line options could be changed to
"-convert-to-llvm/cfg" then.)
Signed-off-by: Uday Bondhugula <uday@polymagelabs.com>
Closes tensorflow/mlir#115
PiperOrigin-RevId:
266666909
Mehdi Amini [Sat, 31 Aug 2019 22:23:31 +0000 (15:23 -0700)]
Add a link to the rational on lack of const for IR units in the developer guide
PiperOrigin-RevId:
266583374
Mehdi Amini [Sat, 31 Aug 2019 22:17:42 +0000 (15:17 -0700)]
Document that non-IR units are passed by non-const reference instead of pointer in general
PiperOrigin-RevId:
266583029
Mahesh Ravishankar [Sat, 31 Aug 2019 16:52:18 +0000 (09:52 -0700)]
Add floating-point comparison operations to SPIR-V dialect.
Use the existing SPV_LogicalOp specification to add the floating-point
comparison operations (both ordered and unordered versions).
To make it easier to import the op-definitions automatically modify
the dialect generation script to update the different .td files based
on whether the operation is an arithmetic op, logical op, etc. Also
allow specification of multiple opcodes with define_inst.sh.
Since this reuses the SPV_LogicalOp framework, no tests specific to
the floating point comparison ops are added with this CL.
PiperOrigin-RevId:
266561634
Lei Zhang [Sat, 31 Aug 2019 16:50:02 +0000 (09:50 -0700)]
Add missing link dependency to MLIRTableGenTests
PiperOrigin-RevId:
266561495
Uday Bondhugula [Sat, 31 Aug 2019 00:38:36 +0000 (17:38 -0700)]
update vim syntax file
- more highlighting: numbers, elemental types inside shaped types
- add some more keywords
Signed-off-by: Uday Bondhugula <uday@polymagelabs.com>
Closes tensorflow/mlir#110
COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/110 from bondhugula:vim
029777db0ecb95bfc6453c0869af1c233d84d521
PiperOrigin-RevId:
266487768
River Riddle [Fri, 30 Aug 2019 23:49:01 +0000 (16:49 -0700)]
Add a canonicalization to erase empty AffineForOps.
AffineForOp themselves are pure and can be removed if there are no internal operations.
PiperOrigin-RevId:
266481293
MLIR Team [Fri, 30 Aug 2019 22:40:51 +0000 (15:40 -0700)]
Splits DictionaryAttr into DictionaryAttrBase and DictionaryAttr.
This maintains consistency with other *AttrBase/Attr splits.
PiperOrigin-RevId:
266469869
Logan Chien [Fri, 30 Aug 2019 21:53:28 +0000 (14:53 -0700)]
Add TensorRankOf for ranked tensor types with specific ranks
This commit adds `TensorRankOf<types, typeNames, ranks>` to specify ranked
tensor types with the specified types and ranks. For example,
`TensorRankOf<[I32, F32], ["i32", "F32"], [0, 1]>` matches `tensor<i32>`,
`tensor<?xi32>`, `tensor<f32>`, or `tensor<?xf32>`.
PiperOrigin-RevId:
266461256
Rob Suderman [Fri, 30 Aug 2019 21:09:46 +0000 (14:09 -0700)]
Fix StructsGenTest.cpp CMakeFile build error
PiperOrigin-RevId:
266452719
River Riddle [Fri, 30 Aug 2019 20:16:13 +0000 (13:16 -0700)]
Generalize the pass hierarchy by adding a general OpPass<PassT, OpT>.
This pass class generalizes the current functionality between FunctionPass and ModulePass, and allows for operating on any operation type. The pass manager currently only supports OpPasses operating on FuncOp and ModuleOp, but this restriction will be relaxed in follow-up changes. A utility class OpPassBase<OpT> allows for generically referring to operation specific passes: e.g. FunctionPassBase == OpPassBase<FuncOp>.
PiperOrigin-RevId:
266442239
Jacques Pienaar [Fri, 30 Aug 2019 20:01:34 +0000 (13:01 -0700)]
Add mechanism to dump JIT-compiled objects to files
This commit introduces the bits to be able to dump JIT-compile
objects to external files by passing an object cache to OrcJit.
The new functionality is tested in mlir-cpu-runner under the flag
`dump-object-file`.
Closes tensorflow/mlir#95
PiperOrigin-RevId:
266439265
Rob Suderman [Fri, 30 Aug 2019 19:51:31 +0000 (12:51 -0700)]
Added a TableGen generator for structured data
Similar to enum, added a generator for structured data. This provide Dictionary that stores a fixed set of values and guarantees the values are valid. It is intended to store a fixed number of values by a given name.
PiperOrigin-RevId:
266437460
River Riddle [Fri, 30 Aug 2019 19:47:24 +0000 (12:47 -0700)]
Add support for early exit walk methods.
This is done by providing a walk callback that returns a WalkResult. This result is either `advance` or `interrupt`. `advance` means that the walk should continue, whereas `interrupt` signals that the walk should stop immediately. An example is shown below:
auto result = op->walk([](Operation *op) {
if (some_invariant)
return WalkResult::interrupt();
return WalkResult::advance();
});
if (result.wasInterrupted())
...;
PiperOrigin-RevId:
266436700
Lei Zhang [Fri, 30 Aug 2019 19:17:21 +0000 (12:17 -0700)]
Add spv.Branch and spv.BranchConditional
This CL just covers the op definition, its parsing, printing,
and verification. (De)serialization is to be implemented
in a subsequent CL.
PiperOrigin-RevId:
266431077
River Riddle [Fri, 30 Aug 2019 05:19:29 +0000 (22:19 -0700)]
Change the parseSource* methods to return OwningModuleRef instead of ModuleOp.
This avoids potential memory leaks from misuse of the API.
PiperOrigin-RevId:
266305750
River Riddle [Thu, 29 Aug 2019 20:04:22 +0000 (13:04 -0700)]
Refactor the 'walk' methods for operations.
This change refactors and cleans up the implementation of the operation walk methods. After this refactoring is that the explicit template parameter for the operation type is no longer needed for the explicit op walks. For example:
op->walk<AffineForOp>([](AffineForOp op) { ... });
is now accomplished via:
op->walk([](AffineForOp op) { ... });
PiperOrigin-RevId:
266209552
Jacques Pienaar [Thu, 29 Aug 2019 19:14:02 +0000 (12:14 -0700)]
Make dumping using generic form more robust when IR ill-formed
PiperOrigin-RevId:
266198057