Commit Graph

2052 Commits

Author SHA1 Message Date
River Riddle 694975ddbc Standardize the definition and usage of getAllArgAttrs between FuncOp and Function.
PiperOrigin-RevId: 255988352
2019-07-01 11:39:12 -07:00
River Riddle 54cd6a7e97 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
2019-07-01 11:39:00 -07:00
River Riddle 84bd67fc4f Update the 1->N legalizer test to use "test.return" so that the conversion cast is elided properly.
PiperOrigin-RevId: 255979732
2019-07-01 11:38:47 -07:00
Alex Zinenko 5eef726bc8 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
2019-07-01 09:56:56 -07:00
Alex Zinenko a83fd0d2c7 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
2019-07-01 09:56:44 -07:00
Andy Davis f487d20bf0 Add affine-to-standard lowerings for affine.load/store/dma_start/dma_wait.
PiperOrigin-RevId: 255960171
2019-07-01 09:56:22 -07:00
Lei Zhang 2dc5e19426 Also disable generating underlying value to symbol conversion declaration when there is an enumerant without explicit value
PiperOrigin-RevId: 255950779
2019-07-01 09:56:11 -07:00
Lei Zhang 2652be7934 Avoid generating underlying value to symbol conversion function if there is an enumerant without explicit value.
PiperOrigin-RevId: 255945801
2019-07-01 09:55:59 -07:00
Lei Zhang 9dd182e0fa [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
2019-07-01 09:55:47 -07:00
Nicolas Vasilache e7f51ad08a Add a folder-based EDSC intrinsics constructor (NFC)
PiperOrigin-RevId: 255908660
2019-07-01 09:55:35 -07:00
Alex Zinenko d046b2ddec 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
2019-07-01 09:55:24 -07:00
River Riddle 8c47e2ed5c 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
2019-07-01 09:55:13 -07:00
Nicolas Vasilache 6a7a1ca25d 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
2019-07-01 09:54:27 -07:00
jpienaar ef76343488 Merge pull request tensorflow/mlir#37 from tensorflow:jpienaar-patch-1
PiperOrigin-RevId: 255769524
2019-07-01 09:54:15 -07:00
jpienaar 0acb393fc4 Update link to presentation 2019-06-28 18:06:45 -07:00
Jacques Pienaar b975111fc0 Internal change
PiperOrigin-RevId: 255700627
2019-06-28 18:00:49 -07:00
A. Unique TensorFlower 16a60c6df7 Merge pull request tensorflow/mlir#36 from pkanwar23:patch-2
PiperOrigin-RevId: 255694478
2019-06-28 17:59:59 -07:00
pkanwar23 c353d97cb8 Update CONTRIBUTING.md
Co-Authored-By: Mehdi Amini <joker.eph@gmail.com>
2019-06-28 16:44:32 -07:00
pkanwar23 8ed1ce9de3 Update CONTRIBUTING.md 2019-06-28 15:11:04 -07:00
pkanwar23 4cd3a67157 Update CONTRIBUTING.md 2019-06-28 15:05:13 -07:00
pkanwar23 098d93e0fd Update CONTRIBUTING.md 2019-06-28 15:00:57 -07:00
Andy Davis 6c68596aee 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
2019-06-28 13:31:57 -07:00
pkanwar23 799c7b291a Update CONTRIBUTING.md 2019-06-28 12:51:30 -07:00
Lei Zhang 7b17f4e647 [spirv] Move conversion passes to a new library
PiperOrigin-RevId: 255648303
2019-06-28 12:32:02 -07:00
River Riddle 7c755d06aa 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
2019-06-28 11:29:04 -07:00
Mahesh Ravishankar 266841751f 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
2019-06-28 10:10:17 -07:00
River Riddle 030e45e33d Respect the user provided type when parsing StringAttr.
PiperOrigin-RevId: 255532918
2019-06-27 20:59:19 -07:00
Jacques Pienaar ce1f72a456 Update cmake depedency.
PiperOrigin-RevId: 255532863
2019-06-27 20:58:34 -07:00
Mahesh Ravishankar fd1113f1dd Return an error when parseType doesnt parse the entire string passed
PiperOrigin-RevId: 255505300
2019-06-27 17:00:31 -07:00
River Riddle 929466b5c9 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
2019-06-27 16:43:18 -07:00
MLIR Team 7b5f49af76 Parenthesize match expression to avoid operator precedence issues
PiperOrigin-RevId: 255435454
2019-06-27 11:07:07 -07:00
River Riddle bda669beea 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
2019-06-27 09:13:44 -07:00
Jacques Pienaar c48675fd87 Fix incorrect type used in forward declaration.
Addresses compiler warning.

PiperOrigin-RevId: 255407691
2019-06-27 08:39:17 -07:00
MLIR Team 1533e53159 Support parsing MLIR source from stdin.
PiperOrigin-RevId: 255316118
2019-06-26 19:57:04 -07:00
River Riddle 6ebd6df69f 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
2019-06-26 18:50:18 -07:00
River Riddle 260d3e39ad 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
2019-06-26 18:29:54 -07:00
Jacques Pienaar d4cf54f2c1 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
2019-06-26 11:14:45 -07:00
Stephan Herhut 630119f84f 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
2019-06-26 05:33:11 -07:00
Stephan Herhut c72c6c3907 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
2019-06-26 05:16:37 -07:00
River Riddle a4c3a6455c 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
2019-06-25 21:32:23 -07:00
River Riddle 679a3b4191 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
2019-06-25 19:06:34 -07:00
River Riddle 49162524d8 NFC: Uniformize the return of the LocationAttr 'get' methods to 'Location'.
PiperOrigin-RevId: 255078768
2019-06-25 16:57:56 -07:00
River Riddle 4842b2d42e 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
2019-06-25 16:06:58 -07:00
Rasmus Munk Larsen 1df5f3159e Fix typo in Toy tutorial documentation
PiperOrigin-RevId: 255054639
2019-06-25 15:00:08 -07:00
Rasmus Munk Larsen 9966ba2b3c Fix unclear sentence.
PiperOrigin-RevId: 255022564
2019-06-25 12:24:00 -07:00
River Riddle 3ca33a5c62 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
2019-06-25 12:11:14 -07:00
Nicolas Vasilache f08dcfaf89 Internal change
PiperOrigin-RevId: 255018853
2019-06-25 12:03:29 -07:00
Andy Davis 91f27d025b Support printing SSA ids in affine.load/store which do not have special names.
PiperOrigin-RevId: 254997746
2019-06-25 10:30:26 -07:00
River Riddle 66ed7d6d83 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
2019-06-25 09:43:21 -07:00
Alex Zinenko 2628641b23 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
2019-06-25 09:21:26 -07:00