platform/upstream/llvm.git
4 years agoAdd quant.const_fake_quant_per_axis op
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

4 years ago[NFC] Rename ExpressedToUniformQuantizedType to ExpressedToQuantizedType
Feng Liu [Mon, 9 Sep 2019 22:29:30 +0000 (15:29 -0700)]
[NFC] Rename ExpressedToUniformQuantizedType to ExpressedToQuantizedType

PiperOrigin-RevId: 268090906

4 years agoConvert per channel fake quant attributes to type
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

4 years agoExplicitly declare the OpPassManager move constructor to avoid undefined errors.
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

4 years agoOverload LLVM::TerminatorOp::build() for empty operands list.
MLIR Team [Mon, 9 Sep 2019 18:38:34 +0000 (11:38 -0700)]
Overload LLVM::TerminatorOp::build() for empty operands list.

PiperOrigin-RevId: 268041584

4 years agoAdd warpsize and laneid intrinsics to NVVM dialect.
MLIR Team [Mon, 9 Sep 2019 18:37:05 +0000 (11:37 -0700)]
Add warpsize and laneid intrinsics to NVVM dialect.

PiperOrigin-RevId: 268041263

4 years agoAdd support for coalescing adjacent nested pass pipelines.
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

4 years agoAddressing some late review comments on kernel inlining.
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

4 years agoAdd `parseGenericOperation()` to the OpAsmParser
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

4 years agoRefactor PassTiming to support nested pipelines.
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

4 years agoUse "final" instead of marking method virtual in override (NFC)
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

4 years agoRefactor getUsedValuesDefinedAbove to expose a variant taking a callback (NFC)
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

4 years agoSet mlir-cpu-runner JIT codegen opt level correctly
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

4 years agoWrap debug dump in LLVM_DEBUG
Mehdi Amini [Sat, 7 Sep 2019 15:53:24 +0000 (08:53 -0700)]
Wrap debug dump in LLVM_DEBUG

PiperOrigin-RevId: 267774506

4 years agoAdd doc for declarative rewrite rules
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

4 years agoFix typo in the documentation for tensor_cast (NFC)
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

4 years agoRestrict affine inlining to just Function operations.
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

4 years agoAdd custom builder for AffineIfOp
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

4 years agoSimplify Linalg ABI integration with external function calls.
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

4 years agoFix typos in Interfaces.md
Alex Zinenko [Fri, 6 Sep 2019 08:22:24 +0000 (01:22 -0700)]
Fix typos in Interfaces.md

PiperOrigin-RevId: 267548530

4 years agoInteger set + operands / affine if op canonicalization
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

4 years agoAdd support for conservatively inlining Affine operations.
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

4 years ago[spirv] Add spv.loop
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

4 years agoAdd the initial inlining infrastructure.
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

4 years agoMake GPU kernel outlining test independent of value names.
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

4 years agoGeneralize I32ElementsAttr definition and introduce I64ElementsAttr
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

4 years agoUse transform function on llvm::Module in the ExecutionEngine
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

4 years agoUpdated StructAttr to use the struct name for StorageType and ReturnType.
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

4 years agoRetain address space during MLIR > LLVM conversion.
MLIR Team [Wed, 4 Sep 2019 19:26:11 +0000 (12:26 -0700)]
Retain address space during MLIR > LLVM conversion.

PiperOrigin-RevId: 267206460

4 years agoMove LLVMIR dialect tests from test/LLVMIR to test/Dialect and test/Conversion
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

4 years agoMake isIsolatedAbove robuster to invalid IR
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

4 years agopipeline-data-transfer: remove dead tag alloc's and improve test coverage for replace...
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

4 years agoMove Linalg dialect tests to test/Dialect/Linalg
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

4 years agoMake GPU kernel outlining inline constants.
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

4 years agoAdd support for array-typed constants.
MLIR Team [Wed, 4 Sep 2019 10:45:38 +0000 (03:45 -0700)]
Add support for array-typed constants.

PiperOrigin-RevId: 267121729

4 years agoUpdate the syntax of splat attribute in LLVM.md
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

4 years agoMention clang-format in the developer guide
Alex Zinenko [Wed, 4 Sep 2019 09:42:50 +0000 (02:42 -0700)]
Mention clang-format in the developer guide

PiperOrigin-RevId: 267114122

4 years agoProperly clone Linalg ops with regions
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

4 years agoUtility to normalize memrefs with non-identity layout maps
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

4 years agoAdd folding rule and dialect materialization hook for spv.constant
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

4 years agoFix affine data copy generation corner cases/bugs
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

4 years ago Add information about the SIG + Open Design meetings to the README.
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

4 years agoFix an invalid assert when processing escaped strings.
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

4 years agoRemove unused variables
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

4 years agoLLVM dialect: prefix auxiliary operations with "mlir."
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

4 years agoSupport bf16 in Builder::getZeroAttr
Smit Hinsu [Tue, 3 Sep 2019 06:43:36 +0000 (23:43 -0700)]
Support bf16 in Builder::getZeroAttr

PiperOrigin-RevId: 266863802

4 years agoAdd Select operation to SPIR-V dialect.
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

4 years agoEnable OwningRewritePatternList insert overload with parameter pack only when
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

4 years agoRefactor the pass manager to support operations other than FuncOp/ModuleOp.
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

4 years agoAdd a new dialect interface for the OperationFolder `OpFolderDialectInterface`.
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

4 years agoAdd a `getUsedValuesDefinedAbove()` overload that takes an `Operation` pointer (NFC)
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

4 years agoAdd a convenient `clone()` method on the `Op` class that forward to the underlying...
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

4 years agoAdd missing lowering to CFG in mlir-cpu-runner + related cleanup
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

4 years agoAdd a link to the rational on lack of const for IR units in the developer guide
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

4 years agoDocument that non-IR units are passed by non-const reference instead of pointer in...
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

4 years agoAdd floating-point comparison operations to SPIR-V dialect.
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

4 years agoAdd missing link dependency to MLIRTableGenTests
Lei Zhang [Sat, 31 Aug 2019 16:50:02 +0000 (09:50 -0700)]
Add missing link dependency to MLIRTableGenTests

PiperOrigin-RevId: 266561495

4 years agoupdate vim syntax file
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

4 years agoAdd a canonicalization to erase empty AffineForOps.
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

4 years agoSplits DictionaryAttr into DictionaryAttrBase and DictionaryAttr.
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

4 years agoAdd TensorRankOf for ranked tensor types with specific ranks
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

4 years agoFix StructsGenTest.cpp CMakeFile build error
Rob Suderman [Fri, 30 Aug 2019 21:09:46 +0000 (14:09 -0700)]
Fix StructsGenTest.cpp CMakeFile build error

PiperOrigin-RevId: 266452719

4 years agoGeneralize the pass hierarchy by adding a general OpPass<PassT, OpT>.
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

4 years agoAdd mechanism to dump JIT-compiled objects to files
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

4 years agoAdded a TableGen generator for structured data
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

4 years agoAdd support for early exit walk methods.
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

4 years agoAdd spv.Branch and spv.BranchConditional
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

4 years agoChange the parseSource* methods to return OwningModuleRef instead of ModuleOp.
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

5 years agoRefactor the 'walk' methods for operations.
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

5 years agoMake dumping using generic form more robust when IR ill-formed
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

5 years agoAdd tests to verify 0.0 is quantized correctly
Feng Liu [Thu, 29 Aug 2019 17:08:46 +0000 (10:08 -0700)]
Add tests to verify 0.0 is quantized correctly

We should consider both signed and narrow_range cases.

PiperOrigin-RevId: 266167366

5 years agoExtend map canonicalization to propagate constant operands
Uday Bondhugula [Thu, 29 Aug 2019 08:13:01 +0000 (01:13 -0700)]
Extend map canonicalization to propagate constant operands

- extend canonicalizeMapAndOperands to propagate constant operands into
  the map's expressions (and thus drop those operands).
- canonicalizeMapAndOperands previously only dropped duplicate and
  unused operands; however, operands that were constants were
  retained.

This change makes IR maps/expressions generated by various
utilities/passes even simpler; also makes some of the test checks more
accurate and simpler -- for eg., 0' instead of symbol(%{{.*}}).

Signed-off-by: Uday Bondhugula <uday@polymagelabs.com>
Closes tensorflow/mlir#107

COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/107 from bondhugula:canonicalize-maps c889a51486d14fbf7db489f224f881e7e1ff7d72
PiperOrigin-RevId: 266085289

5 years agofix loop unroll and jam - operand mapping - imperfect nest case
Uday Bondhugula [Thu, 29 Aug 2019 06:42:17 +0000 (23:42 -0700)]
fix loop unroll and jam - operand mapping - imperfect nest case

- fix operand mapping while cloning sub-blocks to jam - was incorrect
  for imperfect nests where def/use was across sub-blocks
- strengthen/generalize the first test case to cover the previously
  missed scenario
- clean up the other cases while on this.

Previously, unroll-jamming the following nest
```
    affine.for %arg0 = 0 to 2048 {
      %0 = alloc() : memref<512x10xf32>
      affine.for %arg1 = 0 to 10 {
        %1 = affine.load %0[%arg0, %arg1] : memref<512x10xf32>
      }
      dealloc %0 : memref<512x10xf32>
    }
```

would yield

```
      %0 = alloc() : memref<512x10xf32>
      %1 = affine.apply #map0(%arg0)
      %2 = alloc() : memref<512x10xf32>
      affine.for %arg1 = 0 to 10 {
        %4 = affine.load %0[%arg0, %arg1] : memref<512x10xf32>
        %5 = affine.apply #map0(%arg0)
        %6 = affine.load %0[%5, %arg1] : memref<512x10xf32>
      }
      dealloc %0 : memref<512x10xf32>
      %3 = affine.apply #map0(%arg0)
      dealloc %0 : memref<512x10xf32>

```

instead of

```

module {
    affine.for %arg0 = 0 to 2048 step 2 {
      %0 = alloc() : memref<512x10xf32>
      %1 = affine.apply #map0(%arg0)
      %2 = alloc() : memref<512x10xf32>
      affine.for %arg1 = 0 to 10 {
        %4 = affine.load %0[%arg0, %arg1] : memref<512x10xf32>
        %5 = affine.apply #map0(%arg0)
        %6 = affine.load %2[%5, %arg1] : memref<512x10xf32>
      }
      dealloc %0 : memref<512x10xf32>
      %3 = affine.apply #map0(%arg0)
      dealloc %2 : memref<512x10xf32>
    }
```

Signed-off-by: Uday Bondhugula <uday@polymagelabs.com>
Closes tensorflow/mlir#98

COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/98 from bondhugula:ujam ddbc853f69b5608b3e8ff9b5ac1f6a5a0bb315a4
PiperOrigin-RevId: 266073460

5 years agoAdd verification for dimension attribute on GPUDialect index operations.
Stephan Herhut [Thu, 29 Aug 2019 06:39:20 +0000 (23:39 -0700)]
Add verification for dimension attribute on GPUDialect index operations.

PiperOrigin-RevId: 266073204

5 years agoAdd vim scripts for indent/syntax
Uday Bondhugula [Thu, 29 Aug 2019 06:22:39 +0000 (23:22 -0700)]
Add vim scripts for indent/syntax

- some of it has been adapted from LLVM's vim utils

Signed-off-by: Uday Bondhugula <uday@polymagelabs.com>
Closes tensorflow/mlir#90

COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/90 from bondhugula:vim 22b1c958818c4b09de0ec8e1d7a4893171a03dbf
PiperOrigin-RevId: 266071752

5 years agoFix the equality check of two floating point values
Feng Liu [Wed, 28 Aug 2019 23:39:18 +0000 (16:39 -0700)]
Fix the equality check of two floating point values

PiperOrigin-RevId: 266022088

5 years agoGeneralize the analysis manager framework to work on any operation at any nesting.
River Riddle [Wed, 28 Aug 2019 22:10:37 +0000 (15:10 -0700)]
Generalize the analysis manager framework to work on any operation at any nesting.

The pass manager is moving towards being able to run on operations at arbitrary nesting. An operation may have both parent and child operations, and the AnalysisManager must be able to handle this generalization. The AnalysisManager class now contains generic 'getCachedParentAnalysis' and 'getChildAnalysis/getCachedChildAnalysis' functions to query analyses on parent/child operations. This removes the hard coded nesting relationship between Module/Function.

PiperOrigin-RevId: 266003636

5 years agoTweak to the pretty type parser to recognize that `->` is a special token.
Eric Schweitz [Wed, 28 Aug 2019 20:55:11 +0000 (13:55 -0700)]
Tweak to the pretty type parser to recognize that `->` is a special token.

Tweak to the pretty type parser to recognize that `->` is a special token that
shouldn't be split into two characters.  This change allows dialect
types to wrap function types as in `!my.ptr_type<(i32) -> i32>`.

Closes tensorflow/mlir#105

COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/105 from schweitzpgi:parse-arrow 8b2d768053f419daae5a1a864121a44c4319acbe
PiperOrigin-RevId: 265986240

5 years agoAdd implementation for tensor_load and tensor_store operations.
Stephan Herhut [Wed, 28 Aug 2019 18:25:19 +0000 (11:25 -0700)]
Add implementation for tensor_load and tensor_store operations.

This change adds definitions, parsing and verification for both ops.

PiperOrigin-RevId: 265954051

5 years agoPort mlir-cuda-runner to use dialect conversion framework.
Stephan Herhut [Wed, 28 Aug 2019 08:50:28 +0000 (01:50 -0700)]
Port mlir-cuda-runner to use dialect conversion framework.

Instead of lowering the program in two steps (Standard->LLVM followed
by GPU->NVVM), leading to invalid IR inbetween, the runner now uses
one pattern based rewrite step to go directly from Standard+GPU to
LLVM+NVVM.

PiperOrigin-RevId: 265861934

5 years agoRefactor / improve replaceAllMemRefUsesWith
Uday Bondhugula [Wed, 28 Aug 2019 00:56:25 +0000 (17:56 -0700)]
Refactor / improve replaceAllMemRefUsesWith

Refactor replaceAllMemRefUsesWith to split it into two methods: the new
method does the replacement on a single op, and is used by the existing
one.

- make the methods return LogicalResult instead of bool

- Earlier, when replacement failed (due to non-deferencing uses of the
  memref), the set of ops that had already been processed would have
  been replaced leaving the IR in an inconsistent state. Now, a
  pass is made over all ops to first check for non-deferencing
  uses, and then replacement is performed. No test cases were affected
  because all clients of this method were first checking for
  non-deferencing uses before calling this method (for other reasons).
  This isn't true for a use case in another upcoming PR (scalar
  replacement); clients can now bail out with consistent IR on failure
  of replaceAllMemRefUsesWith. Add test case.

- multiple deferencing uses of the same memref in a single op is
  possible (we have no such use cases/scenarios), and this has always
  remained unsupported. Add an assertion for this.

- minor fix to another test pipeline-data-transfer case.

Signed-off-by: Uday Bondhugula <uday@polymagelabs.com>
Closes tensorflow/mlir#87

PiperOrigin-RevId: 265808183

5 years agoUpdate Ch.2 of the Toy tutorial.
River Riddle [Tue, 27 Aug 2019 19:43:55 +0000 (12:43 -0700)]
Update Ch.2 of the Toy tutorial.

The code and documentation for this chapter of the tutorial have been updated to follow the new flow. The toy 'array' type has been replaced by usages of the MLIR tensor type. The code has also been cleaned up and modernized.

Closes tensorflow/mlir#101

PiperOrigin-RevId: 265744086

5 years agoAdd 3 additional intrinsic ops to NVVM dialect, in preparation to implement block...
MLIR Team [Tue, 27 Aug 2019 17:55:47 +0000 (10:55 -0700)]
Add 3 additional intrinsic ops to NVVM dialect, in preparation to implement block-wide reduce.

PiperOrigin-RevId: 265720077

5 years ago[spirv] Fix the entry block to start with OpLabel
Lei Zhang [Tue, 27 Aug 2019 17:50:58 +0000 (10:50 -0700)]
[spirv] Fix the entry block to start with OpLabel

Each basic block in SPIR-V must start with an OpLabel instruction.
We don't support control flow yet, so this CL just makes sure that
the entry block follows this rule and is valid.

PiperOrigin-RevId: 265718841

5 years agoEnhance GPU To SPIR-V conversion to support builtins and load/store ops.
Mahesh Ravishankar [Tue, 27 Aug 2019 17:49:53 +0000 (10:49 -0700)]
Enhance GPU To SPIR-V conversion to support builtins and load/store ops.

To support a conversion of a simple load-compute-store kernel from GPU
dialect to SPIR-V dialect, the conversion of operations like
"gpu.block_dim", "gpu.thread_id" which allow threads to get the launch
conversion is needed. In SPIR-V these are specified as global
variables with builin attributes. This CL adds support to specify
builtin variables in SPIR-V conversion framework. This is used to
convert the relevant operations from GPU dialect to SPIR-V dialect.
Also add support for conversion of load/store operation in Standard
dialect to SPIR-V dialect.
To simplify the conversion add a method to build a spv.AccessChain
operation that automatically determines the return type based on the
base pointer type and the indices provided.

PiperOrigin-RevId: 265718525

5 years ago[spirv] Add Block decoration for spv.struct.
Denis Khalikov [Tue, 27 Aug 2019 17:41:07 +0000 (10:41 -0700)]
[spirv] Add Block decoration for spv.struct.

Add Block decoration for top-level spv.struct.

Closes tensorflow/mlir#102

PiperOrigin-RevId: 265716241

5 years agoNFC: Remove the explicit context from Operation::create and OperationState.
River Riddle [Tue, 27 Aug 2019 00:34:06 +0000 (17:34 -0700)]
NFC: Remove the explicit context from Operation::create and OperationState.

The context can easily be recovered from the Location in these situations.

PiperOrigin-RevId: 265578574

5 years agoAdd FPToSI/FPExt/FPTrunc cast ops to the LLVM dialect.
Eric Schweitz [Mon, 26 Aug 2019 21:18:47 +0000 (14:18 -0700)]
Add FPToSI/FPExt/FPTrunc cast ops to the LLVM dialect.

Closes tensorflow/mlir#99

PiperOrigin-RevId: 265538731

5 years agoNFC: Remove unnecessary context parameters from several Location getters.
River Riddle [Mon, 26 Aug 2019 20:53:22 +0000 (13:53 -0700)]
NFC: Remove unnecessary context parameters from several Location getters.

The context can be recovered by other means in these methods and doesn't need to be passed explicitly.

PiperOrigin-RevId: 265532956

5 years agoUpdate documentation for custom rewrite specs.
MLIR Team [Mon, 26 Aug 2019 17:27:38 +0000 (10:27 -0700)]
Update documentation for custom rewrite specs.

PiperOrigin-RevId: 265485862

5 years agoSupport folding of ops with inner ops in GreedyPatternRewriteDriver.
Andy Ly [Mon, 26 Aug 2019 16:44:09 +0000 (09:44 -0700)]
Support folding of ops with inner ops in GreedyPatternRewriteDriver.

This fixes a bug when folding ops with inner ops and inner ops are still being visited.

PiperOrigin-RevId: 265475780

5 years agoNFC: Add doc for id-punct
Alina Sbirlea [Sat, 24 Aug 2019 04:00:40 +0000 (21:00 -0700)]
NFC: Add doc for id-punct
PiperOrigin-RevId: 265190168

5 years agoNFC: Update Ch.1 of the Toy tutorial.
River Riddle [Sat, 24 Aug 2019 01:11:29 +0000 (18:11 -0700)]
NFC: Update Ch.1 of the Toy tutorial.

Change the use of 'array' to 'tensor' to reflect the new flow that the tutorial will follow. Also tidy up some of the documentation, code comments, and fix a few out-dated links.

PiperOrigin-RevId: 265174676

5 years agoLower linalg.copy to LLVM dialect in the presence of transposes.
Nicolas Vasilache [Sat, 24 Aug 2019 00:44:55 +0000 (17:44 -0700)]
Lower linalg.copy to LLVM dialect in the presence of transposes.

Add an extra RewritePattern that does not convert types to rewrite a CopyOp that has non-identity permutations into a sequence of TransposeOp followed by a CopyOp without such permutations.

This RewitePattern is made to fail in the non-permutation case so that the conversion pattern can kick in to lower to LLVM.

This is an instance of A->A->B lowering where A->A is done by a RewritePattern in case_1 and A->B is done by a ConversionPatternRewriter when not(case_1).

PiperOrigin-RevId: 265171380

5 years agoLower linalg.transpose to LLVM dialect
Nicolas Vasilache [Sat, 24 Aug 2019 00:28:51 +0000 (17:28 -0700)]
Lower linalg.transpose to LLVM dialect

Add a conversion pattern that transforms a linalg.transpose op into:
   1. A function entry `alloca` operation to allocate a ViewDescriptor.
   2. A load of the ViewDescriptor from the pointer allocated in 1.
   3. Updates to the ViewDescriptor to introduce the data ptr, offset, size
      and stride. Size and stride are permutations of the original values.
   4. A store of the resulting ViewDescriptor to the alloca'ed pointer.
The linalg.transpose op is replaced by the alloca'ed pointer.

PiperOrigin-RevId: 265169112

5 years agoAdd a linalg.transpose op
Nicolas Vasilache [Fri, 23 Aug 2019 21:47:46 +0000 (14:47 -0700)]
Add a linalg.transpose op

A linalg.transpose op is a pure metadata operation that takes a view + permutation map and produces
another view of the same underlying data, with a different reindexing. This is a
pure metadata operation that does not touch the underlying data.

Example:

```
  %t = linalg.transpose %v (i, j) -> (j, i) : !linalg.view<?x?xf32>
```

PiperOrigin-RevId: 265139429

5 years agoNFC: Add a note to 'applyPatternsGreedily' that it also performs folding/dce.
River Riddle [Fri, 23 Aug 2019 18:28:19 +0000 (11:28 -0700)]
NFC: Add a note to 'applyPatternsGreedily' that it also performs folding/dce.

Fixes tensorflow/mlir#72

PiperOrigin-RevId: 265097597

5 years agoAdd lowering of linalg.copy to an external C++ library and a test.
Nicolas Vasilache [Fri, 23 Aug 2019 18:08:59 +0000 (11:08 -0700)]
Add lowering of linalg.copy to an external C++ library and a test.

This CL extends support for lowering of linalg to external C++ libraries with CopyOp. Currently this can only work when the permutation maps in the copies are identity. Future support for permutations will be added later.

PiperOrigin-RevId: 265093025

5 years agoUpdate Linalg slice and subview documentation - NFC
Nicolas Vasilache [Fri, 23 Aug 2019 18:08:33 +0000 (11:08 -0700)]
Update Linalg slice and subview documentation - NFC

PiperOrigin-RevId: 265092922

5 years ago[spirv] NFC: move SPIR-V control flow ops to a separate file
Lei Zhang [Fri, 23 Aug 2019 18:07:13 +0000 (11:07 -0700)]
[spirv] NFC: move SPIR-V control flow ops to a separate file

This CL is also purely moving code around for better file organization.

PiperOrigin-RevId: 265092566