River Riddle [Mon, 25 Mar 2019 06:51:05 +0000 (23:51 -0700)]
Update some of the derived type classes to use getImpl instead of a static_cast.
PiperOrigin-RevId:
240084937
Chris Lattner [Mon, 25 Mar 2019 06:26:39 +0000 (23:26 -0700)]
Various small cleanups to the code, mostly removing const_cast's.
PiperOrigin-RevId:
240083489
Mehdi Amini [Mon, 25 Mar 2019 05:09:41 +0000 (22:09 -0700)]
Add a `getImpl()` utility method to the `TypeBase` class as a convenience for derived class to access their associated TypeStorage (NFC)
PiperOrigin-RevId:
240077874
Mehdi Amini [Mon, 25 Mar 2019 04:52:49 +0000 (21:52 -0700)]
Change TypeStorage from a struct into a class (NFC)
By coding standard, we try to keep struct as pure storage without method or other logic attached to it.
PiperOrigin-RevId:
240076419
Mehdi Amini [Mon, 25 Mar 2019 04:41:36 +0000 (21:41 -0700)]
Move TypeStorage out of the detail namespace
Dialect implementer are expected to inherit from this class when implementing their types. It does not seems right when using MLIR "from the outside" to use directly something from `mlir::detail::`.
PiperOrigin-RevId:
240075769
River Riddle [Mon, 25 Mar 2019 03:35:07 +0000 (20:35 -0700)]
NFC: Rename the 'if' operation in the AffineOps dialect to 'affine.if'.
PiperOrigin-RevId:
240071154
Mehdi Amini [Mon, 25 Mar 2019 03:34:16 +0000 (20:34 -0700)]
Remove `alignas(8) from TypeStorage class
This is here from history at a time where it was bit-packed and storage was dependent on this.
PiperOrigin-RevId:
240071093
Chris Lattner [Mon, 25 Mar 2019 02:53:05 +0000 (19:53 -0700)]
Remove OpPointer, cleaning up a ton of code. This also moves Ops to using
inherited constructors, which is cleaner and means you can now use DimOp()
to get a null op, instead of having to use Instruction::getNull<DimOp>().
This removes another 200 lines of code.
PiperOrigin-RevId:
240068113
Jacques Pienaar [Mon, 25 Mar 2019 02:35:20 +0000 (19:35 -0700)]
Fix missing parenthesis around negation.
This should probably be changed to instead use the negated form (e.g., get predicate + negate it + get resulting template), but this fixes it locally.
PiperOrigin-RevId:
240067116
Mehdi Amini [Mon, 25 Mar 2019 01:48:21 +0000 (18:48 -0700)]
Add a routine to allow registering a dialect without relying on global constructors.
Using global constructors should not be mandatory when possible, clients should be able to register a dialect explicitly when they want.
PiperOrigin-RevId:
240064244
Chris Lattner [Sun, 24 Mar 2019 20:02:43 +0000 (13:02 -0700)]
Push a bunch of 'consts' out of the *Op structure, in prep for removing
OpPointer.
PiperOrigin-RevId:
240044712
Nicolas Vasilache [Sun, 24 Mar 2019 17:45:22 +0000 (10:45 -0700)]
Cleanup ValueHandleArray
We just need a way to unpack ArrayRef<ValueHandle> to ArrayRef<Value*>.
No need to expose this to the user.
This reduces the cognitive overhead for the tutorial.
PiperOrigin-RevId:
240037425
Chris Lattner [Sat, 23 Mar 2019 23:42:01 +0000 (16:42 -0700)]
Deconst-ify MLIRContext, and detemplatize some stuff now that const is gone.
PiperOrigin-RevId:
239976764
Mehdi Amini [Sat, 23 Mar 2019 22:19:51 +0000 (15:19 -0700)]
Add a convenience getContext() method in OpState to reduce boilerplate on clients.
PiperOrigin-RevId:
239972907
Chris Lattner [Sat, 23 Mar 2019 22:09:06 +0000 (15:09 -0700)]
Remove const from Value, Instruction, Argument, and the various methods on the
*Op classes. This is a net reduction by almost 400LOC.
PiperOrigin-RevId:
239972443
Jacques Pienaar [Sat, 23 Mar 2019 17:36:55 +0000 (10:36 -0700)]
Return operand_range instead for generated variadic operands accessor.
PiperOrigin-RevId:
239959381
River Riddle [Sat, 23 Mar 2019 17:12:31 +0000 (10:12 -0700)]
Clarify the comment on valid data during DenseElementsAttr construction.
PiperOrigin-RevId:
239958211
Chris Lattner [Sat, 23 Mar 2019 16:03:07 +0000 (09:03 -0700)]
Now that ConstOpPointer is gone, we can change the various methods generated by
tblgen be non-const. This requires introducing some const_cast's at the
moment, but those (and lots more stuff) will disappear in subsequent patches.
This significantly simplifies those patches because the various tblgen op emitters
get adjusted.
PiperOrigin-RevId:
239954566
Jacques Pienaar [Sat, 23 Mar 2019 12:05:20 +0000 (05:05 -0700)]
Verify first body is not empty before testing last character.
Avoids sigabrt where body is empty.
PiperOrigin-RevId:
239942200
River Riddle [Sat, 23 Mar 2019 07:40:25 +0000 (00:40 -0700)]
Cleanup the construction of attributes and fix a opt-mode bug in DenseElementsAttr when allocating an empty array buffer.
PiperOrigin-RevId:
239926824
Mehdi Amini [Sat, 23 Mar 2019 05:26:01 +0000 (22:26 -0700)]
At missing mlir:: namespace qualifier in front of function definition
This was defining a function in the global namespace instead of the mlir one.
PiperOrigin-RevId:
239918509
Mehdi Amini [Sat, 23 Mar 2019 05:17:10 +0000 (22:17 -0700)]
Add a parserSourceFile function that takes a file path directly
This avoids adding boilerplate around the SourceMgr on the client.
PiperOrigin-RevId:
239918122
Geoffrey Martin-Noble [Sat, 23 Mar 2019 01:03:58 +0000 (18:03 -0700)]
Add tablegen aliases for OpTraits ResultsAreFloatLike and SameOperandsAndResultShape
Startblock:
cl/
239891224 is submitted
PiperOrigin-RevId:
239899356
River Riddle [Sat, 23 Mar 2019 00:54:26 +0000 (17:54 -0700)]
Remove "<label>" from the llvm basic block CHECK names.
PiperOrigin-RevId:
239898185
Jacques Pienaar [Fri, 22 Mar 2019 22:26:05 +0000 (15:26 -0700)]
Start elemental type constraint specification modelling.
Enable users specifying operand type constraint combinations (e.g., considering multiple operands). Some of these will be refactored (particularly the OpBase change and that should also not be needed to be done by most users), but the focus is more on user side (shown in test). The generated code for this does not take any known facts into account or perform any simplification.
Start with 2 primities to specify 1) whether an operand has a specific element type, and 2) whether an operand's element type matches another operands element type.
PiperOrigin-RevId:
239875712
Feng Liu [Fri, 22 Mar 2019 18:22:20 +0000 (11:22 -0700)]
Define the base class for attributes containing types
This attribute has checks for verifying it is an mlir::TypeAttr and the
subclass can specify the mlir::Type as the value.
PiperOrigin-RevId:
239830412
Nicolas Vasilache [Fri, 22 Mar 2019 16:10:01 +0000 (09:10 -0700)]
Rename edsc::EDSCxxxBuilder to edsc::xxxBuilder - NFC
PiperOrigin-RevId:
239805692
Nicolas Vasilache [Fri, 22 Mar 2019 14:31:00 +0000 (07:31 -0700)]
Support composition of symbols in AffineApplyOp
This CL revisits the composition of AffineApplyOp for the special case where a symbol
itself comes from an AffineApplyOp.
This is achieved by rewriting such symbols into dims to allow composition to occur mathematically.
The implementation is also refactored to improve readability.
Rationale for locally rewriting symbols as dims:
================================================
The mathematical composition of AffineMap must always concatenate symbols
because it does not have enough information to do otherwise. For example,
composing `(d0)[s0] -> (d0 + s0)` with itself must produce
`(d0)[s0, s1] -> (d0 + s0 + s1)`.
The result is only equivalent to `(d0)[s0] -> (d0 + 2 * s0)` when
applied to the same mlir::Value* for both s0 and s1.
As a consequence mathematical composition of AffineMap always concatenates
symbols.
When AffineMaps are used in AffineApplyOp however, they may specify
composition via symbols, which is ambiguous mathematically. This corner case
is handled by locally rewriting such symbols that come from AffineApplyOp
into dims and composing through dims.
PiperOrigin-RevId:
239791597
Mehdi Amini [Fri, 22 Mar 2019 06:18:11 +0000 (23:18 -0700)]
Remove declaration and unused reference to non-existent type `TensorTypeStorage` (NFC)
PiperOrigin-RevId:
239743070
Chris Lattner [Fri, 22 Mar 2019 00:53:00 +0000 (17:53 -0700)]
Remove const from mlir::Block.
This also eliminates some incorrect reinterpret_cast logic working around it, and numerous const-incorrect issues (like block argument iteration).
PiperOrigin-RevId:
239712029
Chris Lattner [Thu, 21 Mar 2019 18:57:14 +0000 (11:57 -0700)]
Remove const support from mlir::Region
PiperOrigin-RevId:
239642194
Chris Lattner [Thu, 21 Mar 2019 18:39:22 +0000 (11:39 -0700)]
Continue pushing const out of the core IR types - in this case, remove const
from Function.
PiperOrigin-RevId:
239638635
River Riddle [Thu, 21 Mar 2019 17:03:40 +0000 (10:03 -0700)]
Add support for building a DenseIntElementsAttr with ArrayRef<int64_t> values.
PiperOrigin-RevId:
239616595
Nicolas Vasilache [Thu, 21 Mar 2019 16:59:57 +0000 (09:59 -0700)]
Better document TemplatedIndexedValue
PiperOrigin-RevId:
239615534
Nicolas Vasilache [Thu, 21 Mar 2019 15:44:20 +0000 (08:44 -0700)]
Make edsc::IndexedValue templated - NFC
This allows the indexing sugar to just work naturally with other type of load and store ops than the affine ones we currently have.
This is needed for the EuroLLVM tutorial.
PiperOrigin-RevId:
239602257
Mehdi Amini [Thu, 21 Mar 2019 15:42:06 +0000 (08:42 -0700)]
Add 10 "private" kind ranges for MLIR type kind.
This is useful when developing one or multiple dialects in a private context without having to register them with MLIR Core.
PiperOrigin-RevId:
239601844
Nicolas Vasilache [Thu, 21 Mar 2019 15:25:51 +0000 (08:25 -0700)]
Reserve type range for the Linalg dialect
PiperOrigin-RevId:
239599147
Mehdi Amini [Thu, 21 Mar 2019 15:21:21 +0000 (08:21 -0700)]
Fix class description for Attributes: the instance of the class aren't uniqued, the class has reference semantics.
PiperOrigin-RevId:
239598522
Nicolas Vasilache [Thu, 21 Mar 2019 15:07:15 +0000 (08:07 -0700)]
Add intrinsics for constants
PiperOrigin-RevId:
239596595
Nicolas Vasilache [Thu, 21 Mar 2019 14:32:51 +0000 (07:32 -0700)]
Improve comment for `augmentMapAndBounds`
Followup from a previous CL.
PiperOrigin-RevId:
239591775
Mehdi Amini [Thu, 21 Mar 2019 05:34:49 +0000 (22:34 -0700)]
Add comment describing what IREE (IR Execution Engine) stands for in the dialect registration.
PiperOrigin-RevId:
239539263
Chris Lattner [Thu, 21 Mar 2019 04:14:59 +0000 (21:14 -0700)]
Continue pushing const out of the IR types - removing the notion of a 'const
Module'. NFC.
PiperOrigin-RevId:
239532885
Jacques Pienaar [Thu, 21 Mar 2019 03:28:58 +0000 (20:28 -0700)]
Add contributing file.
Initially no external contributions will be accepted (until post dev meeting at
least).
PiperOrigin-RevId:
239528594
Chris Lattner [Thu, 21 Mar 2019 00:48:43 +0000 (17:48 -0700)]
Move to new `const` model, part 1: remove ConstOpPointer.
This eliminate ConstOpPointer (but keeps OpPointer for now) by making OpPointer
implicitly launder const in a const incorrect way. It will eventually go away
entirely, this is a progressive step towards the new const model.
PiperOrigin-RevId:
239512640
Chris Lattner [Thu, 21 Mar 2019 00:32:52 +0000 (17:32 -0700)]
Add a nice quote from Bjarke to summarize the const situation.
PiperOrigin-RevId:
239510578
Lei Zhang [Thu, 21 Mar 2019 00:25:34 +0000 (17:25 -0700)]
[TableGen] Generate op declaration and definition into different files
Previously we emit both op declaration and definition into one file and include it
in *Ops.h. That pulls in lots of implementation details in the header file and we
cannot hide symbols local to implementation. This CL splits them to provide a cleaner
interface.
The way how we define custom builders in TableGen is changed accordingly because now
we need to distinguish signatures and implementation logic. Some custom builders with
complicated logic now can be moved to be implemented in .cpp entirely.
PiperOrigin-RevId:
239509594
Chris Lattner [Wed, 20 Mar 2019 20:32:39 +0000 (13:32 -0700)]
Add a "Usage of Const in MLIR" doc, explaining the rationale for the design
point we're moving the compiler to.
PiperOrigin-RevId:
239462779
Nicolas Vasilache [Wed, 20 Mar 2019 17:23:04 +0000 (10:23 -0700)]
Properly propagate induction variable in tiling
This CL fixes an issue where cloned loop induction variables were not properly
propagated and beefs up the corresponding test.
PiperOrigin-RevId:
239422961
Lei Zhang [Wed, 20 Mar 2019 16:01:58 +0000 (09:01 -0700)]
Change getBroadcastedShape() to return result shape via parameter
This is a more efficient way than returning SmallVector directly.
PiperOrigin-RevId:
239407024
Jacques Pienaar [Tue, 19 Mar 2019 19:05:11 +0000 (12:05 -0700)]
Cleanup for changes failing with std=c++11
The static constexpr were failing with undefined reference due to lacking definition at namespace scope.
PiperOrigin-RevId:
239241157
River Riddle [Tue, 19 Mar 2019 17:59:02 +0000 (10:59 -0700)]
Add support for a standard TupleType. Though this is a standard type, it merely provides a common mechanism for representing tuples in MLIR. It is up to dialect authors to provides operations for manipulating them, e.g. extract_tuple_element.
TupleType has the following form:
tuple-type ::= `tuple` `<` (type (`,` type)*)? `>`
Example:
// Empty tuple.
tuple<>
// Single element.
tuple<i32>
// Multi element.
tuple<i32, tuple<f32>, i16>
PiperOrigin-RevId:
239226021
Jacques Pienaar [Tue, 19 Mar 2019 15:45:06 +0000 (08:45 -0700)]
Remove some statements that required >C++11, add includes and qualify names. NFC.
PiperOrigin-RevId:
239197784
Dimitrios Vytiniotis [Tue, 19 Mar 2019 08:19:01 +0000 (01:19 -0700)]
Avoiding allocations during argument attribute conversion.
PiperOrigin-RevId:
239144675
Jacques Pienaar [Tue, 19 Mar 2019 02:26:04 +0000 (19:26 -0700)]
Remove index free function
Avoids including function in C++ side that resulted in OSS C++ errors:
include/mlir-c/Core.h:228:16: error: functions that differ only in their
return type cannot be overloaded
edsc_indexed_t index(edsc_indexed_t indexed, edsc_expr_list_t indices);
~~~~~~~~~~~~~~ ^
/usr/include/string.h:484:14: note: previous declaration is here
extern char *index (const char *__s, int __c)
And as these are going away soon, just removing the function requires the least changes.
PiperOrigin-RevId:
239110470
River Riddle [Mon, 18 Mar 2019 20:42:55 +0000 (13:42 -0700)]
Add support for parsing true/false inside of a splat tensor literal.
PiperOrigin-RevId:
239052061
River Riddle [Mon, 18 Mar 2019 18:56:18 +0000 (11:56 -0700)]
Give PassInstrumentor a SmartMutex to lock access to the held instrumentations.
PiperOrigin-RevId:
239031524
Jacques Pienaar [Mon, 18 Mar 2019 17:21:57 +0000 (10:21 -0700)]
Change trait verification to support older clang & gcc.
This was resulting in an error:
explicit specialization of 'BaseProperties' in class scope
pre clang-7.0 (C++ DR 275).
PiperOrigin-RevId:
239010696
Jacques Pienaar [Mon, 18 Mar 2019 16:26:20 +0000 (09:26 -0700)]
Cleanups for OSS build.
PiperOrigin-RevId:
238999629
Nicolas Vasilache [Mon, 18 Mar 2019 15:07:19 +0000 (08:07 -0700)]
Cleanups Vectorize and SliceAnalysis - NFC
This CL cleans up and refactors super-vectorization and slice analysis.
PiperOrigin-RevId:
238986866
Jacques Pienaar [Mon, 18 Mar 2019 14:54:20 +0000 (07:54 -0700)]
Change Value to NamedTypeConstraint and use TypeConstraint.
Previously Value was a pair of name & Type, but for operands/result a TypeConstraint rather then a Type is specified. Update C++ side to match declarative side.
PiperOrigin-RevId:
238984799
Nicolas Vasilache [Mon, 18 Mar 2019 13:52:23 +0000 (06:52 -0700)]
Port Tablegen'd reference implementation of Add to declarative builders.
PiperOrigin-RevId:
238977252
Nicolas Vasilache [Mon, 18 Mar 2019 13:26:05 +0000 (06:26 -0700)]
Remove LOAD/STORE/RETURN boilerplate in declarative builders.
This CL introduces a ValueArrayHandle helper to manage the implicit conversion
of ArrayRef<ValueHandle> -> ArrayRef<Value*> by converting first to ValueArrayHandle.
Without this, boilerplate operations that take ArrayRef<Value*> cannot be removed easily.
This all seems to boil down to decoupling Value from Type.
Alternative solutions exist (e.g. MLIR using Value by value everywhere) but they would be very intrusive. This seems to be the lowest impedance change.
Intrinsics are also lowercased by popular demand.
PiperOrigin-RevId:
238974125
Nicolas Vasilache [Mon, 18 Mar 2019 13:03:00 +0000 (06:03 -0700)]
Port LowerVectorTransfers from EDSC + AST to declarative builders
This CL removes the dependency of LowerVectorTransfers on the AST version of EDSCs which will be retired.
This exhibited a pretty fundamental staging difference in AST-based vs declarative based emission.
Since the delayed creation with an AST was staged, the loop order came into existence after the clipping expressions were computed.
This now changes as the loops first need to be created declaratively in fixed order and then the clipping expressions are created.
Also, due to lack of staging, coalescing cannot be done on the fly anymore and
needs to be done either as a pre-pass (current implementation) or as a local transformation on the generated IR (future work).
Tests are updated accordingly.
PiperOrigin-RevId:
238971631
River Riddle [Sun, 17 Mar 2019 03:34:23 +0000 (20:34 -0700)]
Moving the IR printing and execution timing options out of mlir-opt and into lib/Pass. We now expose two methods: registerPassManagerCLOptions and applyPassManagerCLOptions; to allow for multiple different users (mlir-opt, etc.) to opt-in to this common functionality.
PiperOrigin-RevId:
238836911
River Riddle [Sat, 16 Mar 2019 22:07:08 +0000 (15:07 -0700)]
Replace the usages of llvm::Timer in PassTiming in favor of a simple nested Timer. The output view is simplified to just display the Wall Time. This new infrastructure will greatly simplify the amount of work needed to support multi-threaded execution timing.
PiperOrigin-RevId:
238819218
Jacques Pienaar [Sat, 16 Mar 2019 20:49:57 +0000 (13:49 -0700)]
Move getSuccessorOperandIndex out of line.
PiperOrigin-RevId:
238814769
Jacques Pienaar [Fri, 15 Mar 2019 17:20:03 +0000 (10:20 -0700)]
Add numeric include for using std::accumulate
PiperOrigin-RevId:
238664219
River Riddle [Fri, 15 Mar 2019 16:24:05 +0000 (09:24 -0700)]
Cache the simplified attributes in SimplifyAffineStructures to avoid redundant simplifications, as well as unnecessary accesses to the MLIRContext.
PiperOrigin-RevId:
238654325
Jacques Pienaar [Fri, 15 Mar 2019 15:55:35 +0000 (08:55 -0700)]
Qualify DenseMap in AnalysisManager.
PiperOrigin-RevId:
238649794
Jacques Pienaar [Fri, 15 Mar 2019 14:35:27 +0000 (07:35 -0700)]
Remove unnecessary headers from mlir-opt.
PiperOrigin-RevId:
238639013
River Riddle [Thu, 14 Mar 2019 21:44:58 +0000 (14:44 -0700)]
Add an instrumentation for conditionally printing the IR before and after pass execution. This instrumentation can be added directly to the PassManager via 'enableIRPrinting'. mlir-opt exposes access to this instrumentation via the following flags:
* print-ir-before=(comma-separated-pass-list)
- Print the IR before each of the passes provided within the pass list.
* print-ir-before-all
- Print the IR before every pass in the pipeline.
* print-ir-after=(comma-separated-pass-list)
- Print the IR after each of the passes provided within the pass list.
* print-ir-after-all
- Print the IR after every pass in the pipeline.
* print-ir-module-scope
- Always print the Module IR, even for non module passes.
PiperOrigin-RevId:
238523649
River Riddle [Thu, 14 Mar 2019 21:14:14 +0000 (14:14 -0700)]
Rename allocator to identifierAllocator and add an identifierMutex to make identifier uniquing thread safe. This also adds a general purpose 'contextMutex' to protect access to the rest of the miscellaneous parts of the MLIRContext, e.g. diagnostics, dialect registration, etc. This is step 5/5 of making the MLIRContext thread-safe.
PiperOrigin-RevId:
238516697
River Riddle [Thu, 14 Mar 2019 21:14:00 +0000 (14:14 -0700)]
Give the Location classes their own SmartRWMutex and make sure that they are using the locationAllocator. This is step 4/N to making MLIRContext thread-safe.
PiperOrigin-RevId:
238516646
River Riddle [Thu, 14 Mar 2019 21:13:45 +0000 (14:13 -0700)]
Give the affine structures, AffineMap/AffineExpr/IntegerSet/etc, their own BumpPtrAllocator and SmartMutex to make them thread-safe. This is step 3/N to making MLIRContext thread-safe.
PiperOrigin-RevId:
238516596
River Riddle [Thu, 14 Mar 2019 21:13:29 +0000 (14:13 -0700)]
Give Attributes their own BumpPtrAllocator and SmartRWMutex to make them thread-safe. This is step 2/N to making the MLIRContext thread-safe.
PiperOrigin-RevId:
238516542
River Riddle [Thu, 14 Mar 2019 20:56:45 +0000 (13:56 -0700)]
Add an 'Instruction::create' overload that accepts an existing NamedAttributeList. This avoids the need to unique an attribute list if one already exists, e.g. when cloning an existing instruction.
PiperOrigin-RevId:
238512499
River Riddle [Thu, 14 Mar 2019 18:34:12 +0000 (11:34 -0700)]
Optimize the implementation of AffineExprConstantFolder to avoid the redundant creation of IntegerAttrs and IndexType. This becomes a much bigger performance issue when MLIRContext is thread-safe; as each unnecessary call may need to lock a mutex.
PiperOrigin-RevId:
238484632
Alex Zinenko [Thu, 14 Mar 2019 17:38:44 +0000 (10:38 -0700)]
Rename BlockList into Region
NFC. This is step 1/n to specifying regions as parts of any operation.
PiperOrigin-RevId:
238472370
Alex Zinenko [Thu, 14 Mar 2019 12:04:52 +0000 (05:04 -0700)]
Python bindings: expose boolean and comparison operators
In particular, expose comparison operators as Python operator overloads on
ValueHandles. The comparison currently emits signed integer comparisons only,
which is compatible with the behavior of emitter-based EDSC interface. This is
sub-optimal and must be reconsidered in the future. Note that comparison
operators are not overloaded in the C++ declarative builder API precisely
because this avoids the premature decision on the signedness of comparisons.
Implement the declarative construction of boolean expressions using
ValueHandles by overloading the boolean operators in the `op` namespace to
differentiate between `operator!` for nullity check and for boolean negation.
The operands must be of i1 type. Also expose boolean operations as Python
operator overloads on ValueHandles.
PiperOrigin-RevId:
238421615
Alex Zinenko [Thu, 14 Mar 2019 12:04:38 +0000 (05:04 -0700)]
Python bindings: expose various Ops through declarative builders
In particular, expose `cond_br`, `select` and `call` operations with syntax
similar to that of the previous emitter-based EDSC interface. These are
provided for backwards-compatibility. Ideally, we want them to be
Table-generated from the Op definitions when those definitions are declarative.
Additionally, expose the ability to construct any op given its canonical name,
which also exercises the construction of unregistered ops.
PiperOrigin-RevId:
238421583
Alex Zinenko [Thu, 14 Mar 2019 12:04:20 +0000 (05:04 -0700)]
Python bindings: expose IndexedValue
Expose edsc::IndexedValue using a syntax smilar to that of edsc::Indexed to
ensure backwards-compatibility. It remains possible to write array-indexed
loads and stores as
C.store([i, j], A.load([i, k]) * B.load([k, j]))
after taking a "view" of some value handle using IndexedValue as
A = IndexedValue(originalValueHandle)
provided that all indices are also value handles.
PiperOrigin-RevId:
238421544
Alex Zinenko [Thu, 14 Mar 2019 12:04:03 +0000 (05:04 -0700)]
Python bindings: use MLIR operations to define constant values
In the original implementation, constants could be bound to EDSC expressions in
the binder, independently from other MLIR Values. A rework of EDSC including
early typing provided the functionality to use MLIR's `constant` operation to
define typed constants instead of binding them separately, but only used it for
index types. The new declarative builder implementation followed by providing
a call for building `constant` operations of index types but nothing more.
Expose similar builders for integers, floats and functions to match the what
binders allow one to use.
PiperOrigin-RevId:
238421508
Alex Zinenko [Thu, 14 Mar 2019 12:02:21 +0000 (05:02 -0700)]
Python bindings: make FunctionContext behave more like BlockContext
Provide a function `arg` that returns the function argument as a value handle,
similar to block arguments. This makes function context managers in Python
similar to block context managers, which is more consistent given that the
function context manager sets the insertion point to the first block of the
function and that arguments of that block are those of the function. This
prepares the removal of PythonMLIREmitter class and its bind_function_arguments
helper.
Additionally, provide a helper method in PythonMLIRModule to define a function
and immediately create a context for it. Update the tests that are already
using context managers to use the function context manager instead of creating
the function manually.
PiperOrigin-RevId:
238421087
Uday Bondhugula [Tue, 12 Mar 2019 23:31:22 +0000 (16:31 -0700)]
Change parallelism detection test pass to emit a note
- emit a note on the loop being parallel instead of setting a loop attribute
- rename the pass -test-detect-parallel (from -detect-parallel)
PiperOrigin-RevId:
238122847
Uday Bondhugula [Tue, 12 Mar 2019 23:09:11 +0000 (16:09 -0700)]
Change getMemoryFootprintBytes emitError to a warning
- this is really not a hard error; emit a warning instead (for inability to compute
footprint due to the union failing due to unimplemented cases)
- remove a misleading warning from LoopFusion.cpp
PiperOrigin-RevId:
238118711
Feng Liu [Tue, 12 Mar 2019 20:55:50 +0000 (13:55 -0700)]
[TableGen] Support nested dag attributes arguments in the result pattern
Add support to create a new attribute from multiple attributes. It extended the
DagNode class to represent attribute creation dag. It also changed the
RewriterGen::emitOpCreate method to support this nested dag emit.
An unit test is added.
PiperOrigin-RevId:
238090229
River Riddle [Tue, 12 Mar 2019 20:08:48 +0000 (13:08 -0700)]
Refactor pass timing so that it is toggled on the passmanager via 'enableTiming'. This also makes the pipeline view the default display mode.
PiperOrigin-RevId:
238079916
Uday Bondhugula [Tue, 12 Mar 2019 17:52:09 +0000 (10:52 -0700)]
Fix misc bugs / TODOs / other improvements to analysis utils
- fix for getConstantBoundOnDimSize: floordiv -> ceildiv for extent
- make getConstantBoundOnDimSize also return the identifier upper bound
- fix unionBoundingBox to correctly use the divisor and upper bound identified by
getConstantBoundOnDimSize
- deal with loop step correctly in addAffineForOpDomain (covers most cases now)
- fully compose bound map / operands and simplify/canonicalize before adding
dim/symbol to FlatAffineConstraints; fixes false positives in -memref-bound-check; add
test case there
- expose mlir::isTopLevelSymbol from AffineOps
PiperOrigin-RevId:
238050395
River Riddle [Tue, 12 Mar 2019 17:00:21 +0000 (10:00 -0700)]
Give the TypeUniquer its own BumpPtrAllocator and a SmartRWMutex to make it thread-safe. This is step 1/N to making the MLIRContext thread-safe.
PiperOrigin-RevId:
238037814
River Riddle [Tue, 12 Mar 2019 16:40:04 +0000 (09:40 -0700)]
NFC: Remove a stray print in mlir::buildTripCountMapAndOperands.
PiperOrigin-RevId:
238033349
Lei Zhang [Tue, 12 Mar 2019 16:29:12 +0000 (09:29 -0700)]
[TableGen] Sort OpBase.td attribute kinds and refine some comments
This CL sorts attribute kinds in OpBase.td according to a logical order: simple
cases ahead of complicated ones. The logic of attribute kinds involved are
completely untouched.
Comments on AttrConstraint and Attr are revised slightly.
PiperOrigin-RevId:
238031275
Lei Zhang [Tue, 12 Mar 2019 16:25:44 +0000 (09:25 -0700)]
[TableGen] Add common I<n>Tensor, F<n>Tensor, and I64Attr definitions
This CL also changes IntegerAttrBase to use APInt as return value to defer bitwidth
handling to API call sites and be consistent with FloatAttrBase. Call sites are
adjusted accordingly.
PiperOrigin-RevId:
238030614
Uday Bondhugula [Tue, 12 Mar 2019 15:00:52 +0000 (08:00 -0700)]
Extend loop unrolling and unroll-jamming to non-matching bound operands and
multi-result upper bounds, complete TODOs, fix/improve test cases.
- complete TODOs for loop unroll/unroll-and-jam. Something as simple as
"for %i = 0 to %N" wasn't being unrolled earlier (unless it had been written
as "for %i = ()[s0] -> (0)()[%N] to %N"; addressed now.
- update/replace getTripCountExpr with buildTripCountMapAndOperands; makes it
more powerful as it composes inputs into it
- getCleanupLowerBound and getUnrolledLoopUpperBound actually needed the same
code; refactor and remove one.
- reorganize test cases, write previous ones better; most of these changes are
"label replacements".
- fix wrongly labeled test cases in unroll-jam.mlir
PiperOrigin-RevId:
238014653
Alex Zinenko [Tue, 12 Mar 2019 13:55:03 +0000 (06:55 -0700)]
Python bindings: provide context managers for the Blocks
Expose EDSC block builders as Python context managers, similarly to loop
builders. Note that blocks, unlike loops, are addressable and may need to be
"declared" without necessarily filling their bodies with instructions. This is
the case, for example, when branching to a new block from the existing block.
Therefore, creating the block context manager immediately creates the block
(unless the manager captures an existing block) by creating and destroying the
block builder. With this approach, one can either fill in the block and refer
to it later leveraging Python's dynamic variable lookup
with BlockContext([indexType]) as b:
op(...) # operation inside the block
ret()
op(...) # operation outside the block (in the function entry block)
br(b, [...]) # branching to the block created above
or declare the block contexts upfront and enter them on demand
bb1 = BlockContext() # empty block created in the surrounding function
bb2 = BlockContext() # context
cond_br(bb1.handle, [], bb2.handle, []) # branch to blocks from here
with bb1:
op(...) # operation inside the first block
with bb2:
op(...) # operation inside the second block
with bb1:
op(...) # append operation to the first block
Additionally, one can create multiple throw-away contexts that append to the
same block
with BlockContext() as b:
op(...) # operation inside the block
with BlockContext(appendTo(b)):
op(...) # new context appends to the block
which has a potential of being extended to control the insertion point of the
block at a finer level of granularity.
PiperOrigin-RevId:
238005298
Alex Zinenko [Tue, 12 Mar 2019 13:03:26 +0000 (06:03 -0700)]
Python bindings: drop third_party/ in includes
Historically, Python bindings were using full path including third_party for
most headers but not all of them. This is inconsistent with the rest of MLIR.
Drop the prefix path in #include directives.
PiperOrigin-RevId:
237999346
MLIR Team [Tue, 12 Mar 2019 02:47:41 +0000 (19:47 -0700)]
Clean up some stray mlfunc/cfgfunc leftovers.
PiperOrigin-RevId:
237936610
River Riddle [Tue, 12 Mar 2019 00:26:45 +0000 (17:26 -0700)]
Add documentation for the pass instrumentation framework to the WritingAPass document.
PiperOrigin-RevId:
237919897
River Riddle [Mon, 11 Mar 2019 22:56:34 +0000 (15:56 -0700)]
NFC: Remove old comment referencing CFG/EXT/ML functions.
PiperOrigin-RevId:
237902039
Nicolas Vasilache [Mon, 11 Mar 2019 19:48:16 +0000 (12:48 -0700)]
Minor changes to the EDSC API NFC
This CL makes some minor changes to the declarative builder Helpers:
1. adds lb, ub, step methods to MemRefView to avoid always having to go through std::get + range;
2. drops MemRefView& from IndexedValue which was just creating ownership concerns. Instead, an IndexedValue only needs to keep track of the ValueHandle from which a MemRefView can be constructed on-demand if necessary.
PiperOrigin-RevId:
237861493
Lei Zhang [Mon, 11 Mar 2019 18:36:20 +0000 (11:36 -0700)]
Allow input and output to have different element types for broadcastable ops
TensorFlow comparison ops like tf.Less supports broadcast behavior but the result
type have different element types as the input types. Extend broadcastable trait
to allow such cases. Added tf.Less to demonstrate it.
PiperOrigin-RevId:
237846127