platform/upstream/llvm.git
5 years agoUse isa instead of dyn_cast as cast value isn't used.
Jacques Pienaar [Sun, 7 Jul 2019 21:04:46 +0000 (14:04 -0700)]
Use isa instead of dyn_cast as cast value isn't used.

Avoids unused variable warning.

PiperOrigin-RevId: 256874512

5 years agoMigrate NativeCodeCall and AllAttrConstraintsOf tests to use TestDialect
Lei Zhang [Fri, 5 Jul 2019 17:05:16 +0000 (10:05 -0700)]
Migrate NativeCodeCall and AllAttrConstraintsOf tests to use TestDialect

PiperOrigin-RevId: 256685260

5 years agoMigrate pattern attribute matching tests to use TestDialect
Lei Zhang [Fri, 5 Jul 2019 16:23:47 +0000 (09:23 -0700)]
Migrate pattern attribute matching tests to use TestDialect

This CL also reorders op definitions and tests a bit to make them
group more logically.

PiperOrigin-RevId: 256682105

5 years agoMove StdForOp to ODS ForOp
Nicolas Vasilache [Fri, 5 Jul 2019 12:04:53 +0000 (05:04 -0700)]
Move StdForOp to ODS ForOp

PiperOrigin-RevId: 256657155

5 years agoAdd a standard if op
Nicolas Vasilache [Fri, 5 Jul 2019 10:34:49 +0000 (03:34 -0700)]
Add a standard if op

This CL adds an "std.if" op to represent an if-then-else construct whose condition is an arbitrary value of type i1.
This is necessary to lower all the existing examples from affine and linalg to std.for + std.if.

This CL introduces the op and adds the relevant positive and negative unit test. Lowering will be done in a separate followup CL.

PiperOrigin-RevId: 256649138

5 years agoSimplify launch_func rewrite pattern in mlir-cuda-runner
Alex Zinenko [Fri, 5 Jul 2019 09:51:26 +0000 (02:51 -0700)]
Simplify launch_func rewrite pattern in mlir-cuda-runner

Use the bulk setOperands on the cloned operation, no need to cast or iterate
over the operand list.

PiperOrigin-RevId: 256643496

5 years agoODS: provide a flag to skip generation of default build methods
Alex Zinenko [Fri, 5 Jul 2019 09:27:39 +0000 (02:27 -0700)]
ODS: provide a flag to skip generation of default build methods

Some operations need to override the default behavior of builders, in
particular region-holding operations such as affine.for or tf.graph want to
inject default terminators into the region upon construction, which default
builders won't do.  Provide a flag that disables the generation of default
builders so that the custom builders could use the same function signatures.
This is an intentionally low-level and heavy-weight feature that requires the
entire builder to be implemented, and it should be used sparingly.  Injecting
code into the end of a default builder would depend on the naming scheme of the
default builder arguments that is not visible in the ODS.  Checking that the
signature of a custom builder conflicts with that of a default builder to
prevent emission would require teaching ODG to differentiate between types and
(optional) argument names in the generated C++ code.  If this flag ends up
being used a lot, we should consider adding traits that inject specific code
into the default builder.

PiperOrigin-RevId: 256640069

5 years agoAdd ODS accessors for named regions.
Nicolas Vasilache [Fri, 5 Jul 2019 09:20:38 +0000 (02:20 -0700)]
Add ODS accessors for named regions.

PiperOrigin-RevId: 256639471

5 years agoTrivial typo in comment fix.
Chris Lattner [Fri, 5 Jul 2019 05:17:42 +0000 (22:17 -0700)]
Trivial typo in comment fix.

PiperOrigin-RevId: 256616187

5 years agoNFC: Remove Region::getContainingFunction as Functions are now Operations.
River Riddle [Thu, 4 Jul 2019 20:22:42 +0000 (13:22 -0700)]
NFC: Remove Region::getContainingFunction as Functions are now Operations.

PiperOrigin-RevId: 256579717

5 years agoFix another incorrect forward declaration of LogicalResult
Alex Zinenko [Thu, 4 Jul 2019 20:05:28 +0000 (13:05 -0700)]
Fix another incorrect forward declaration of LogicalResult

LogicalResult is a struct and the Windows build is unhappy about it being
forward-declared as class.

PiperOrigin-RevId: 256578230

5 years agoForward-declare LogicalResult as struct
Alex Zinenko [Thu, 4 Jul 2019 17:16:39 +0000 (10:16 -0700)]
Forward-declare LogicalResult as struct

LogicalResult is a struct but some headers forward-declare it as a class, which
breaks Windows builds.  Forward-delcare as a struct instead.

PiperOrigin-RevId: 256565699

5 years agoMake TranslateFromMLIRFunction type return LogicalResult instead of bool
Alex Zinenko [Thu, 4 Jul 2019 15:18:45 +0000 (08:18 -0700)]
Make TranslateFromMLIRFunction type return LogicalResult instead of bool

This interface was created before MLIR introduced LogicalResult.

PiperOrigin-RevId: 256554557

5 years agoAdd an mlir-cuda-runner tool.
Stephan Herhut [Thu, 4 Jul 2019 14:49:52 +0000 (07:49 -0700)]
Add an mlir-cuda-runner tool.

This tool allows to execute MLIR IR snippets written in the GPU dialect
on a CUDA capable GPU. For this to work, a working CUDA install is required
and the build has to be configured with MLIR_CUDA_RUNNER_ENABLED set to 1.

PiperOrigin-RevId: 256551415

5 years agoAllocOp: drop redundant verifier check
Alex Zinenko [Thu, 4 Jul 2019 14:47:34 +0000 (07:47 -0700)]
AllocOp: drop redundant verifier check

The equality check between the rank of a memref and the input size of the
layout affine map in AllocOp::verify is subsumed by the well-formedness check
of the memref type itself.  Drop the redundant check from the verifier since it
is never exercised (the type builder does not allow one to construct a type
that would not pass the verifier check).

PiperOrigin-RevId: 256551247

5 years agoAdd missing mlir:: namespace in definition of createConvertToLLVMIRPass.
Stephan Herhut [Thu, 4 Jul 2019 14:02:25 +0000 (07:02 -0700)]
Add missing mlir:: namespace in definition of createConvertToLLVMIRPass.

PiperOrigin-RevId: 256546769

5 years agoMake ConvertStandardToLLVMPass extendable with other patterns
Alex Zinenko [Thu, 4 Jul 2019 11:41:02 +0000 (04:41 -0700)]
Make ConvertStandardToLLVMPass extendable with other patterns

Extend the LLVM lowering pass to accept callbacks that construct an instance of
(a subclass of) LLVMTypeConverter and populate a list of conversion patterns.
These callbacks will be called when the pass processes a module and their
results will be used to set up the dialect conversion infrastructure.  Clients
can now provide additional conversion patterns to avoid the need of
materializing type conversions between LLVM and other types.

PiperOrigin-RevId: 256532415

5 years agoNFC: Refactoring to remove code bloat in SPIRV due to handling of Enum
Mahesh Ravishankar [Thu, 4 Jul 2019 01:12:52 +0000 (18:12 -0700)]
NFC: Refactoring to remove code bloat in SPIRV due to handling of Enum
Class Attribute parsing

PiperOrigin-RevId: 256471248

5 years ago[TableGen] Support creating multi-result ops in result patterns
Lei Zhang [Thu, 4 Jul 2019 00:17:33 +0000 (17:17 -0700)]
[TableGen] Support creating multi-result ops in result patterns

This CL introduces a new syntax for creating multi-result ops and access their
results in result patterns. Specifically, if a multi-result op is unbound or
bound to a name without a trailing `__N` suffix, it will act as a value pack
and expand to all its values. If a multi-result op is bound to a symbol with
`__N` suffix, only the N-th result will be extracted and used.

PiperOrigin-RevId: 256465208

5 years agoReplace the implementation of Function and Module with FuncOp and ModuleOp.
River Riddle [Wed, 3 Jul 2019 20:21:24 +0000 (13:21 -0700)]
Replace the implementation of Function and Module with FuncOp and ModuleOp.

This is an important step in allowing for the top-level of the IR to be extensible. FuncOp and ModuleOp contain all of the necessary functionality, while using the existing operation infrastructure. As an interim step, many of the usages of Function and Module, including the name, will remain the same. In the future, many of these will be relaxed to allow for many different types of top-level operations to co-exist.

PiperOrigin-RevId: 256427100

5 years agoGlobally change load/store/dma_start/dma_wait operations over to affine.load/store...
Andy Davis [Wed, 3 Jul 2019 17:35:03 +0000 (10:35 -0700)]
Globally change load/store/dma_start/dma_wait operations over to affine.load/store/dma_start/dma_wait.
In most places, this is just a name change (with the exception of affine.dma_start swapping the operand positions of its tag memref and num_elements operands).
Significant code changes occur here:
*) Vectorization: LoopAnalysis.cpp, Vectorize.cpp
*) Affine Transforms: Transforms/Utils/Utils.cpp

PiperOrigin-RevId: 256395088

5 years agoMore general subview calculation in tiling
Nicolas Vasilache [Wed, 3 Jul 2019 12:05:05 +0000 (05:05 -0700)]
More general subview calculation in tiling

This CL refactors tiling to enable tiling of views that are not just specified by a simple permutation. This allows the tiling of convolutions for which a new example is added.

PiperOrigin-RevId: 256346028

5 years agoAdd a generic loop abstraction to the std dialect
Nicolas Vasilache [Wed, 3 Jul 2019 09:56:37 +0000 (02:56 -0700)]
Add a generic loop abstraction to the std dialect

This CL is the first step of a refactoring unification of the control flow abstraction used in different dialects. The `std.for` loop accepts unrestricted indices to encode min, max and step and will be used as a common abstraction on the way to lower level dialects.

PiperOrigin-RevId: 256331795

5 years agoNFC: Allow clearing the functions of a Module and splicing the functions from other...
River Riddle [Wed, 3 Jul 2019 01:32:34 +0000 (18:32 -0700)]
NFC: Allow clearing the functions of a Module and splicing the functions from other modules.

PiperOrigin-RevId: 256280543

5 years agoAdd support for getting and setting the dialect attributes of an operation.
River Riddle [Wed, 3 Jul 2019 01:24:58 +0000 (18:24 -0700)]
Add support for getting and setting the dialect attributes of an operation.

This allows for handling dialect attributes, those with names starting with a dialect prefix, to be handled explicitly.

PiperOrigin-RevId: 256279728

5 years agoAdd a 'getOps<>' method to Block to only iterate operations of a certain kind.
River Riddle [Wed, 3 Jul 2019 01:05:04 +0000 (18:05 -0700)]
Add a 'getOps<>' method to Block to only iterate operations of a certain kind.

PiperOrigin-RevId: 256277436

5 years agoNFC: Move Standard to SPIR-V conversion to lib/Conversion
Lei Zhang [Wed, 3 Jul 2019 00:22:21 +0000 (17:22 -0700)]
NFC: Move Standard to SPIR-V conversion to lib/Conversion

PiperOrigin-RevId: 256271759

5 years agoNFC: Move the Function/Module/Operation::verify methods out-of-line.
River Riddle [Tue, 2 Jul 2019 22:00:38 +0000 (15:00 -0700)]
NFC: Move the Function/Module/Operation::verify methods out-of-line.

As Functions/Modules becomes operations, these methods will conflict with the 'verify' hook already on derived operation types.

PiperOrigin-RevId: 256246112

5 years agoAdd support for promoting Linalg views into new buffers.
Nicolas Vasilache [Tue, 2 Jul 2019 21:17:30 +0000 (14:17 -0700)]
Add support for promoting Linalg views into new buffers.

This CL uses the generic CopyOp to promote a subview (constructed during tiling) into a new buffer + copy by:
  1. Creating a new buffer for the subview.
  2. Taking a view into the buffer and copying into it.
  3. Adapting the linalg op to operating on the view from point 2.
Tiling is extended with a boolean flag to enable promoting views (all or nothing for now).

More specifically, the current implementation creates a buffer that is always of the full size of the ranges of the subview. This produces a buffer whose size may be bigger
than the actual size of the `subView` at the boundaries and is related to the full/partial tile problem.

In practice, we introduce a `buffer`, a `fullLocalView` and a `partialLocalView` such that:
  * `buffer` is always the size of the subview in the full tile case.
  * `fullLocalView` is a dense contiguous view into that buffer.
  * `partialLocalView` is a dense non-contiguous slice of `fullLocalView`
     that corresponds to the size of `subView` and accounting for boundary
     effects.
The point of the full tile buffer is that constant static tile sizes are
folded and result in a buffer type with statically known size and alignment
properties.

Padding is introduced on the boundary tiles with a `fill` op followed by a partial `copy` op.

These behaviors will be refined later, on a per-need basis.

PiperOrigin-RevId: 256237319

5 years agoAdd support for SPIR-V Struct Types. Current support is limited to
Mahesh Ravishankar [Tue, 2 Jul 2019 19:30:34 +0000 (12:30 -0700)]
Add support for SPIR-V Struct Types. Current support is limited to
supporting only Offset decorations

PiperOrigin-RevId: 256216704

5 years ago[spirv] Various small improvements
Lei Zhang [Tue, 2 Jul 2019 18:19:22 +0000 (11:19 -0700)]
[spirv] Various small improvements

* Added comments
* Improved op creation
* Used LogicalResult where suitable

PiperOrigin-RevId: 256203068

5 years agoNFC: Refactor Module to be value typed.
River Riddle [Tue, 2 Jul 2019 17:49:17 +0000 (10:49 -0700)]
NFC: Refactor Module to be value typed.

As with Functions, Module will soon become an operation, which are value-typed. This eases the transition from Module to ModuleOp. A new class, OwningModuleRef is provided to allow for owning a reference to a Module, and will auto-delete the held module on destruction.

PiperOrigin-RevId: 256196193

5 years agodocs: minor spelling tweaks
Brett Koonce [Sat, 20 Apr 2019 01:15:44 +0000 (18:15 -0700)]
docs: minor spelling tweaks

Close tensorflow/mlir#23

5 years agoResolving buffer operand of linalg.view doesnt have the information
Mahesh Ravishankar [Tue, 2 Jul 2019 17:13:34 +0000 (10:13 -0700)]
Resolving buffer operand of linalg.view doesnt have the information
about the buffer size. This is needed to resolve the operand
correctly. Add that information to view op
serialization/deserialization

Also modify the parsing of buffer type by splitting at 'x' to
side-step issues with StringRef number parsing.

PiperOrigin-RevId: 256188319

5 years agoUpdate readme to reflect accepting contributions.
Jacques Pienaar [Tue, 2 Jul 2019 15:39:46 +0000 (08:39 -0700)]
Update readme to reflect accepting contributions.

PiperOrigin-RevId: 256171145

5 years ago[ODS] NFC: Rename EnumAttr to StrEnumAttr to be consistent with IntEnumAttr
Lei Zhang [Tue, 2 Jul 2019 15:27:32 +0000 (08:27 -0700)]
[ODS] NFC: Rename EnumAttr to StrEnumAttr to be consistent with IntEnumAttr

PiperOrigin-RevId: 256169019

5 years ago[spirv] Use I32EnumAttr for enum attributes
Lei Zhang [Tue, 2 Jul 2019 13:02:20 +0000 (06:02 -0700)]
[spirv] Use I32EnumAttr for enum attributes

This saves us the excessive string conversions and comparisons in
verification and transformation and scopes them only to parsing
and printing, which are meant for I/O so string conversions should
be fine.

In order to do this, changed the custom assembly format of
spv.module regarding addressing model and memory model.

PiperOrigin-RevId: 256149856

5 years agoNFC: Update the Operation 'walk' methods to use llvm::function_ref instead of std...
River Riddle [Tue, 2 Jul 2019 05:35:06 +0000 (22:35 -0700)]
NFC: Update the Operation 'walk' methods to use llvm::function_ref instead of std::function.

PiperOrigin-RevId: 256099638

5 years agoNFC: Add several utilities to OpState.
River Riddle [Tue, 2 Jul 2019 05:15:13 +0000 (22:15 -0700)]
NFC: Add several utilities to OpState.

* 'walk' functionality.
* Method to set the location.
* 'dump'/'print' methods.
* Method to set the attributes.

PiperOrigin-RevId: 256097960

5 years agoEnumsGen: remove dangling assertion
Lei Zhang [Tue, 2 Jul 2019 03:56:13 +0000 (20:56 -0700)]
EnumsGen: remove dangling assertion

StringAttr-backed enum attribute cases changed to allow explicit values,
But this assertion was not deleted.

Fixes https://github.com/tensorflow/mlir/issues/39

PiperOrigin-RevId: 256090793

5 years agoUpdate variable naming to match LLVM coding style.
Jacques Pienaar [Tue, 2 Jul 2019 00:40:40 +0000 (17:40 -0700)]
Update variable naming to match LLVM coding style.

Update to follow enumerators naming style
https://llvm.org/docs/CodingStandards.html#name-types-functions-variables-and-enumerators-properly
this also avoids the mach/boolean.h macros.

PiperOrigin-RevId: 256069831

5 years agogpu::LaunchOp: canonicalize away constant kernel arguments
Alex Zinenko [Mon, 1 Jul 2019 21:38:02 +0000 (14:38 -0700)]
gpu::LaunchOp: canonicalize away constant kernel arguments

The GPU Launch operation may take constants as arguments, in particular
affine-to-GPU mapping pass automatically forwards potentially constant lower
bounds of loops into the kernel.  Define a canonicalization pattern for
LaunchOp that recreates the constants inside the kernel region instead of
accepting them as kernel arguments.  This is currently restricted to standard
constants but may be extended to other constant operations.

Also fix an off-by-one indexing bug in OperandStorage::eraseOperand.

PiperOrigin-RevId: 256035437

5 years agoGeneralize the CFG graph printing for Functions to work on Regions instead.
River Riddle [Mon, 1 Jul 2019 21:10:52 +0000 (14:10 -0700)]
Generalize the CFG graph printing for Functions to work on Regions instead.

PiperOrigin-RevId: 256029944

5 years agoStandardize the definition and usage of getAllArgAttrs between FuncOp and Function.
River Riddle [Mon, 1 Jul 2019 17:53:31 +0000 (10:53 -0700)]
Standardize the definition and usage of getAllArgAttrs between FuncOp and Function.

PiperOrigin-RevId: 255988352

5 years agoNFC: Refactor Function to be value typed.
River Riddle [Mon, 1 Jul 2019 17:29:09 +0000 (10:29 -0700)]
NFC: Refactor Function to be value typed.

Move the data members out of Function and into a new impl storage class 'FunctionStorage'. This allows for Function to become value typed, which will greatly simplify the transition of Function to FuncOp(given that FuncOp is also value typed).

PiperOrigin-RevId: 255983022

5 years agoUpdate the 1->N legalizer test to use "test.return" so that the conversion cast is...
River Riddle [Mon, 1 Jul 2019 17:12:33 +0000 (10:12 -0700)]
Update the 1->N legalizer test to use "test.return" so that the conversion cast is elided properly.

PiperOrigin-RevId: 255979732

5 years agoTypeConversion: do not materialize conversion of the type to itself
Alex Zinenko [Mon, 1 Jul 2019 16:52:53 +0000 (09:52 -0700)]
TypeConversion: do not materialize conversion of the type to itself

Type conversion does not necessarily affect all types, some of them may remain
untouched.  The type conversion tool from the dialect conversion framework will
unconditionally insert a temporary cast operation from the type to itself
anyway, and will try to materialize it to a real conversion operation if there
are remaining uses.  Simply use the original value instead.

PiperOrigin-RevId: 255975450

5 years agoRun FileCheck on test-legalizer.mlir
Alex Zinenko [Mon, 1 Jul 2019 16:49:31 +0000 (09:49 -0700)]
Run FileCheck on test-legalizer.mlir

The RUN line was missing a call to FileCheck making the test always pass.  Add
the call to FileCheck and temporarily disable one of the tests that does not
produce the expected result.

PiperOrigin-RevId: 255974805

5 years agoAdd affine-to-standard lowerings for affine.load/store/dma_start/dma_wait.
Andy Davis [Mon, 1 Jul 2019 15:32:44 +0000 (08:32 -0700)]
Add affine-to-standard lowerings for affine.load/store/dma_start/dma_wait.

PiperOrigin-RevId: 255960171

5 years agoAlso disable generating underlying value to symbol conversion declaration when there...
Lei Zhang [Mon, 1 Jul 2019 14:30:23 +0000 (07:30 -0700)]
Also disable generating underlying value to symbol conversion declaration when there is an enumerant without explicit value

PiperOrigin-RevId: 255950779

5 years agoAvoid generating underlying value to symbol conversion function if there is an enumer...
Lei Zhang [Mon, 1 Jul 2019 13:51:39 +0000 (06:51 -0700)]
Avoid generating underlying value to symbol conversion function if there is an enumerant without explicit value.

PiperOrigin-RevId: 255945801

5 years ago[ODS] Introduce IntEnumAttr
Lei Zhang [Mon, 1 Jul 2019 12:26:14 +0000 (05:26 -0700)]
[ODS] Introduce IntEnumAttr

In ODS, right now we use StringAttrs to emulate enum attributes. It is
suboptimal if the op actually can and wants to store the enum as a
single integer value; we are paying extra cost on storing and comparing
the attribute value.

This CL introduces a new enum attribute subclass that are backed by
IntegerAttr. The downside with IntegerAttr-backed enum attributes is
that the assembly form now uses integer values, which is less obvious
than the StringAttr-backed ones. However, that can be remedied by
defining custom assembly form with the help of the conversion utility
functions generated via EnumsGen.

Choices are given to the dialect writers to decide which one to use for
their enum attributes.

PiperOrigin-RevId: 255935542

5 years agoAdd a folder-based EDSC intrinsics constructor (NFC)
Nicolas Vasilache [Mon, 1 Jul 2019 08:31:15 +0000 (01:31 -0700)]
Add a folder-based EDSC intrinsics constructor (NFC)

PiperOrigin-RevId: 255908660

5 years agoExpose AffineToGPUPass for use with PassManager
Alex Zinenko [Mon, 1 Jul 2019 07:47:58 +0000 (00:47 -0700)]
Expose AffineToGPUPass for use with PassManager

Originally, AffineToGPUPass was created and registered in the source file
mainly for testing purposes.  Provide a factory function that constructs
AffineToGPU pass to make it usable in pass pipelines.

PiperOrigin-RevId: 255902831

5 years agoExtract the automatic function renaming and symbol table out of Module.
River Riddle [Sun, 30 Jun 2019 17:44:07 +0000 (10:44 -0700)]
Extract the automatic function renaming and symbol table out of Module.

This functionality is now moved to a new class, ModuleManager. This class allows for inserting functions into a module, and will auto-rename them on insert to ensure a unique name. This now means that users adding new functions to a module must ensure that the function name is unique, as the Module will no longer do it automatically. This also means that Module::getNamedFunction now operates in O(N) instead of the O(c) time it did before. This simplifies the move of Modules to Operations as the ModuleOp will not be able to have this functionality.

PiperOrigin-RevId: 255846088

5 years agoMove BufferAllocOp and BufferDeallocOp to ODS
Nicolas Vasilache [Sun, 30 Jun 2019 14:07:50 +0000 (07:07 -0700)]
Move BufferAllocOp and BufferDeallocOp to ODS

This CL also fixes a parsing issue in the BufferType, adds LLVM lowering support for handling the static constant buffer size and a roundtrip test.

PiperOrigin-RevId: 255834356

5 years agoMerge pull request tensorflow/mlir#37 from tensorflow:jpienaar-patch-1
jpienaar [Mon, 1 Jul 2019 16:54:15 +0000 (09:54 -0700)]
Merge pull request tensorflow/mlir#37 from tensorflow:jpienaar-patch-1

PiperOrigin-RevId: 255769524

5 years agoUpdate link to presentation
jpienaar [Sat, 29 Jun 2019 01:06:45 +0000 (18:06 -0700)]
Update link to presentation

5 years agoInternal change
Jacques Pienaar [Sat, 29 Jun 2019 00:52:48 +0000 (17:52 -0700)]
Internal change

PiperOrigin-RevId: 255700627

5 years agoMerge pull request tensorflow/mlir#36 from pkanwar23:patch-2
A. Unique TensorFlower [Sat, 29 Jun 2019 00:59:58 +0000 (17:59 -0700)]
Merge pull request tensorflow/mlir#36 from pkanwar23:patch-2

PiperOrigin-RevId: 255694478

5 years agoUpdate CONTRIBUTING.md
pkanwar23 [Fri, 28 Jun 2019 23:44:32 +0000 (16:44 -0700)]
Update CONTRIBUTING.md

Co-Authored-By: Mehdi Amini <joker.eph@gmail.com>
5 years agoUpdate CONTRIBUTING.md
pkanwar23 [Fri, 28 Jun 2019 22:11:04 +0000 (15:11 -0700)]
Update CONTRIBUTING.md

5 years agoUpdate CONTRIBUTING.md
pkanwar23 [Fri, 28 Jun 2019 22:05:13 +0000 (15:05 -0700)]
Update CONTRIBUTING.md

5 years agoUpdate CONTRIBUTING.md
pkanwar23 [Fri, 28 Jun 2019 22:00:57 +0000 (15:00 -0700)]
Update CONTRIBUTING.md

5 years agoAdd new operations affine.dma_start and affine.dma_wait which take affine maps for...
Andy Davis [Fri, 28 Jun 2019 20:31:31 +0000 (13:31 -0700)]
Add new operations affine.dma_start and affine.dma_wait which take affine maps for indexing memrefs by construction.
These ops are analogues of the current standard ops dma_start/wait, with the exception that the memref operands are affine expressions of loop IVs and symbols (analogous to affine.load/store).
The addition of these operations will enable changes to affine transformation and analysis passes which operate on memory dereferencing operations.

PiperOrigin-RevId: 255658382

5 years agoUpdate CONTRIBUTING.md
pkanwar23 [Fri, 28 Jun 2019 19:51:30 +0000 (12:51 -0700)]
Update CONTRIBUTING.md

5 years ago[spirv] Move conversion passes to a new library
Lei Zhang [Fri, 28 Jun 2019 19:31:38 +0000 (12:31 -0700)]
[spirv] Move conversion passes to a new library

PiperOrigin-RevId: 255648303

5 years agoRefactor DialectConversion to use 'materializeConversion' when a type conversion...
River Riddle [Fri, 28 Jun 2019 18:28:30 +0000 (11:28 -0700)]
Refactor DialectConversion to use 'materializeConversion' when a type conversion must persist after the conversion has finished.

During conversion, if a type conversion has dangling uses a type conversion must persist after conversion has finished to maintain valid IR. In these cases, we now query the TypeConverter to materialize a conversion for us. This allows for the default case of a full conversion to continue working as expected, but also handle the degenerate cases more robustly.

PiperOrigin-RevId: 255637171

5 years agoAdd buffer size information to Linalg::BufferType. If the size is
Mahesh Ravishankar [Fri, 28 Jun 2019 16:59:22 +0000 (09:59 -0700)]
Add buffer size information to Linalg::BufferType. If the size is
constant then it is represented as <size x elementType>. If the size
is not a compile time constant, then it is represented as
<? x elementType>.

PiperOrigin-RevId: 255619400

5 years agoRespect the user provided type when parsing StringAttr.
River Riddle [Fri, 28 Jun 2019 03:48:53 +0000 (20:48 -0700)]
Respect the user provided type when parsing StringAttr.

PiperOrigin-RevId: 255532918

5 years agoUpdate cmake depedency.
Jacques Pienaar [Fri, 28 Jun 2019 03:48:04 +0000 (20:48 -0700)]
Update cmake depedency.

PiperOrigin-RevId: 255532863

5 years agoReturn an error when parseType doesnt parse the entire string passed
Mahesh Ravishankar [Thu, 27 Jun 2019 23:46:24 +0000 (16:46 -0700)]
Return an error when parseType doesnt parse the entire string passed

PiperOrigin-RevId: 255505300

5 years agoCleanup the 'clone' methods and remove the need to explicitly pass in the context.
River Riddle [Thu, 27 Jun 2019 23:42:50 +0000 (16:42 -0700)]
Cleanup the 'clone' methods and remove the need to explicitly pass in the context.

This also adds a new 'Region::cloneInto' method that accepts an insertion position.

PiperOrigin-RevId: 255504640

5 years agoParenthesize match expression to avoid operator precedence issues
MLIR Team [Thu, 27 Jun 2019 17:56:37 +0000 (10:56 -0700)]
Parenthesize match expression to avoid operator precedence issues

PiperOrigin-RevId: 255435454

5 years agoAllow attaching a type to StringAttr.
River Riddle [Thu, 27 Jun 2019 16:12:19 +0000 (09:12 -0700)]
Allow attaching a type to StringAttr.

Some dialects allow for string types, and this allows for reusing StringAttr for constants of these types.

PiperOrigin-RevId: 255413948

5 years agoFix incorrect type used in forward declaration.
Jacques Pienaar [Thu, 27 Jun 2019 15:38:49 +0000 (08:38 -0700)]
Fix incorrect type used in forward declaration.

Addresses compiler warning.

PiperOrigin-RevId: 255407691

5 years agoSupport parsing MLIR source from stdin.
MLIR Team [Thu, 27 Jun 2019 02:56:42 +0000 (19:56 -0700)]
Support parsing MLIR source from stdin.

PiperOrigin-RevId: 255316118

5 years agoAdd a new AttributeElementIterator to DenseElementsAttr.
River Riddle [Thu, 27 Jun 2019 01:49:50 +0000 (18:49 -0700)]
Add a new AttributeElementIterator to DenseElementsAttr.

This allows for iterating over the internal elements via an iterator_range of Attribute, and also allows for removing the final SmallVectorImpl based 'getValues' method.

PiperOrigin-RevId: 255309555

5 years agoStandardize and refactor Attribute type printing.
River Riddle [Thu, 27 Jun 2019 01:29:25 +0000 (18:29 -0700)]
Standardize and refactor Attribute type printing.

Remove the ability to print an attribute without a type, but allow for attributes to elide the type under certain circumstances. This fixes a bug where attributes within ArrayAttr, and other collection attributes, would never print the type.

PiperOrigin-RevId: 255306974

5 years agoSplit out TranslateClParser and add new parse method that reuses SourceMgr.
Jacques Pienaar [Wed, 26 Jun 2019 18:12:40 +0000 (11:12 -0700)]
Split out TranslateClParser and add new parse method that reuses SourceMgr.

Split out class to command line parser for translate methods into standalone
class. Similar to splitting up mlir-opt to reuse functionality with different
initialization.

PiperOrigin-RevId: 255225790

5 years agoAdd a pass that inserts getters for all cubins found via nvvm.cubin
Stephan Herhut [Wed, 26 Jun 2019 12:32:46 +0000 (05:32 -0700)]
Add a pass that inserts getters for all cubins found via nvvm.cubin
annotations.

Getters are required as there are currently no global constants in MLIR and this
is an easy way to unblock CUDA execution while waiting for those.

PiperOrigin-RevId: 255169002

5 years agoMake GPU to CUDA transformations independent of CUDA runtime.
Stephan Herhut [Wed, 26 Jun 2019 12:16:11 +0000 (05:16 -0700)]
Make GPU to CUDA transformations independent of CUDA runtime.

The actual transformation from PTX source to a CUDA binary is now factored out,
enabling compiling and testing the transformations independently of a CUDA
runtime.

MLIR has still to be built with NVPTX target support for the conversions to be
built and tested.

PiperOrigin-RevId: 255167139

5 years agoMove the emitError/Warning/Remark utility methods out of MLIRContext and into the...
River Riddle [Wed, 26 Jun 2019 04:31:54 +0000 (21:31 -0700)]
Move the emitError/Warning/Remark utility methods out of MLIRContext and into the mlir namespace.

Now that Locations are attributes, they have direct access to the MLIR context. This allows for simplifying error emission by removing unnecessary context lookups.

PiperOrigin-RevId: 255112791

5 years agoChange the attribute dictionary syntax to separate name and value with '='.
River Riddle [Wed, 26 Jun 2019 02:06:06 +0000 (19:06 -0700)]
Change the attribute dictionary syntax to separate name and value with '='.

The current syntax separates the name and value with ':', but ':' is already overloaded by several other things(e.g. trailing types). This makes the syntax difficult to parse in some situtations:

Old:
  "foo: 10 : i32"

New:
  "foo = 10 : i32"
PiperOrigin-RevId: 255097928

5 years agoNFC: Uniformize the return of the LocationAttr 'get' methods to 'Location'.
River Riddle [Tue, 25 Jun 2019 23:57:32 +0000 (16:57 -0700)]
NFC: Uniformize the return of the LocationAttr 'get' methods to 'Location'.

PiperOrigin-RevId: 255078768

5 years agoModify the syntax of the the ElementsAttrs to print the type as a colon type.
River Riddle [Tue, 25 Jun 2019 23:06:13 +0000 (16:06 -0700)]
Modify the syntax of the the ElementsAttrs to print the type as a colon type.

This is the standard syntax for types on operations, and is also already used by IntegerAttr and FloatAttr.

Example:
  dense<5> : tensor<i32>
  dense<[3]> : tensor<1xi32>
PiperOrigin-RevId: 255069157

5 years agoFix typo in Toy tutorial documentation
Rasmus Munk Larsen [Tue, 25 Jun 2019 21:59:40 +0000 (14:59 -0700)]
Fix typo in Toy tutorial documentation

PiperOrigin-RevId: 255054639

5 years agoFix unclear sentence.
Rasmus Munk Larsen [Tue, 25 Jun 2019 19:23:28 +0000 (12:23 -0700)]
Fix unclear sentence.

PiperOrigin-RevId: 255022564

5 years agoMove the IndexedAccessorIterator to STLExtras to allow for reuse.
River Riddle [Tue, 25 Jun 2019 19:10:46 +0000 (12:10 -0700)]
Move the IndexedAccessorIterator to STLExtras to allow for reuse.

This iterator is useful for implementing random access iterators based upon an index and an object pointer. Moving it to STLExtras allows for reuse elsewhere throughout the codebase, e.g. simplifying the DenseElementsAttr iterators.

PiperOrigin-RevId: 255020377

5 years agoInternal change
Nicolas Vasilache [Tue, 25 Jun 2019 19:02:56 +0000 (12:02 -0700)]
Internal change

PiperOrigin-RevId: 255018853

5 years agoSupport printing SSA ids in affine.load/store which do not have special names.
Andy Davis [Tue, 25 Jun 2019 17:29:53 +0000 (10:29 -0700)]
Support printing SSA ids in affine.load/store which do not have special names.

PiperOrigin-RevId: 254997746

5 years agoUpdate the OperationFolder to find a valid insertion point when materializing constants.
River Riddle [Tue, 25 Jun 2019 16:42:52 +0000 (09:42 -0700)]
Update the OperationFolder to find a valid insertion point when materializing constants.

The OperationFolder currently just inserts into the entry block of a Function, but regions may be isolated above, i.e. explicit capture only, and blindly inserting constants may break the invariants of these regions.

PiperOrigin-RevId: 254987796

5 years agoGPUtoNVVM: adjust integer bitwidth when lowering special register ops
Alex Zinenko [Tue, 25 Jun 2019 16:04:13 +0000 (09:04 -0700)]
GPUtoNVVM: adjust integer bitwidth when lowering special register ops

GPU dialect operations (launch and launch_func) use `index` type for thread and
block index values inside the kernel, for compatibility with affine loops.
NVVM dialect operations, following the NVVM intrinsics, use `!llvm.i32` type,
which does not necessarily have the same bit width as the lowered `index` type.
Optionally sign-extend (indices are signed) or truncate the result of the NVVM
dialect operation to the bit width of the lowered `index` type before passing
it to other operations.  This behavior is consistent with `std.index_cast`.  We
cannot use the latter since we are targeting LLVM dialect types directly,
rather than standard integer types.

PiperOrigin-RevId: 254980868

5 years agoAdd gpu::GPUDialect::isKernel helper.
Stephan Herhut [Tue, 25 Jun 2019 13:44:58 +0000 (06:44 -0700)]
Add gpu::GPUDialect::isKernel helper.

Also some mild cleanup of the kernel to cubin conversion pass.

PiperOrigin-RevId: 254959303

5 years agoAdd missing dependence to MLIRLLVMIR
Nicolas Vasilache [Tue, 25 Jun 2019 13:35:28 +0000 (06:35 -0700)]
Add missing dependence to MLIRLLVMIR

PiperOrigin-RevId: 254957980

5 years agoNVVM target: emit nvvm.annotations for kernel functions
Alex Zinenko [Tue, 25 Jun 2019 13:30:32 +0000 (06:30 -0700)]
NVVM target: emit nvvm.annotations for kernel functions

PTX backend in LLVM expects additional module-level metadata
`!nvvm.annotations` that lists functions that can be used as GPU kernels.
Generate this metadata based on the `gpu.kernel` attribute attached to
functions.  This attribute is added automatically by the kernel outlining pass
in the GPU dialect lowering flow.

PiperOrigin-RevId: 254957345

5 years agogpu.launch_func: add accessors to grid configuration operands
Alex Zinenko [Tue, 25 Jun 2019 11:21:10 +0000 (04:21 -0700)]
gpu.launch_func: add accessors to grid configuration operands

Add accessor functions that return `gpu::KernelDim3` containing the respective
operands for grid and block size accepted by `gpu.launch_func`.  Use the same
signature as for `gpu.launch`.

PiperOrigin-RevId: 254942674

5 years agoPrint both type in diagnostic emitted on mismatch between def/use of SSA Values ...
Mehdi Amini [Tue, 25 Jun 2019 00:51:44 +0000 (17:51 -0700)]
Print both type in diagnostic emitted on mismatch between def/use of SSA Values (NFC)

The error would look like:

  path/filename.mlir:32:23: error: use of value '%28' expects different type than prior uses: ''i32'' vs ''!_tf.control''

PiperOrigin-RevId: 254874859

5 years agoNFC: Move the ArgConverter methods out-of-line to improve readability.
River Riddle [Tue, 25 Jun 2019 00:36:05 +0000 (17:36 -0700)]
NFC: Move the ArgConverter methods out-of-line to improve readability.

PiperOrigin-RevId: 254872695

5 years agoFix OSS build
Nicolas Vasilache [Mon, 24 Jun 2019 22:23:26 +0000 (15:23 -0700)]
Fix OSS build

PiperOrigin-RevId: 254847773