summaryrefslogtreecommitdiffstats
path: root/mlir/lib/EDSC/Builders.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [mlir] NFC: Rename index_t to index_typeRainer Orth2020-03-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | mlir currently fails to build on Solaris: /vol/llvm/src/llvm-project/dist/mlir/lib/Conversion/VectorToLoops/ConvertVectorToLoops.cpp:78:20: error: reference to 'index_t' is ambiguous IndexHandle zero(index_t(0)), one(index_t(1)); ^ /usr/include/sys/types.h:103:16: note: candidate found by name lookup is 'index_t' typedef short index_t; ^ /vol/llvm/src/llvm-project/dist/mlir/include/mlir/EDSC/Builders.h:27:8: note: candidate found by name lookup is 'mlir::edsc::index_t' struct index_t { ^ and many more. Given that POSIX reserves all identifiers ending in `_t` 2.2.2 The Name Space <https://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html>, it seems quite unwise to use such identifiers in user code, even more so without a distinguished prefix. The following patch fixes this by renaming `index_t` to `index_type`. cases. Tested on `amd64-pc-solaris2.11` and `sparcv9-sun-solaris2.11`. Differential Revision: https://reviews.llvm.org/D72619 (cherry picked from commit 002ec79f979b9da9dedafe7ea036e00c90a9fbb7)
* [mlir] NFC: Remove Value::operator* and Value::operator-> now that Value is ↵River Riddle2020-01-111-6/+6
| | | | | | | | | | properly value-typed. Summary: These were temporary methods used to simplify the transition. Reviewed By: antiagainst Differential Revision: https://reviews.llvm.org/D72548
* NFC: Replace ValuePtr with Value and remove it now that Value is value-typed.River Riddle2019-12-231-11/+12
| | | | | | ValuePtr was a temporary typedef during the transition to a value-typed Value. PiperOrigin-RevId: 286945714
* Adjust License.txt file to use the LLVM licenseMehdi Amini2019-12-231-13/+4
| | | | PiperOrigin-RevId: 286906740
* NFC: Introduce new ValuePtr/ValueRef typedefs to simplify the transition to ↵River Riddle2019-12-221-12/+11
| | | | | | | | | | Value being value-typed. This is an initial step to refactoring the representation of OpResult as proposed in: https://groups.google.com/a/tensorflow.org/g/mlir/c/XXzzKhqqF_0/m/v6bKb08WCgAJ This change will make it much simpler to incrementally transition all of the existing code to use value-typed semantics. PiperOrigin-RevId: 286844725
* Add integer bit-shift operations to the standard dialect.Manuel Freiberger2019-12-221-2/+2
| | | | | | | | | | | | | | | | | | | Rename the 'shlis' operation in the standard dialect to 'shift_left'. Add tests for this operation (these have been missing so far) and add a lowering to the 'shl' operation in the LLVM dialect. Add also 'shift_right_signed' (lowered to LLVM's 'ashr') and 'shift_right_unsigned' (lowered to 'lshr'). The original plan was to name these operations 'shift.left', 'shift.right.signed' and 'shift.right.unsigned'. This works if the operations are prefixed with 'std.' in MLIR assembly. Unfortunately during import the short form is ambigous with operations from a hypothetical 'shift' dialect. The best solution seems to omit dots in standard operations for now. Closes tensorflow/mlir#226 PiperOrigin-RevId: 286803388
* NFC: Remove unnecessary 'llvm::' prefix from uses of llvm symbols declared ↵River Riddle2019-12-181-12/+12
| | | | | | | | in `mlir` namespace. Aside from being cleaner, this also makes the codebase more consistent. PiperOrigin-RevId: 286206974
* NFC: Convert CmpIPredicate in StandardOps to use EnumAttrLei Zhang2019-11-151-6/+6
| | | | | | This turns several hand-written functions to auto-generated ones. PiperOrigin-RevId: 280684326
* Lower vector transfer ops to loop.for operations.Nicolas Vasilache2019-10-181-1/+0
| | | | | | This allows mixing linalg operations with vector transfer operations (with additional modifications to affine ops) and is a step towards solving tensorflow/mlir#189. PiperOrigin-RevId: 275543361
* Automated rollback of commit 575405f4d6762830c1c4520569de4e4ed3c8eed5Nicolas Vasilache2019-10-181-17/+56
| | | | PiperOrigin-RevId: 275461067
* Automated rollback of commit b65c8bb5d6ab418bb3fcd0302aee19d3615d90f1River Riddle2019-10-171-56/+17
| | | | PiperOrigin-RevId: 275370861
* Add EDSC support for loop.for operationsNicolas Vasilache2019-10-171-17/+56
| | | | | | | This CL adds support for loop.for operations in EDSC and adds a test. This will be used in a followup commit to implement lowering of vector_transfer ops so that it works more generally and is not subject to affine constraints. PiperOrigin-RevId: 275349796
* Rename LoopNestBuilder to AffineLoopNestBuilder - NFCNicolas Vasilache2019-10-171-6/+5
| | | | PiperOrigin-RevId: 275310747
* NFC: Move LLVMIR, SDBM, and StandardOps to the Dialect/ directory.River Riddle2019-08-191-1/+1
| | | | PiperOrigin-RevId: 264193915
* Add support for floating-point comparison 'fcmp' to the LLVM dialect.Nagy Mostafa2019-08-081-9/+43
| | | | | | | | This adds support for fcmp to the LLVM dialect and adds any necessary lowerings, as well as support for EDSCs. Closes tensorflow/mlir#69 PiperOrigin-RevId: 262475255
* Remove the 'region' field from OpBuilder.River Riddle2019-07-121-1/+1
| | | | | | This field wasn't updated as the insertion point changed, making it potentially dangerous given the multi-level of MLIR(e.g. 'createBlock' would always insert the new block in 'region'). This also allows for building an OpBuilder with just a context. PiperOrigin-RevId: 257829135
* NFC: Remove the 'context' parameter from OperationState.River Riddle2019-06-221-2/+1
| | | | | | Now that Locations are Attributes they contain a direct reference to the MLIRContext, i.e. the context can be directly accessed from the given location instead of being explicitly passed in. PiperOrigin-RevId: 254568329
* Uniformize usage of OpBuilder& (NFC)Nicolas Vasilache2019-06-221-16/+14
| | | | | | | Historically the pointer-based version of builders was used. This CL uniformizes to OpBuilder & PiperOrigin-RevId: 254280885
* NFC: Rename FuncBuilder to OpBuilder and refactor to take a top level region ↵River Riddle2019-06-091-5/+4
| | | | | | instead of a function. PiperOrigin-RevId: 251563898
* Don't use ShapedType to indicate vector or tensor typeGeoffrey Martin-Noble2019-06-011-1/+2
| | | | | | | | MemRefType may soon subclass ShapedType. ShapedType only guarantees that something has a shape (possibly dynamic), rank (or explicitly unranked), and fixed element type. -- PiperOrigin-RevId: 250940537
* Remove "size" property of affine maps.MLIR Team2019-06-011-1/+1
| | | | | | -- PiperOrigin-RevId: 250572818
* EDSC: use llvm::function_ref instead of std::functionAlex Zinenko2019-06-011-3/+4
| | | | | | | | | | Region body constructors in EDSC now take a callback to the function that fills in the body. This callback is called immediately and not stored, so it is sufficient to pass a reference to it and avoid a potentially expensive copy. -- PiperOrigin-RevId: 250473793
* Use lambdas for nesting edsc constructs.Nicolas Vasilache2019-05-201-5/+10
| | | | | | | | | | | Using ArrayRef introduces issues with the order of evaluation between a constructor and the arguments of the subsequent calls to the `operator()`. As a consequence the order of captures is not well-defined can go wrong with certain compilers (e.g. gcc-6.4). This CL fixes the issue by using lambdas in lieu of ArrayRef. -- PiperOrigin-RevId: 249114775
* Add support for saving and restoring the insertion point of a ↵River Riddle2019-05-201-4/+14
| | | | | | | | FuncBuilder. This also updates the edsc::ScopedContext to use a single builder that saves/restores insertion points. This is necessary for using edscs within RewritePatterns. -- PiperOrigin-RevId: 248812645
* Rename VectorOrTensorType to ShapedTypeGeoffrey Martin-Noble2019-05-201-1/+1
| | | | | | | | | | | | This is in preparation for making it also support/be a parent class of MemRefType. MemRefs have similar shape/rank/element semantics and it would be useful to be able to use these same utilities for them. This CL should not change any semantics and only change variables, types, string literals, and comments. In follow-up CLs I will prepare all callers to handle MemRef types or remove their dependence on ShapedType. Discussion/Rationale in https://groups.google.com/a/tensorflow.org/forum/#!topic/mlir/cHLoyfGu8y8 -- PiperOrigin-RevId: 248476449
* Remove unnecessary C++ specifier in CPP files. NFC.Jacques Pienaar2019-05-201-1/+1
| | | | | | | | These are only required in .h files to disambiguate between C and C++ header files. -- PiperOrigin-RevId: 248219135
* Add support for using llvm::dyn_cast/cast/isa for operation casts and ↵River Riddle2019-05-201-3/+3
| | | | | | | | replace usages of Operation::dyn_cast with llvm::dyn_cast. -- PiperOrigin-RevId: 247780086
* Automated rollback of changelist 247778391.MLIR Team2019-05-201-3/+3
| | | | PiperOrigin-RevId: 247778691
* Add support for using llvm::dyn_cast/cast/isa for operation casts and ↵River Riddle2019-05-201-3/+3
| | | | | | | | replace usages of Operation::dyn_cast with llvm::dyn_cast. -- PiperOrigin-RevId: 247778391
* Add new utilities for RTTI Operation casting: dyn_cast_or_null and ↵River Riddle2019-04-071-3/+1
| | | | | | | | | | | | | | | | | | | | | isa_nonnull * dyn_cast_or_null - This will first check if the operation is null before trying to 'dyn_cast': Value *v = ...; if (auto forOp = dyn_cast_or_null<AffineForOp>(v->getDefiningOp())) ... * isa_nonnull - This will first check if the pointer is null before trying to 'isa': Value *v = ...; if (isa_nonnull<AffineForOp>(v->getDefiningOp()); ... -- PiperOrigin-RevId: 242171343
* Replace remaining usages of the Instruction class with Operation.River Riddle2019-03-291-16/+16
| | | | PiperOrigin-RevId: 240777521
* Introduce affine terminatorAlex Zinenko2019-03-291-4/+1
| | | | | | | | | | | | | | | | | | | | | | Due to legacy reasons (ML/CFG function separation), regions in affine control flow operations require contained blocks not to have terminators. This is inconsistent with the notion of the block and may complicate code motion between regions of affine control operations and other regions. Introduce `affine.terminator`, a special terminator operation that must be used to terminate blocks inside affine operations and transfers the control back to he region enclosing the affine operation. For brevity and readability reasons, allow `affine.for` and `affine.if` to omit the `affine.terminator` in their regions when using custom printing and parsing format. The custom parser injects the `affine.terminator` if it is missing so as to always have it present in constructed operations. Update transformations to account for the presence of terminator. In particular, most code motion transformation between loops should leave the terminator in place, and code motion between loops and non-affine blocks should drop the terminator. PiperOrigin-RevId: 240536998
* Replace usages of Instruction with Operation in the /IR directory.River Riddle2019-03-291-4/+4
| | | | | | This is step 2/N to renaming Instruction to Operation. PiperOrigin-RevId: 240459216
* Replace usages of "Op::operator->" with ".".River Riddle2019-03-291-2/+2
| | | | | | This is step 2/N of removing the temporary operator-> method as part of the de-const transition. PiperOrigin-RevId: 240200792
* Replace usages of "operator->" with "." for the AffineOps.River Riddle2019-03-291-4/+4
| | | | | Note: The "operator->" method is a temporary helper for the de-const transition and is gradually being phased out. PiperOrigin-RevId: 240179439
* Remove OpPointer, cleaning up a ton of code. This also moves Ops to usingChris Lattner2019-03-291-5/+4
| | | | | | | | | 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
* Cleanups Vectorize and SliceAnalysis - NFCNicolas Vasilache2019-03-291-0/+2
| | | | | | This CL cleans up and refactors super-vectorization and slice analysis. PiperOrigin-RevId: 238986866
* Port LowerVectorTransfers from EDSC + AST to declarative buildersNicolas Vasilache2019-03-291-0/+33
| | | | | | | | | | | | | | | 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
* Python bindings: expose boolean and comparison operatorsAlex Zinenko2019-03-291-0/+15
| | | | | | | | | | | | | | | | | 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
* [EDSC] Cleanup declarative builder insertion point with blocksNicolas Vasilache2019-03-291-0/+6
| | | | | | | | | | | | | Declarative builders want to provide the same nesting interface for blocks and loops. MLIR on the other hand has different behaviors: 1. when an AffineForOp is created the insertion point does not enter the loop body; 2. when a Block is created, the insertion point does enter the block body. Guard against the second behavior in EDSC to make the interface unsurprising. This also surfaces two places in the eager branch API where I was guarding against this behavior indirectly by creating a new ScopedContext. Instead, uniformize everything to properly reset the insertion point in the unique place that builds the mlir::Block*. PiperOrigin-RevId: 237619513
* Follow up on custom instruction support.Nicolas Vasilache2019-03-291-3/+3
| | | | | | | | | This CL addresses a few post-submit comments: 1. better comments, 2. check number of results before dyn_cast (which is a less common case) 3. test usage for multi-result InstructionHandle PiperOrigin-RevId: 237549333
* Add support for custom ops in declarative builders.Nicolas Vasilache2019-03-291-3/+36
| | | | | | | | This CL adds support for named custom instructions in declarative builders. To allow this, it introduces a templated `CustomInstruction` class. This CL also splits ValueHandle which can capture only the **value** in single-valued instructions from InstructionHandle which can capture any instruction but provide no typing and sugaring to extract the potential Value*. PiperOrigin-RevId: 237543222
* Add helper classes to declarative builders to help write end-to-end custom ops.Nicolas Vasilache2019-03-291-0/+26
| | | | | | | | This CL adds the same helper classes that exist in the AST form of EDSCs to support a basic indexing notation and emit the proper load and store operations and capture MemRefViews as function arguments. This CL also adds a wrapper class LoopNestBuilder to allow generic rank-agnostic loops over indices. PiperOrigin-RevId: 237113755
* [EDSC] Hotfix: Avoid implicit OpPointer -> OpType* conversionNicolas Vasilache2019-03-291-3/+3
| | | | | | | An implicit OpPointer -> OpType* conversion results in AddressSanitizer triggering a stack-use-after-scope error (which may be a false positive). Avoid using such patterns to make life good again. PiperOrigin-RevId: 237053863
* Add support for Branches in edsc::BuilderNicolas Vasilache2019-03-291-0/+39
| | | | | | | | | This CL adds support for BranchHandle and BranchBuilder that require a slightly different abstraction since an mlir::Block is not an mlir::Value. This CL also adds support for the BR and COND_BR instructions and the relevant tests. PiperOrigin-RevId: 237034312
* Start a new implementation for edsc::BuilderNicolas Vasilache2019-03-291-0/+264
This CL reworks the design of EDSCs from first principles. It introduces a ValueHandle which can hold either: 1. an eagerly typed, delayed Value* 2. a precomputed Value* A ValueHandle can be manipulated with intrinsic operations a nested within a NestedBuilder. These NestedBuilder are a more idiomatic nested builder abstraction that should feel intuitive to program in C++. Notably, this abstraction does not require an AST to stage the construction of MLIR snippets from C++. Instead, the abstraction makes use of orderings between definition and declaration of ValueHandles and provides a NestedBuilder and a LoopBuilder helper classes to handle those orderings. All instruction creations are meant to use the templated ValueHandle::create<> which directly calls mlir::Builder.create<>. For now the EDSC AST and the builders live side-by-side until the C API is ported. PiperOrigin-RevId: 237030945
OpenPOWER on IntegriCloud