River Riddle [Sat, 4 May 2019 18:14:23 +0000 (11:14 -0700)]
Add explicit friendship with Operation to each derived op class to ensure access to the inherited protected constructor of `Op`. Some compiler versions have different rules for the visibility of inherited constructors.
--
PiperOrigin-RevId:
246661686
Ashwin Murthy [Sat, 4 May 2019 08:00:25 +0000 (01:00 -0700)]
[TableGen] Couple of small updates to OpBase
Added a definition for the newly added None type.
Fix TCopVTEtAreSameAt to be a Predicate rather than a PredOpTrait. This makes it more of a primitive and allows flexible composition.
--
PiperOrigin-RevId:
246631975
Mehdi Amini [Sat, 4 May 2019 04:38:39 +0000 (21:38 -0700)]
Minor fixes (formatting/typos) to the DeveloperGuide
--
PiperOrigin-RevId:
246621047
Jacques Pienaar [Sat, 4 May 2019 02:48:57 +0000 (19:48 -0700)]
Fix up some mixed sign warnings.
--
PiperOrigin-RevId:
246614498
Mehdi Amini [Sat, 4 May 2019 01:46:24 +0000 (18:46 -0700)]
Automated rollback of changelist
246610168.
PiperOrigin-RevId:
246610394
Mehdi Amini [Sat, 4 May 2019 01:43:55 +0000 (18:43 -0700)]
Add a section in the DeveloperGuide about avoiding unsigned integer
--
PiperOrigin-RevId:
246610168
Mehdi Amini [Sat, 4 May 2019 01:43:22 +0000 (18:43 -0700)]
Add a section in the DeveloperGuide for the naming convention of command line options
--
PiperOrigin-RevId:
246610123
Jacques Pienaar [Sat, 4 May 2019 00:07:02 +0000 (17:07 -0700)]
Remove erroneous cast.
--
PiperOrigin-RevId:
246600166
River Riddle [Fri, 3 May 2019 22:59:42 +0000 (15:59 -0700)]
Remove the ability to directly print affine structures from the OpAsmPrinter. These should go through attributes like most everything else.
--
PiperOrigin-RevId:
246589682
Jacques Pienaar [Fri, 3 May 2019 21:41:55 +0000 (14:41 -0700)]
Fix -Wmismatched-tags warning.
--
PiperOrigin-RevId:
246576348
River Riddle [Fri, 3 May 2019 18:40:57 +0000 (11:40 -0700)]
Make the Twine parameter of the current diagnostic emit functions optional. This allows for the ability to exclusively use the new diagnostic interface without breaking all of the existing usages. Several diagnostics emitted in lib/IR have been updated to make use of this functionality.
--
PiperOrigin-RevId:
246546044
River Riddle [Fri, 3 May 2019 18:40:42 +0000 (11:40 -0700)]
Add an MLIRContext::emitWarning utility method.
--
PiperOrigin-RevId:
246546015
River Riddle [Fri, 3 May 2019 18:40:22 +0000 (11:40 -0700)]
Add the ability to attach notes to Diagnostic/InFlightDiagnostic.
Notes are a way to add additional context to a diagnostic, but don't really make sense as standalone diagnostics. Moving forward, notes will no longer be able to be constructed directly and must be attached to a parent Diagnostic.
Notes can be attached via `attachNote`:
auto diag = ...;
diag.attachNote() << "This is a note";
--
PiperOrigin-RevId:
246545971
Nicolas Vasilache [Fri, 3 May 2019 18:07:37 +0000 (11:07 -0700)]
Prepend an "affine-" prefix to Affine pass option names - NFC
Trying to activate both LLVM and MLIR passes in mlir-cpu-runner showed name collisions when registering pass names.
One possible way of disambiguating that should also work across dialects is to prepend the dialect name to the passes that specifically operate on that dialect.
With this CL, mlir-cpu-runner tests still run when both LLVM and MLIR passes are registered
--
PiperOrigin-RevId:
246539917
River Riddle [Fri, 3 May 2019 17:01:01 +0000 (10:01 -0700)]
Introduce a new API for emitting diagnostics with Diagnostic and InFlightDiagnostic.
The Diagnostic class contains all of the information necessary to report a diagnostic to the DiagnosticEngine. It should generally not be constructed directly, and instead used transitively via InFlightDiagnostic. A diagnostic is currently comprised of several different elements:
* A severity level.
* A source Location.
* A list of DiagnosticArguments that help compose and comprise the output message.
* A DiagnosticArgument represents any value that may be part of the diagnostic, e.g. string, integer, Type, Attribute, etc.
* Arguments can be added to the diagnostic via the stream(<<) operator.
* (In a future cl) A list of attached notes.
* These are in the form of other diagnostics that provide supplemental information to the main diagnostic, but do not have context on their own.
The InFlightDiagnostic class represents an RAII wrapper around a Diagnostic that is set to be reported with the diagnostic engine. This allows for the user to modify a diagnostic that is inflight. The internally wrapped diagnostic can be reported directly or automatically upon destruction.
These classes allow for more natural composition of diagnostics by removing the restriction that the message of a diagnostic is comprised of a single Twine. They should also allow for nice incremental improvements to the diagnostics experience in the future, e.g. formatv style diagnostics.
Simple Example:
emitError(loc, "integer bitwidth is limited to " + Twine(IntegerType::kMaxWidth) + " bits");
emitError(loc) << "integer bitwidth is limited to " << IntegerType::kMaxWidth << " bits";
--
PiperOrigin-RevId:
246526439
Alex Zinenko [Fri, 3 May 2019 12:31:55 +0000 (05:31 -0700)]
Accept additional conversions in the LLVM lowering
Extend the LLVM lowering class following the original idea of the "bag of
conversions". LLVMLowering class is now exposed as and can be derived from.
It provides hooks for derived classes to inject operation conversions and to
convert custom types. It is under responsibility of the caller to make sure
patterns don't overlap.
Update the lowering from the Linalg dialect to the LLVM IR dialect to use this
new approach.
--
PiperOrigin-RevId:
246492919
MLIR Team [Fri, 3 May 2019 10:08:56 +0000 (03:08 -0700)]
Fix bug in LoopTiling where a loop with trip count of 1 caused a division by zero
--
PiperOrigin-RevId:
246480710
Jacques Pienaar [Fri, 3 May 2019 01:58:47 +0000 (18:58 -0700)]
Start developer guide doc.
This is just a bare skeleton to start populating developer policies and
guidelines. LLVM side this would be multiple separate documents (coding
standard & programmer's manual) but starting with one and we can break it out
into multiple if the content so dictates.
--
PiperOrigin-RevId:
246433346
Stella Laurenzo [Fri, 3 May 2019 00:26:00 +0000 (17:26 -0700)]
Add missing SameValueType trait to a couple of quantization ops.
--
PiperOrigin-RevId:
246422412
Lei Zhang [Thu, 2 May 2019 21:08:18 +0000 (14:08 -0700)]
Be consistent w.r.t. struct/class in forward declaration
This addresses compiler warnings.
--
PiperOrigin-RevId:
246386939
River Riddle [Thu, 2 May 2019 21:02:57 +0000 (14:02 -0700)]
NFC: Move AttributeStorage and AttributeUniquer into a new header AttributeSupport.h in preparation for them to be used by dialect defined attributes.
--
PiperOrigin-RevId:
246385860
Stella Laurenzo [Thu, 2 May 2019 19:41:34 +0000 (12:41 -0700)]
Add FxpMathOps real_matmul and real_matmul_bias.
Also:
- cleans up some operand names for consistency
- remove the broadcast_dims attribute as it isn't used
- adds an IsNullAttr predicate which is needed to match optional clamp attributes on these kind of ops (needed to simplify some out of tree transforms on the new matmul op)
--
PiperOrigin-RevId:
246370576
Lei Zhang [Thu, 2 May 2019 19:08:17 +0000 (12:08 -0700)]
[TableGen] Add the `TCopVTEtAreSameAt` PredOpTrait
This trait is used for specifying operands at the indices from a given
list are with the same element type.
--
PiperOrigin-RevId:
246364735
Jacques Pienaar [Thu, 2 May 2019 18:52:33 +0000 (11:52 -0700)]
[ODS] Define ConstantOp.
Add ConstantOp's Op Definition Spec. Currently we don't use convertFromStorage in the generated patterns and so needed to add a few casts to support patterns restricted to ElementsAttrs and to compensate for old rules where we defined ConstantOp to have a ElementsAttr to simplify writing the pattern.
--
PiperOrigin-RevId:
246361555
Nicolas Vasilache [Thu, 2 May 2019 18:36:52 +0000 (11:36 -0700)]
Add a primitive linalg-lower-to-llvm-dialect pass
This CL builds upon ftynse@'s Linalg dialect conversion (in examples/Linalg/Linalg1) and updates it to support buffers and the fully composed form of view and slice operations.
A new BufferSizeOp is introduced for the purpose of extracting the size information from a buffer.
This will be useful in a followup CL for an end-to-end LLVM execution path where mlir-cpu-runner will allocate a buffer.
--
PiperOrigin-RevId:
246358593
River Riddle [Thu, 2 May 2019 18:27:58 +0000 (11:27 -0700)]
Simplify TypeUniquer/AttributeUniquer to not require multiple overloads when constructing a new storage.
--
PiperOrigin-RevId:
246356767
Jacques Pienaar [Thu, 2 May 2019 18:21:00 +0000 (11:21 -0700)]
Update to address missing cmake target & qualify make_pair.
--
PiperOrigin-RevId:
246355137
MLIR Team [Thu, 2 May 2019 13:33:58 +0000 (06:33 -0700)]
Fix a minor formatting issue.
--
PiperOrigin-RevId:
246307329
MLIR Team [Thu, 2 May 2019 13:05:01 +0000 (06:05 -0700)]
Fix a typo.
--
PiperOrigin-RevId:
246304098
Geoffrey Martin-Noble [Thu, 2 May 2019 00:03:32 +0000 (17:03 -0700)]
Substitute getI64IntegerAttr for the more verbose code it replaces.
--
PiperOrigin-RevId:
246227344
River Riddle [Wed, 1 May 2019 19:13:44 +0000 (12:13 -0700)]
Add support for basic remark diagnostics. This is the minimal functionality needed to separate notes from remarks. It also provides a starting point to start building out better remark infrastructure.
--
PiperOrigin-RevId:
246175216
River Riddle [Wed, 1 May 2019 18:14:15 +0000 (11:14 -0700)]
Start sketching out a new diagnostics infrastructure. Create a new class 'DiagnosticEngine' and move the diagnostic handler support and final diagnostic emission from the MLIRContext to it.
--
PiperOrigin-RevId:
246163897
Nicolas Vasilache [Wed, 1 May 2019 13:47:32 +0000 (06:47 -0700)]
[Linalg] Add a primitive tiling pass
This CL adds a primitive tiling pass for Linalg.
The tiling pass uses the loopToOperandRangesMaps property which should be ideally Tablegen'd and in-class.
The tiling specification uses 0 as a convention to skip loops that should not be tiled.
Tiling proceeds in 3 steps, for each op:
1. Pad tile sizes with 0 to match the number of loops, this simplifies the implementation and avoids affine map manipulations to align dimensions.
2. Create loop ranges that represent the min/max/step by which to iterate. This should be later complemented by a range intersection to avoid the out-of-bounds case.
3. Map the loop ranges to view ranges in order to create subviews on which the op can be called.
Relevant utility and helper functions are added separately that support writing the transformation in a declarative fashion.
Simplifying assumptions are made for now on the views and the ranges that are constructed
in the function and are not passed as function arguments. This restriction will be lifted
in the future.
--
PiperOrigin-RevId:
246124419
River Riddle [Wed, 1 May 2019 01:15:48 +0000 (18:15 -0700)]
Remove NumericAttr. Now that all attributes contain a type, this subclass is no longer necessary.
--
PiperOrigin-RevId:
246061024
Stella Laurenzo [Tue, 30 Apr 2019 22:32:55 +0000 (15:32 -0700)]
Fix namespaces on a few pass factory functions.
--
PiperOrigin-RevId:
246035278
River Riddle [Tue, 30 Apr 2019 21:26:04 +0000 (14:26 -0700)]
Ensure that every Attribute contains a Type. If an Attribute does not provide a type explicitly, the type is defaulted to NoneType.
--
PiperOrigin-RevId:
246021088
Smit Hinsu [Tue, 30 Apr 2019 18:53:00 +0000 (11:53 -0700)]
Reserve the required capacity to avoid pointer invalidations for translation functions
--
PiperOrigin-RevId:
245992152
River Riddle [Tue, 30 Apr 2019 17:31:29 +0000 (10:31 -0700)]
Refactor Attribute uniquing to use StorageUniquer instead of being hard coded in the MLIRContext. This allows for attributes to be uniqued similarly to types. This is the second step towards allowing dialects to define attributes.
--
PiperOrigin-RevId:
245974705
Rob Suderman [Tue, 30 Apr 2019 16:52:38 +0000 (09:52 -0700)]
ExtractElementsOp asserts for >1 operator however it actually expects
>0 operators.
--
PiperOrigin-RevId:
245966586
Stephan Herhut [Tue, 30 Apr 2019 13:08:21 +0000 (06:08 -0700)]
Add transformation of the NVVM dialect to an LLVM module. Only handles
the generation of intrinsics out of NVVM index ops for now.
--
PiperOrigin-RevId:
245933152
Jacques Pienaar [Tue, 30 Apr 2019 06:12:40 +0000 (23:12 -0700)]
Add extraClassDeclaration field for ops.
Simple mechanism to allow specifying arbitrary function declarations. The modelling will not cover all cases so allow a means for users to declare a method function that they will define in their C++ files. The goal is to allow full C++ flexibility as the goal is to cover cases not modelled.
--
PiperOrigin-RevId:
245889819
Stella Laurenzo [Tue, 30 Apr 2019 00:05:05 +0000 (17:05 -0700)]
Add an "any" quantized type, which contains the underlying type correlation but does not specify any mapping.
Also fixes some comments that were stale after the last syntax upgrade.
--
PiperOrigin-RevId:
245853462
Jacques Pienaar [Mon, 29 Apr 2019 23:12:15 +0000 (16:12 -0700)]
Fix opt build failure.
--
PiperOrigin-RevId:
245844236
Jacques Pienaar [Mon, 29 Apr 2019 21:10:08 +0000 (14:10 -0700)]
Fixup MLIRGPU to mlir-opt in cmake.
--
PiperOrigin-RevId:
245820077
Nicolas Vasilache [Mon, 29 Apr 2019 19:11:58 +0000 (12:11 -0700)]
Parsing support for Range, View and Slice operations
This CL implements the previously unsupported parsing for Range, View and Slice operations.
A pass is introduced to lower to the LLVM.
Tests are moved out of C++ land and into mlir/test/Examples.
This allows better fitting within standard developer workflows.
--
PiperOrigin-RevId:
245796600
Nicolas Vasilache [Mon, 29 Apr 2019 17:30:57 +0000 (10:30 -0700)]
Link MLIRSupport to IR in OSS
The missing dependency breaks linking on Linux.
--
PiperOrigin-RevId:
245773637
Jacques Pienaar [Mon, 29 Apr 2019 16:24:09 +0000 (09:24 -0700)]
Add Dialect in op definition to capture prefix and documentation.
Enables specifying the documentation for dialect along with defining the ops of the dialect. The doc generator will be expanded in follow up to emit the documentation in the autogenerated files. This is precursor to allowing common base for all ops in a dialect.
All the dialect documentation is super sparse and just added as placeholder.
I was tempted (and started) to move ConstantOp to be generated too, but this will be easier post adding extra_methods, so deferring until then.
--
PiperOrigin-RevId:
245759984
Alex Zinenko [Mon, 29 Apr 2019 10:00:25 +0000 (03:00 -0700)]
Start GPU Dialect
Define a new dialect related to GPU kernels. Currently, it only contains a
single operation for launching a kernel on a three-dimensional grid of thread
blocks, following a model similar to that of CUDA. In particular, the body of
the kernel contains operations executed by each thread and uses region
arguments to accept thread and block identifiers (similar to how the loop body
region accepts the induction value).
--
PiperOrigin-RevId:
245713728
Mehdi Amini [Sun, 28 Apr 2019 17:54:06 +0000 (10:54 -0700)]
Rename "convert-to-llvmir" to "lower-to-llvm" (NFC)
--
PiperOrigin-RevId:
245649493
Smit Hinsu [Sun, 28 Apr 2019 03:55:38 +0000 (20:55 -0700)]
Make identity cast operations with the same operand and result types legal
Instead, fold such operations. This way callers don't need to conditionally create cast operations depending on if a value already has the target type.
Also, introduce areCastCompatible to allow cast users to verify that the generated op will be valid before creating the operation.
TESTED with unit tests
--
PiperOrigin-RevId:
245606133
River Riddle [Sun, 28 Apr 2019 01:35:04 +0000 (18:35 -0700)]
Add support for a NoneType.
none-type ::= `none`
The `none` type is a unit type, i.e. a type with exactly one possible value, where its value does not have a defined dynamic representation.
--
PiperOrigin-RevId:
245599248
River Riddle [Sat, 27 Apr 2019 21:26:41 +0000 (14:26 -0700)]
Update the wording of a comment in the LangRef now that multi-threading is no longer an anticipated feature.
--
PiperOrigin-RevId:
245586656
Alex Zinenko [Fri, 26 Apr 2019 22:31:11 +0000 (15:31 -0700)]
Add LLVM Conversion Tutorial
Add a tutorial document explaining how to define a conversion from the Linalg
dialect to the LLVM IR dialect, bypassing the Affine dialect. It defines a
dynamic representation for a range and a view for the sake of type conversion.
Operation conversion becomes straightforward given the dynamic representation.
The code in the tutorial is better structured and better document that what we
currently have in the example, which will be updated separately.
--
PiperOrigin-RevId:
245498394
Alex Zinenko [Fri, 26 Apr 2019 22:07:13 +0000 (15:07 -0700)]
Implement the conversion between SDBMExpr and AffineExpr
Since SDBM expressions are a subset of affine expressions, they can be
converted to affine expressions in a straightforward way. The inverse
conversion may fail when the affine expression is not an SDBM. Implement the
inverse convresion assuming affine expressions are simplified and
canonicalizied, detect subtractive and multiplicative forms of the stripe
operation.
--
PiperOrigin-RevId:
245494735
Alex Zinenko [Fri, 26 Apr 2019 21:46:13 +0000 (14:46 -0700)]
Decouple region argument parsing from their type assignment
The parser currently expects region arguments to have a fixed, known type when
the %-name of the region argument is parsed. This may not necessarily be the
case, for example, if the region argument types are the same as the operand
types, located at the end of the operation. Furthermore, the parser currently
stores the values for region arguments internally and attaches them to the next
parsed region implicitly. This makes it impossible to attach some of the
arguments to one region and some other arguments to another region if the
regions are not textually interleaved with operation arguments.
Provide `OpAsmParser::parseRegionArgument` that parses an SSA identifier and
delays its type assignment until the region is parsed, similarly to operands.
Update `OpAsmParser::parseRegion` to accept a list of pre-parsed SSA
identifiers and a list of types instead of using SSA identifiers stored in the
parser.
--
PiperOrigin-RevId:
245491133
River Riddle [Fri, 26 Apr 2019 18:38:50 +0000 (11:38 -0700)]
Enable multi-threading in the pass manager by default.
--
PiperOrigin-RevId:
245458081
Alex Zinenko [Fri, 26 Apr 2019 08:05:24 +0000 (01:05 -0700)]
Start building SDBM infrastructure
Striped difference-bound matrix expressions are a subset of affine expressions
supporting low-complexity algorithms that can be useful for loop
transformations. This introduces the basic data data structures for building
such expressions and unique'ing them in a MLIRContext.
--
PiperOrigin-RevId:
245380206
Stephan Herhut [Fri, 26 Apr 2019 07:57:10 +0000 (00:57 -0700)]
Add a new NVVM dialect that extends the LLVM dialect with some NVVM specific operations.
Currently, this is limited to operations that give access to the special registers of
NVIDIA gpus that represent block and thread indices.
--
PiperOrigin-RevId:
245378632
River Riddle [Fri, 26 Apr 2019 04:01:21 +0000 (21:01 -0700)]
Refactor the generic storage object uniquing functionality from TypeUniquer into its own class 'StorageUniquer'. This is the first step in supporting dialect extensible attributes.
--
PiperOrigin-RevId:
245358744
Lei Zhang [Thu, 25 Apr 2019 21:45:37 +0000 (14:45 -0700)]
[TableGen] Support multiple variadic operands/results
Certain ops can have multiple variadic operands/results, e.g., `tf.DynamicStitch`.
Even if an op has only one variadic operand/result, it is not necessarily the
very last one, e.g., `tf.RaggedGather`. This CL enhances TableGen subsystem to be
able to represent such cases.
In order to deduce the operand/result value range for each variadic operand,
currently we only support variadic operands/results all of the same size.
So two new traits, `SameVariadicOperandSize` and `SameVariadicResultSize` are
introduced.
--
PiperOrigin-RevId:
245310628
River Riddle [Thu, 25 Apr 2019 16:56:09 +0000 (09:56 -0700)]
Add support for Unit Attributes.
A unit attribute is an attribute that represents a value of `unit` type. The
`unit` type allows only one value forming a singleton set. This attribute value
is used to represent attributes that only have meaning from their existence.
One example of such an attribute could be the `swift.self` attribute. This attribute indicates that a function parameter is the self/context
parameter. It could be represented as a boolean attribute(true or false), but a
value of false doesn't really bring any value. The parameter either is the
self/context or it isn't.
```mlir {.mlir}
// A unit attribute defined with the `unit` value specifier.
func @verbose_form(i1 {unitAttr : unit})
// A unit attribute can also be defined without the `unit` value specifier.
func @simple_form(i1 {unitAttr})
```
--
PiperOrigin-RevId:
245254045
Rob Suderman [Wed, 24 Apr 2019 20:25:49 +0000 (13:25 -0700)]
GetMemRefType failed on 0-D tensors. Loosened check to allow tensors with shape
{}.
--
PiperOrigin-RevId:
245104548
Lei Zhang [Wed, 24 Apr 2019 17:53:12 +0000 (10:53 -0700)]
[TableGen] Refine OpTrait classes and defs to be consistent
--
PiperOrigin-RevId:
245075421
Alex Zinenko [Wed, 24 Apr 2019 16:24:57 +0000 (09:24 -0700)]
Introduce functionality for defining region ancestor relation
Add member functions for Regions to query if another Region is a ancestor. The
implementation is naive and traverses all parent regions performing one-to-one
comparisons. As a side effect, this introduces `getContainingRegion` function
for Operations and Values to return the Region in which they are defined, and
for Regions to return the "parent" region if any.
--
PiperOrigin-RevId:
245057980
Lei Zhang [Wed, 24 Apr 2019 15:51:08 +0000 (08:51 -0700)]
Add MultiResultTraitBase
Similar to MultiOperandTraitBase, this can simply the implementation of
NResults, AtLeastNResults, and VariadicResults.
--
PiperOrigin-RevId:
245052333
River Riddle [Wed, 24 Apr 2019 00:02:06 +0000 (17:02 -0700)]
Fix flaky Linalg roundtrip test. This removes an invalid "%s" from the second mlir-opt command.
--
PiperOrigin-RevId:
244953230
Mehdi Amini [Tue, 23 Apr 2019 23:39:15 +0000 (16:39 -0700)]
Use -force_load instead of -all_load on MacOS
The -all_load flag will apply to all future libraries added on the command line,
while the -force_load flag only applies to the next library. Using the latter
allows to selectively force load the specific libraries we want.
--
PiperOrigin-RevId:
244949770
River Riddle [Tue, 23 Apr 2019 21:38:26 +0000 (14:38 -0700)]
Rename isa_nonnull to isa_and_nonnull to match the upstream llvm name.
--
PiperOrigin-RevId:
244928036
Nicolas Vasilache [Tue, 23 Apr 2019 20:21:40 +0000 (13:21 -0700)]
[Linalg] Add basic linalg ops
This CL adds linalg.dot, linalg.matvec and linalg.matmul ops with the proper roundtripping test. These are the first LinalgOp that operate on views and that will lower to library calls.
Linalg ops exhibit some common properties and behavior that are modeled with Traits.
A LinalgOp is defined as a generic Op that operates on input and output views (passed as operands) and has the following properties:
1. a number of input and outputs captured by the `NInputsAndOutputs` trait.
2. a list of ranks for each operand captured by the `ViewRanks` trait.
3. a set of parallel, reduction and windowing loops captured by `NLoopTypes` trait.
These represent are a first set of generic properties that will enable the definition of generic linear algebra operations and the properties necessary for upcoming transformations.
--
PiperOrigin-RevId:
244912754
MLIR Team [Tue, 23 Apr 2019 14:58:03 +0000 (07:58 -0700)]
Minor typo in integer type definition.
--
PiperOrigin-RevId:
244854008
Alex Zinenko [Tue, 23 Apr 2019 09:37:07 +0000 (02:37 -0700)]
Factor out thread-safe uniqu'ing backed by vector in MLIRcontext
Extract common code from getAffineSymbolExpr and getAffineConstantExpr into a
utility function safeGetOrCreate, similarly to the existing overloads for sets
and maps. The position in the vector is used as indexing key. NFC.
--
PiperOrigin-RevId:
244820859
Alex Zinenko [Tue, 23 Apr 2019 09:31:59 +0000 (02:31 -0700)]
ExecutionEngine: update to reflect LLVM API changes
LLVM Orc JIT changed the API for DynamicLibrarySearchGenerator::
GetForCurrentProcess to only take one value of the DataLayout that it actually
uses instead of the whole data layout. Update MLIR ExecutionEngine call to
this function accordingly.
--
PiperOrigin-RevId:
244820235
Smit Hinsu [Tue, 23 Apr 2019 07:50:15 +0000 (00:50 -0700)]
Fix unused variable warning in opt build
TESTED with existing tests
--
PiperOrigin-RevId:
244808731
Stella Laurenzo [Tue, 23 Apr 2019 00:35:38 +0000 (17:35 -0700)]
Implement lowering of quant.dcast to the fxpmathops and standard dialect.
Note that I broke this out as a separate pass because intermediate transformations often produce qcast/dcast ops that are integral to the transformation, and it is typical to want to lower any remaining, unmatched casts at the end of quantization. If this flexibility ends up not being needed, they can be collapsed into the same pass. This is included in the same cpp file because all of the math ops will need to defer to emitting quantize/dequantize logic for cases that they cannot be fully lowered to fixed-point math.
Also, the new convertistof op needs to be evaluated for inclusion in StandardOps.
--
PiperOrigin-RevId:
244768679
Feng Liu [Mon, 22 Apr 2019 23:06:09 +0000 (16:06 -0700)]
Apply patterns repeatly if the function is modified
During the pattern rewrite, if the function is changed, i.e. ops created,
deleted or swapped, the pattern rewriter needs to re-scan the function entirely
and apply the patterns again, so the patterns whose root ops have been popped
out from the working list nor an immediate users of the changed ops can be
reconsidered.
A command line flag is added to set the max number of iterations rescanning the
function for pattern match. If the rewrite doesn' converge after this number,
this compiling will continue and the result can be sub-optimal.
One unit test is updated because this change fixed the missing optimization opportunities.
--
PiperOrigin-RevId:
244754190
Lei Zhang [Mon, 22 Apr 2019 21:56:54 +0000 (14:56 -0700)]
[TableGen] Clean up comments regarding op and result
An op can have multiple results. Being explicit that we are binding to the
whole op instead of one of the results. A way to bind to a specific result
is yet to come.
--
PiperOrigin-RevId:
244741137
Lei Zhang [Mon, 22 Apr 2019 21:13:45 +0000 (14:13 -0700)]
[TableGen] Unify cOp and tAttr into NativeCodeCall
Both cOp and tAttr were used to perform some native C++ code expression.
Unifying them simplifies the concepts and reduces cognitive burden.
--
PiperOrigin-RevId:
244731946
Lei Zhang [Mon, 22 Apr 2019 20:40:30 +0000 (13:40 -0700)]
[TableGen] Capture bound source ops in PatternState
This allows accessing those bound source ops in result patterns, which can be
useful for invoking native C++ op creation.
We bind the op entirely here because ops can have multiple results. Design a
approach to bind to a specific result is not the concern of this commit.
--
PiperOrigin-RevId:
244724750
Jacques Pienaar [Sat, 20 Apr 2019 17:45:59 +0000 (10:45 -0700)]
Update lib path in whole_archive_link.
The added library path is now specified explicitly wrt top-level build directory.
--
PiperOrigin-RevId:
244507187
Lei Zhang [Sat, 20 Apr 2019 11:05:38 +0000 (04:05 -0700)]
Use StringRef::drop_while() to simplify a while loop
--
PiperOrigin-RevId:
244488612
Mehdi Amini [Fri, 19 Apr 2019 22:26:52 +0000 (15:26 -0700)]
Add references to the EuroLLVM talks in the README
--
PiperOrigin-RevId:
244433092
Stella Laurenzo [Fri, 19 Apr 2019 21:41:31 +0000 (14:41 -0700)]
Simplify and enable pretty-parsing/printing of the uniform quantized types.
The per-layer format is now like:
!quant.uniform<i8<-8:7>:f32, 9.987200e-01:127>
and per-axis is:
!quant.uniform<i8:f32:1, {2.0e+2,0.99872:120}>
I used the following sed script to update the unit tests (invoked with commands like `sed -i -r -f fix_quant.sed $(find . -name '*.mlir')`).
---
# Per-layer
s|\!quant<"uniform\[([iu][0-9]+):([fb]+[0-9]+)\]\{([^\}]+)\}\s*">|!quant.uniform<\1:\2, \3>|g
s|\!quant<"uniform\[([iu][0-9]+)\(([^\)]+)\):([fb]+[0-9]+)\]\{([^\}]+)\}\s*">|!quant.uniform<\1<\2>:\3, \4>|g
# Per-axis
s|\!quant<"uniform\[([iu][0-9]+):([fb]+[0-9]+)(:[0-9]+)?\]\{([^\}]+)\}\s*">|!quant.uniform<\1:\2\3, {\4}>|g
s|\!quant<"uniform\[([iu][0-9]+)\(([^\)]+)\):([fb]+[0-9]+)(:[0-9]+)?\]\{([^\}]+)\}\s*">|!quant.uniform<\1<\2>:\3\4, {\5}>|g
---
I fixed up the one file of error cases manually.
Since this is a one time syntax fix, I am not persisting the script anywhere.
--
PiperOrigin-RevId:
244425331
Nicolas Vasilache [Fri, 19 Apr 2019 19:55:34 +0000 (12:55 -0700)]
[Linalg] Add a slice op
This CL adds a linalg.slice op with the proper roundtripping test.
A slice op allows taking subviews that may be rank-reducing (if some indexing is of index type) or not (if all indexings are of linalg.range type).
A slice must be constructed directly from a base view (no chains of slices may exist in the IR). Helper functions that fold will be provided for construction if/when necessary.
This also renames base_view to view.
--
PiperOrigin-RevId:
244406827
Nicolas Vasilache [Fri, 19 Apr 2019 16:56:11 +0000 (09:56 -0700)]
[Linalg] Add a view type with base_view op
This CL adds a linalg.view<?x?xf32> type and base_view op with the proper roundtripping test. The parser will be improved in a subsequent CL once portions of the mlir::Parser are exposed.
For now this only supports dynamic views, static views will be introduced at a later time when they are needed.
--
PiperOrigin-RevId:
244374180
Stella Laurenzo [Fri, 19 Apr 2019 00:06:05 +0000 (17:06 -0700)]
Implement lowering of element-wise fixed point add and mul to the standard dialect.
This also does the following:
- Removes the poc POT add implementation in favor of a version that does not rescale.
- Adds a handful of FxpMathOps which are needed (these are for comment and we may want to move them to the StandardOps dialect).
- Adds a canonicalizer to the StorageCastOp, which removes some cruft once conversions have been done.
- Adds a couple of predicates to OpBase.
--
PiperOrigin-RevId:
244287706
Guangda Lai [Thu, 18 Apr 2019 22:27:32 +0000 (15:27 -0700)]
Fix typo (transpose -> reshape).
--
PiperOrigin-RevId:
244270801
Nicolas Vasilache [Thu, 18 Apr 2019 20:56:18 +0000 (13:56 -0700)]
[Linalg] Add a simple buffer type with alloc/dealloc ops
This CL adds a linalg.buffer<f32> type and buffer_alloc / buffer_dealloc ops with the proper roundtripping test.
--
PiperOrigin-RevId:
244252306
Nicolas Vasilache [Thu, 18 Apr 2019 15:25:54 +0000 (08:25 -0700)]
Start a Linalg dialect
This CL starts implementing a Linalg dialect with the objective of supporting
optimizing compilation of loops and library calls for a subset of common linear
algebra operations.
This CL starts by simply adding a linalg.range type and an operation with the
proper roundtripping test.
--
PiperOrigin-RevId:
244189468
Lei Zhang [Thu, 18 Apr 2019 12:10:03 +0000 (05:10 -0700)]
Fix MLIRTableGenTests target_link_libraries typo
--
PiperOrigin-RevId:
244168112
Lei Zhang [Thu, 18 Apr 2019 11:04:57 +0000 (04:04 -0700)]
[TableGen] Simplify NOperands trait generation
--
PiperOrigin-RevId:
244162515
Jacques Pienaar [Thu, 18 Apr 2019 03:56:00 +0000 (20:56 -0700)]
Simplify build instructions.
--
PiperOrigin-RevId:
244120877
Nicolas Vasilache [Wed, 17 Apr 2019 21:41:33 +0000 (14:41 -0700)]
Use proper C++ casts in Types.h
This CL reduces the amount of warning spew when compiling with CMake on Linux.
--
PiperOrigin-RevId:
244070668
Nicolas Vasilache [Wed, 17 Apr 2019 21:38:45 +0000 (14:38 -0700)]
Use proper C++ casts in Location.h
This CL reduces the amount of warning spew when compiling with CMake on Linux.
--
PiperOrigin-RevId:
244070052
Amit Sabne [Wed, 17 Apr 2019 20:39:41 +0000 (13:39 -0700)]
Fix LLVM_DEBUG instances
--
PiperOrigin-RevId:
244058051
Amit Sabne [Wed, 17 Apr 2019 19:18:37 +0000 (12:18 -0700)]
Loop invariant code motion.
--
PiperOrigin-RevId:
244043679
Feng Liu [Wed, 17 Apr 2019 15:31:39 +0000 (08:31 -0700)]
Move QuantTypes out of QuantOps to match the file structures of other dialects
This CL also moved the UniformSupport.cpp and FakeQuantSupport.cpp into utils because they are not really the core of the IR.
--
PiperOrigin-RevId:
244001666
Stella Laurenzo [Wed, 17 Apr 2019 01:36:24 +0000 (18:36 -0700)]
Bring naming of some quant ops in alignment with docs and introduce a few necessary additional ops (stats_ref, stats, coupled_ref).
--
PiperOrigin-RevId:
243919195
MLIR Team [Tue, 16 Apr 2019 23:47:41 +0000 (16:47 -0700)]
Add NewLine for Attribute dump()
--
PiperOrigin-RevId:
243904869
Yanan Cao [Tue, 16 Apr 2019 23:12:00 +0000 (16:12 -0700)]
Add DebugStringHelper, which makes it easier to get a string from a dump method
--
PiperOrigin-RevId:
243899072
Nicolas Vasilache [Tue, 16 Apr 2019 21:11:25 +0000 (14:11 -0700)]
Fix SliceAnalysis comment
The description of the backward slice analysis behavior describes what would happen when creating a backward slice from node 9, not 8.
--
PiperOrigin-RevId:
243876599