summaryrefslogtreecommitdiffstats
path: root/mlir/lib/IR
Commit message (Collapse)AuthorAgeFilesLines
...
* NFC: Remove unused default cl::opt value.River Riddle2019-10-081-2/+1
| | | | | | The default value is never used as the value of the elide option is only used if it has an occurrence. PiperOrigin-RevId: 273545143
* Update upgrade some uses of mlir::interleave API to take container argument ↵Jing Pu2019-10-071-1/+1
| | | | | | directly. PiperOrigin-RevId: 273446814
* Add a flag to the AsmPrinter for eliding large ElementsAttrs.River Riddle2019-10-071-2/+42
| | | | | | Some modules may have extremely large ElementsAttrs, which makes debugging involving IR dumping extremely slow and painful. This change adds a flag that will elide ElementsAttrs with a "large"(as defined by the user) number of elements by printing "..." instead of the element data. PiperOrigin-RevId: 273413100
* Add a new class, OpPrintingFlags, to enable programmatic control of ↵River Riddle2019-10-071-22/+64
| | | | | | | | Operation::print behavior. This allows for controlling the behavior of the AsmPrinter programmatically, instead of relying exclusively on cl::opt flags. This will also allow for more fine-tuned control of printing behavior per callsite, instead of being applied globally. PiperOrigin-RevId: 273368361
* Change Block::getParent() to be a const function. This is only necessary ↵Christian Sigg2019-10-071-1/+3
| | | | | | because ilist_node_with_parent specifically requires a 'getParent() const' method. If/When ilist_node removes this constraint we should drop the const to fit the rest of the MLIR const model. PiperOrigin-RevId: 273316153
* Add OpaqueLoc to MLIR locations.MLIR Team2019-10-074-1/+58
| | | | | | | | | See RFC: https://groups.google.com/a/tensorflow.org/forum/#!topic/mlir/xE2IzfhE3Wg. Opaque location stores two pointers, one of them points to some data structure that is external to MLIR, and the other one is unique for each type and represents type id of that data structure. OpaqueLoc also stores an optional location that can be used if the first one is not suitable. OpaqueLoc is managed similar to FileLineColLoc. It is passed around by MLIR transformations and can be used in compound locations like CallSiteLoc. PiperOrigin-RevId: 273266510
* Allow element type traits to operate on scalarsGeoffrey Martin-Noble2019-10-051-22/+8
| | | | | | | | This allows confirming that a scalar argument has the same element type as a shaped one. It's easy to validate a type is shaped on its own if that's desirable, so this shouldn't make that use case harder. This matches the behavior of other traits that operate on element type (e.g. AllElementTypesMatch). Also this makes the code simpler because now we just use getElementTypeOrSelf. Verified that all uses in core already check the type is shaped in another way. PiperOrigin-RevId: 273068507
* Replace constexpr MemRefType::kDynamicStrideOrOffset by a ↵Nicolas Vasilache2019-10-041-8/+8
| | | | | | | | | | MemRefType:;getDynamicStrideOrOffset() method - NFC This fixes global ODR-use issues, some of which manifest in Parser.cpp. Fixes tensorflow/mlir#167. PiperOrigin-RevId: 272886347
* Fix typos, NFC.Christian Sigg2019-10-045-8/+8
| | | | PiperOrigin-RevId: 272851237
* Generalize parse/printBinaryOp to parse/printOneResultOp.Christian Sigg2019-10-031-9/+10
| | | | PiperOrigin-RevId: 272722539
* Add syntactic sugar for strided memref parsing.Nicolas Vasilache2019-10-031-1/+7
| | | | | | | | | | | | | | | This CL implements the last remaining bit of the [strided memref proposal](https://groups.google.com/a/tensorflow.org/forum/#!topic/mlir/MaL8m2nXuio). The syntax is a bit more explicit than what was originally proposed and resembles: `memref<?x?xf32, offset: 0 strides: [?, 1]>` Nonnegative strides and offsets are currently supported. Future extensions will include negative strides. This also gives a concrete example of syntactic sugar for the ([RFC] Proposed Changes to MemRef and Tensor MLIR Types)[https://groups.google.com/a/tensorflow.org/forum/#!topic/mlir/-wKHANzDNTg]. The underlying implementation still uses AffineMap layout. PiperOrigin-RevId: 272717437
* Make Module::getName return Optional<StringRef>Alex Zinenko2019-10-031-14/+12
| | | | | | | | Module names are optional so it makes more sense to take and return an optional any time the name is involved. Also update the language reference to reflect the module names. PiperOrigin-RevId: 272684698
* Give modules a nameAlex Zinenko2019-10-031-7/+31
| | | | | | | | | | Modules are now Ops and, as such, can be nested. They do not produce an SSA value so there is no possibility to refer to them in the IR. Introduce support for symbol names attached to the module Op so that it can be referred to using SymbolRefAttrs. The name is optional, for example the implicit top-level module does not have a name. PiperOrigin-RevId: 272671600
* Disallow index types in memrefs.Alex Zinenko2019-10-031-0/+7
| | | | | | | | | | | | | | | | | As specified in the MLIR language reference and rationale documents, `memref` types should not be allowed to have `index` as element types. As observed in https://groups.google.com/a/tensorflow.org/forum/#!msg/mlir/P49hVWqTMNc/nW89a4i_AgAJ this restriction was lifted when canonicalization unit tests for affine operations were introduced, without sufficient motivation to lift the restriction itself. The test in question can be trivially rewritten (return the value from a function instead of storing it to prevent DCE from removing the producer operation) and the restriction put back in place. If `memref<...x index>` is relevant for some use cases, the relaxation of the type system can be implemented separately with appropriate modifications to the documentation. PiperOrigin-RevId: 272607043
* Extract MemRefType::getStridesAndOffset as a free function and fix dynamic ↵Nicolas Vasilache2019-10-021-9/+9
| | | | | | | | offset determination. This also adds coverage with a missing test, which uncovered a bug in the conditional for testing whether an offset is dynamic or not. PiperOrigin-RevId: 272505798
* Unify Linalg types by using strided memrefsNicolas Vasilache2019-10-011-27/+88
| | | | | | | This CL finishes the implementation of the Linalg + Affine type unification of the [strided memref RFC](https://groups.google.com/a/tensorflow.org/forum/#!topic/mlir/MaL8m2nXuio). As a consequence, the !linalg.view type, linalg::DimOp, linalg::LoadOp and linalg::StoreOp can now disappear and Linalg can use standard types everywhere. PiperOrigin-RevId: 272187165
* Add verification error message for ops that require at least one operand or ↵Christian Sigg2019-10-011-5/+8
| | | | | | result. PiperOrigin-RevId: 272153634
* Normalize MemRefType lowering to LLVM as strided MemRef descriptorNicolas Vasilache2019-09-301-4/+4
| | | | | | | | | | | | | | | | | | | | | This CL finishes the implementation of the lowering part of the [strided memref RFC](https://groups.google.com/a/tensorflow.org/forum/#!topic/mlir/MaL8m2nXuio). Strided memrefs correspond conceptually to the following templated C++ struct: ``` template <typename Elem, size_t Rank> struct { Elem *ptr; int64_t offset; int64_t sizes[Rank]; int64_t strides[Rank]; }; ``` The linearization procedure for address calculation for strided memrefs is the same as for linalg views: `base_offset + SUM_i index_i * stride_i`. The following CL will unify Linalg and Standard by removing !linalg.view in favor of strided memrefs. PiperOrigin-RevId: 272033399
* Fix MemRefType::getStrides corner caseNicolas Vasilache2019-09-301-9/+45
| | | | | | | | MemRefType::getStrides uses AffineExpr::walk which operates in post-order from the leaves. In order to compute strides properly, it needs to escape on terminal nodes and analyze binary ops only. This did not work for AffineExpr that consist of a single term (i.e. without a binary op). This CL fixes the corner case and adds relevant tests. PiperOrigin-RevId: 271975746
* Switch explicit create methods to match generated build's orderJacques Pienaar2019-09-281-6/+6
| | | | | | The generated build methods have result type before the arguments (operands and attributes, which are also now adjacent in the explicit create method). This also results in changing the create method's ordering to match most build method's ordering. PiperOrigin-RevId: 271755054
* Append a newline when dumping a Value.Yanan Cao2019-09-271-1/+4
| | | | | | This is more consistent with other dump methods. Otherwise successive Value dumps are concatenated in same line, hurting readability. PiperOrigin-RevId: 271669846
* Add initial callgraph support.River Riddle2019-09-231-0/+30
| | | | | | | | | | | | | | Using the two call interfaces, CallOpInterface and CallableOpInterface, this change adds support for an initial multi-level CallGraph. This call graph builds a set of nodes for each callable region, and connects them via edges. An edge may be any of the following types: * Abstract - An edge not produced by a call operation, used for connecting to internal nodes from external nodes. * Call - A call edge is an edge defined via a call-like operation. * Child - This is an artificial edge connecting nested callgraph nodes. This callgraph will be used, and improved upon, to begin supporting more interesting interprocedural analyses and transformation. In a followup, this callgraph will be used to support more complex inlining support. PiperOrigin-RevId: 270724968
* Add interfaces for call-like/callable operations.River Riddle2019-09-231-1/+1
| | | | | | | | | | | These two operation interfaces will be used in a followup to support building a callgraph: * CallOpInterface - Operations providing this interface are call-like, and have a "call" target. A call target may be a symbol reference, via SymbolRefAttr, or a SSA value. * CallableOpInterface - Operations providing this interfaces define destinations to call-like operations, e.g. FuncOp. These operations may define any number of callable regions. PiperOrigin-RevId: 270723300
* Refactor DiagnosticEngine to support multiple registered diagnostic handlers.River Riddle2019-09-231-67/+69
| | | | | | | | | | | | This fixes a problem with current save-restore pattern of diagnostics handlers, as there may be a thread race between when the previous handler is destroyed. For example, this occurs when using multiple ParallelDiagnosticHandlers asynchronously: Handler A Handler B | - LifeTime - | Restore A here. Handler C | --- LifeTime ---| Restore B after it has been destroyed. The new design allows for multiple handlers to be registered in a stack like fashion. Handlers can return success() to signal that they have fully processed a diagnostic, or failure to propagate otherwise. PiperOrigin-RevId: 270720625
* Fix a number of Clang-Tidy warnings.Christian Sigg2019-09-232-2/+2
| | | | PiperOrigin-RevId: 270632324
* Upgrade/fix/simplify store to load forwardingUday Bondhugula2019-09-211-0/+4
| | | | | | | | | | | | | | | | - fix store to load forwarding for a certain set of cases (where forwarding shouldn't have happened); use AffineValueMap difference based MemRefAccess equality checking; utility logic is also greatly simplified - add missing equality/inequality operators for AffineExpr ==/!= ints - add == != operators on MemRefAccess Closes tensorflow/mlir#136 COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/136 from bondhugula:store-load-forwarding d79fd1add8bcfbd9fa71d841a6a9905340dcd792 PiperOrigin-RevId: 270457011
* NFC: Pass OpAsmPrinter by reference instead of by pointer.River Riddle2019-09-205-37/+36
| | | | | | MLIR follows the LLVM style of pass-by-reference. PiperOrigin-RevId: 270401378
* NFC: Pass OperationState by reference instead of by pointer.River Riddle2019-09-204-40/+40
| | | | | | MLIR follows the LLVM convention of passing by reference instead of by pointer. PiperOrigin-RevId: 270396945
* NFC: Pass OpAsmParser by reference instead of by pointer.River Riddle2019-09-204-51/+50
| | | | | | MLIR follows the LLVM style of pass-by-reference. PiperOrigin-RevId: 270315612
* Use SmallVectorImpl in getStridesNicolas Vasilache2019-09-201-1/+1
| | | | | | No need to force a particular size on the user of the API. PiperOrigin-RevId: 270310570
* Add utility to extract strides from layout map in MemRefType.Nicolas Vasilache2019-09-201-0/+147
| | | | | | | | | | The RFC for unifying Linalg and Affine compilation passes into an end-to-end flow discusses the notion of a strided MemRef (https://groups.google.com/a/tensorflow.org/forum/#!topic/mlir/MaL8m2nXuio). This CL adds helper functions to extract strides from the layout map which in turn will allow converting between a strided form of the type and a layout map. For now strides are only computed on a single affine map with a single result (i.e. the closed subset of linearization maps that are compatible with striding semantics). This restriction will be reevaluated / lifted in the future based on concrete use cases. PiperOrigin-RevId: 270284686
* NFC: Remove stray logging from ~Block().River Riddle2019-09-181-5/+0
| | | | PiperOrigin-RevId: 269941815
* Fix nested dominance relationship between parent results and child operations.River Riddle2019-09-181-0/+9
| | | | | | This modifies DominanceInfo::properlyDominates(Value *value, Operation *op) to return false if the value is defined by a parent operation of 'op'. This prevents using values defined by the parent operation from within any child regions. PiperOrigin-RevId: 269934920
* Add convenience methods to create i8 and i16 attributes in Builder.Jing Pu2019-09-141-0/+8
| | | | PiperOrigin-RevId: 269120226
* NFC: Fix stray character in error message: 1 -> 'River Riddle2019-09-141-1/+1
| | | | PiperOrigin-RevId: 269091468
* Verify that ModuleOps only contain dialect specific attributes.River Riddle2019-09-131-0/+8
| | | | | | ModuleOp has no expected operations, so only dialect-specific attributes are valid. PiperOrigin-RevId: 269020062
* Forward diagnostics from untracked threads in ParallelDiagnosticHandler.River Riddle2019-09-131-4/+20
| | | | | | This allows for the use of multiple ParallelDiagnosticHandlers without having them conflict with each other. PiperOrigin-RevId: 268967407
* [spirv] Add support for spv.loop (de)serializationLei Zhang2019-09-111-0/+8
| | | | | | | | This CL adds support for serializing and deserializing spv.loop ops. This adds support for spv.Branch and spv.BranchConditional op (de)serialization, too, because they are needed for spv.loop. PiperOrigin-RevId: 268536962
* Add pass generate per block in a function a GraphViz Dot graph with ops as nodesJacques Pienaar2019-09-091-0/+43
| | | | | | | | | | | * Add GraphTraits that treat a block as a graph, Operation* as node and use-relationship for edges; - Just basic graph output; * Add use iterator to iterate over all uses of an Operation; * Add testing pass to generate op graph; This does not support arbitrary operations other than function nor nested regions yet. PiperOrigin-RevId: 268121782
* Integer set + operands / affine if op canonicalizationUday Bondhugula2019-09-051-1/+21
| | | | | | | | | | | | | | | | | | | | | | - turn canonicalizeMapAndOperands into a template that works on both sets and maps, and use it to introduce a utility to canonicalize an affine integer set and its operands - add pattern to canonicalize affine if op's. - rename IntegerSet::getNumOperands -> IntegerSet::getNumInputs to be consistent with AffineMap - add missing accessors for IntegerSet Doesn't need extensive testing since canonicalizeSetAndOperands just reuses canonicalizeMapAndOperands' logic, and the latter is tested on affine.apply map + operands; the new method works the same way on an integer set + operands of an affine if op for example. Signed-off-by: Uday Bondhugula <uday@polymagelabs.com> Closes tensorflow/mlir#112 COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/112 from bondhugula:set-canonicalize eff72f23250b96fa7d9f5caff3877440f5de2cec PiperOrigin-RevId: 267532876
* Make isIsolatedAbove robuster to invalid IRJacques Pienaar2019-09-041-0/+9
| | | | | | This function is only called from the verifier. PiperOrigin-RevId: 267145495
* Support bf16 in Builder::getZeroAttrSmit Hinsu2019-09-021-3/+2
| | | | PiperOrigin-RevId: 266863802
* Add support for early exit walk methods.River Riddle2019-08-301-0/+17
| | | | | | | | | | | | | | | This is done by providing a walk callback that returns a WalkResult. This result is either `advance` or `interrupt`. `advance` means that the walk should continue, whereas `interrupt` signals that the walk should stop immediately. An example is shown below: auto result = op->walk([](Operation *op) { if (some_invariant) return WalkResult::interrupt(); return WalkResult::advance(); }); if (result.wasInterrupted()) ...; PiperOrigin-RevId: 266436700
* Refactor the 'walk' methods for operations.River Riddle2019-08-294-36/+34
| | | | | | | | | | | | This change refactors and cleans up the implementation of the operation walk methods. After this refactoring is that the explicit template parameter for the operation type is no longer needed for the explicit op walks. For example: op->walk<AffineForOp>([](AffineForOp op) { ... }); is now accomplished via: op->walk([](AffineForOp op) { ... }); PiperOrigin-RevId: 266209552
* Make dumping using generic form more robust when IR ill-formedJacques Pienaar2019-08-291-0/+5
| | | | PiperOrigin-RevId: 266198057
* Tweak to the pretty type parser to recognize that `->` is a special token.Eric Schweitz2019-08-281-0/+7
| | | | | | | | | | | Tweak to the pretty type parser to recognize that `->` is a special token that shouldn't be split into two characters. This change allows dialect types to wrap function types as in `!my.ptr_type<(i32) -> i32>`. Closes tensorflow/mlir#105 COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/105 from schweitzpgi:parse-arrow 8b2d768053f419daae5a1a864121a44c4319acbe PiperOrigin-RevId: 265986240
* Add implementation for tensor_load and tensor_store operations.Stephan Herhut2019-08-281-0/+32
| | | | | | This change adds definitions, parsing and verification for both ops. PiperOrigin-RevId: 265954051
* NFC: Remove the explicit context from Operation::create and OperationState.River Riddle2019-08-262-18/+14
| | | | | | The context can easily be recovered from the Location in these situations. PiperOrigin-RevId: 265578574
* NFC: Remove unnecessary context parameters from several Location getters.River Riddle2019-08-261-12/+11
| | | | | | The context can be recovered by other means in these methods and doesn't need to be passed explicitly. PiperOrigin-RevId: 265532956
* Introduce the ability for "isolated from above" ops to introduce shadowingChris Lattner2019-08-231-7/+54
| | | | | | names for the basic block arguments in their body. PiperOrigin-RevId: 265084627
OpenPOWER on IntegriCloud