summaryrefslogtreecommitdiffstats
path: root/mlir/examples/toy/Ch5
Commit message (Collapse)AuthorAgeFilesLines
* [MLIR] Fix broken link locations after move to monorepoDaniel Galvez2020-01-141-1/+1
| | | | | | | | | | I used the codemod python tool to do this with the following commands: codemod 'tensorflow/mlir/blob/master/include' 'llvm/llvm-project/blob/master/mlir/include' codemod 'tensorflow/mlir/blob/master' 'llvm/llvm-project/blob/master/mlir' codemod 'tensorflow/mlir' 'llvm-project/llvm' Differential Revision: https://reviews.llvm.org/D72244
* [mlir] NFC: Remove Value::operator* and Value::operator-> now that Value is ↵River Riddle2020-01-113-12/+11
| | | | | | | | | | 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-235-48/+46
| | | | | | 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-2318-234/+72
| | | | PiperOrigin-RevId: 286906740
* NFC: Introduce new ValuePtr/ValueRef typedefs to simplify the transition to ↵River Riddle2019-12-225-49/+51
| | | | | | | | | | 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
* NFC: Use this-> to appease GCC bug related to template lambda.River Riddle2019-12-171-1/+1
| | | | | | | GCC is unable to properly implicitly capture 'this' in generic lambdas. This bug is not fixed until 7.1.0: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67274 PiperOrigin-RevId: 286083427
* NFC: Use TypeSwitch to simplify existing code.River Riddle2019-12-171-14/+10
| | | | PiperOrigin-RevId: 286066371
* Fix minor spelling tweaks.shanshanpt2019-12-091-1/+1
| | | | | | | Closes tensorflow/mlir#306 COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/306 from shanshanpt:master 11430c2131281d84a432f45e854e29917b336e8d PiperOrigin-RevId: 284613648
* Minor spelling tweaksKazuaki Ishizaki2019-12-091-1/+1
| | | | | | Closes tensorflow/mlir#304 PiperOrigin-RevId: 284568358
* minor spelling tweaksKazuaki Ishizaki2019-12-041-2/+2
| | | | | | | Closes tensorflow/mlir#250 COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/250 from kiszk:spelling_tweaks_201911 50fc04443723190b764e824b6fcd2469fecb56e6 PiperOrigin-RevId: 283733032
* NFC: Remove unnecessarily guarded tablegen includes.River Riddle2019-11-223-9/+0
| | | | | | Support for including a file multiple times was added in tablegen, removing the need for these extra guards. This is because we already insert c/c++ style header guards within each of the specific .td files. PiperOrigin-RevId: 282076728
* Add support for nested symbol references.River Riddle2019-11-111-1/+1
| | | | | | | | | | | | | | | | | | This change allows for adding additional nested references to a SymbolRefAttr to allow for further resolving a symbol if that symbol also defines a SymbolTable. If a referenced symbol also defines a symbol table, a nested reference can be used to refer to a symbol within that table. Nested references are printed after the main reference in the following form: symbol-ref-attribute ::= symbol-ref-id (`::` symbol-ref-id)* Example: module @reference { func @nested_reference() } my_reference_op @reference::@nested_reference Given that SymbolRefAttr is now more general, the existing functionality centered around a single reference is moved to a derived class FlatSymbolRefAttr. Followup commits will add support to lookups, rauw, etc. for scoped references. PiperOrigin-RevId: 279860501
* Fix segfault (nullptr dereference) when passing a non-existent file to the ↵Mehdi Amini2019-11-091-0/+2
| | | | | | | | Toy tutorial compiler Fix tensorflow/mlir#229 PiperOrigin-RevId: 279557863
* NFC: Tidy up the implementation of operations in the Toy tutorialRiver Riddle2019-11-062-40/+50
| | | | | | Use header blocks to separate operation implementations, and switch the build methods to be out-of-line when possible. PiperOrigin-RevId: 278982913
* NFC: Uniformize parser naming scheme in Toy tutorial to camelCase and tidy a ↵River Riddle2019-11-066-218/+204
| | | | | | bit of the implementation. PiperOrigin-RevId: 278982817
* NFC: Use #ifndef in various .td files instead of #ifdef and #elseLei Zhang2019-10-312-10/+5
| | | | | | | | | | Upstream LLVM gained support for #ifndef with https://reviews.llvm.org/D61888 This is changed mechanically via the following command: find . -name "*.td" -exec sed -i -e ':a' -e 'N' -e '$!ba' -e 's/#ifdef \([A-Z_]*\)\n#else/#ifndef \1/g' {} \; PiperOrigin-RevId: 277789427
* Convert the Canonicalize and CSE passes to generic Operation Passes.River Riddle2019-10-241-7/+10
| | | | | | This allows for them to be used on other non-function, or even other function-like, operations. The algorithms are already generic, so this is simply changing the derived pass type. The majority of this change is just ensuring that the nesting of these passes remains the same, as the pass manager won't auto-nest them anymore. PiperOrigin-RevId: 276573038
* NFC: Remove references to the toy.generic attribute.River Riddle2019-10-231-7/+1
| | | | | | This was used for shape inference in the previous tutorial flow. PiperOrigin-RevId: 276351916
* Cleanup and rewrite Ch-4.md.River Riddle2019-10-212-1/+7
| | | | | | This change rewrites Ch-4.md to introduced interfaces in a detailed step-by-step manner, adds examples, and fixes some errors. PiperOrigin-RevId: 275887017
* NFC: Fix remaining usages of MulOp as matrix multiplication.River Riddle2019-10-211-20/+1
| | | | | | MulOp now represents an element-wise multiplication instead of a matrix multiplication. PiperOrigin-RevId: 275886774
* Fix minor spelling tweaks (NFC)Kazuaki Ishizaki2019-10-203-5/+5
| | | | | | Closes tensorflow/mlir#175 PiperOrigin-RevId: 275726876
* Add SourceMgrDiagnosticHandler to toyJacques Pienaar2019-10-191-3/+5
| | | | PiperOrigin-RevId: 275659433
* NFC: Remove trivial builder get methods.River Riddle2019-10-172-8/+8
| | | | | | These don't add any value, and some are even more restrictive than the respective static 'get' method. PiperOrigin-RevId: 275391240
* Fix invalid transpose in example and add proper verification.River Riddle2019-10-162-4/+19
| | | | | | The transpose in the example had the same result type as its input, which is incorrect. PiperOrigin-RevId: 275186568
* Add Ch.5 of the toy tutorial.River Riddle2019-10-1622-2289/+1456
| | | | | | This chapter adds a partial lowering of toy operations, all but PrintOp, to a combination of the Affine and Std dialects. This chapter focuses on introducing the conversion framework, the benefits of partial lowering, and how easily dialects may co-exist in the IR. PiperOrigin-RevId: 275150649
* Use llvm.func to define functions with wrapped LLVM IR function typeAlex Zinenko2019-10-101-12/+11
| | | | | | | | | | | | | | This function-like operation allows one to define functions that have wrapped LLVM IR function type, in particular variadic functions. The operation was added in parallel to the existing lowering flow, this commit only switches the flow to use it. Using a custom function type makes the LLVM IR dialect type system more consistent and avoids complex conversion rules for functions that previously had to use the built-in function type instead of a wrapped LLVM IR dialect type and perform conversions during the analysis. PiperOrigin-RevId: 273910855
* Fix typos, NFC.Christian Sigg2019-10-042-6/+6
| | | | PiperOrigin-RevId: 272851237
* Normalize lowering of MemRef typesNicolas Vasilache2019-09-241-6/+17
| | | | | | | | | | | | | | | | The RFC for unifying Linalg and Affine compilation passes into an end-to-end flow with a predictable ABI and linkage to external function calls raised the question of why we have variable sized descriptors for memrefs depending on whether they have static or dynamic dimensions (https://groups.google.com/a/tensorflow.org/forum/#!topic/mlir/MaL8m2nXuio). This CL standardizes the ABI on the rank of the memrefs. The LLVM struct for a memref becomes equivalent to: ``` template <typename Elem, size_t Rank> struct { Elem *ptr; int64_t sizes[Rank]; }; ``` PiperOrigin-RevId: 270947276
* Add convenience methods to set an OpBuilder insertion point after an ↵Mehdi Amini2019-09-231-2/+1
| | | | | | Operation (NFC) PiperOrigin-RevId: 270727180
* NFC: Pass OperationState by reference instead of by pointer.River Riddle2019-09-202-42/+42
| | | | | | MLIR follows the LLVM convention of passing by reference instead of by pointer. PiperOrigin-RevId: 270396945
* Unify error messages to start with lower-case.MLIR Team2019-09-184-13/+13
| | | | PiperOrigin-RevId: 269803466
* Refactor the pass manager to support operations other than FuncOp/ModuleOp.River Riddle2019-09-021-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change generalizes the structure of the pass manager to allow arbitrary nesting pass managers for other operations, at any level. The only user visible change to existing code is the fact that a PassManager must now provide an MLIRContext on construction. A new class `OpPassManager` has been added that represents a pass manager on a specific operation type. `PassManager` will remain the top-level entry point into the pipeline, with OpPassManagers being nested underneath. OpPassManagers will still be implicitly nested if the operation type on the pass differs from the pass manager. To explicitly build a pipeline, the 'nest' methods on OpPassManager may be used: // Pass manager for the top-level module. PassManager pm(ctx); // Nest a pipeline operating on FuncOp. OpPassManager &fpm = pm.nest<FuncOp>(); fpm.addPass(...); // Nest a pipeline under the FuncOp pipeline that operates on spirv::ModuleOp OpPassManager &spvModulePM = pm.nest<spirv::ModuleOp>(); // Nest a pipeline on FuncOps inside of the spirv::ModuleOp. OpPassManager &spvFuncPM = spvModulePM.nest<FuncOp>(); To help accomplish this a new general OperationPass is added that operates on opaque Operations. This pass can be inserted in a pass manager of any type to operate on any operation opaquely. An example of this opaque OperationPass is a VerifierPass, that simply runs the verifier opaquely on the current operation. /// Pass to verify an operation and signal failure if necessary. class VerifierPass : public OperationPass<VerifierPass> { void runOnOperation() override { Operation *op = getOperation(); if (failed(verify(op))) signalPassFailure(); markAllAnalysesPreserved(); } }; PiperOrigin-RevId: 266840344
* NFC: Move LLVMIR, SDBM, and StandardOps to the Dialect/ directory.River Riddle2019-08-194-4/+4
| | | | PiperOrigin-RevId: 264193915
* Change from llvm::make_unique to std::make_uniqueJacques Pienaar2019-08-175-26/+24
| | | | | | | | Switch to C++14 standard method as llvm::make_unique has been removed ( https://reviews.llvm.org/D66259). Also mark some targets as c++14 to ease next integrates. PiperOrigin-RevId: 263953918
* Refactor ElementsAttr::getValue and DenseElementsAttr::getSplatValue.River Riddle2019-08-141-6/+2
| | | | | | All 'getValue' variants now require that the index is valid, queryable via 'isValidIndex'. 'getSplatValue' now requires that the attribute is a proper splat. This allows for querying these methods on DenseElementAttr with all possible value types; e.g. float, int, APInt, etc. This also allows for removing unnecessary conversions to Attribute that really want the underlying value. PiperOrigin-RevId: 263437337
* Express ownership transfer in PassManager API through std::unique_ptr (NFC)Mehdi Amini2019-08-126-6/+15
| | | | | | | | | | | | | | Since raw pointers are always passed around for IR construct without implying any ownership transfer, it can be error prone to have implicit ownership transferred the same way. For example this code can seem harmless: Pass *pass = .... pm.addPass(pass); pm.addPass(pass); pm.run(module); PiperOrigin-RevId: 263053082
* NFC: Standardize the terminology used for parent ops/regions/etc.River Riddle2019-08-091-1/+1
| | | | | | There are currently several different terms used to refer to a parent IR unit in 'get' methods: getParent/getEnclosing/getContaining. This cl standardizes all of these methods to use 'getParent*'. PiperOrigin-RevId: 262680287
* NFC: Update usages of OwningRewritePatternList to pass by & instead of &&.River Riddle2019-08-092-4/+3
| | | | | | This will allow for reusing the same pattern list, which may be costly to continually reconstruct, on multiple invocations. PiperOrigin-RevId: 262664599
* NFC: Update FuncOp::addEntryBlock to return the newly inserted block.River Riddle2019-08-071-3/+1
| | | | | | The entry block is often used recently after insertion. This removes the need to perform an additional lookup in such cases. PiperOrigin-RevId: 262265671
* Add TTI pass initialization to pass managers.Diego Caballero2019-08-051-2/+4
| | | | | | | | | Many LLVM transformations benefits from knowing the targets. This enables optimizations, especially in a JIT context when the target is (generally) well-known. Closes tensorflow/mlir#49 PiperOrigin-RevId: 261840617
* NFC: Implement OwningRewritePatternList as a class instead of a using directive.River Riddle2019-08-053-8/+8
| | | | | | This allows for proper forward declaration, as opposed to leaking the internal implementation via a using directive. This also allows for all pattern building to go through 'insert' methods on the OwningRewritePatternList, replacing uses of 'push_back' and 'RewriteListBuilder'. PiperOrigin-RevId: 261816316
* Refactor region type signature conversion to be explicit via patterns.River Riddle2019-07-201-0/+5
| | | | | | This cl enforces that the conversion of the type signatures for regions, and thus their entry blocks, is handled via ConversionPatterns. A new hook 'applySignatureConversion' is added to the ConversionPatternRewriter to perform the desired conversion on a region. This also means that the handling of rewriting the signature of a FuncOp is moved to a pattern. A default implementation is provided via 'mlir::populateFuncOpTypeConversionPattern'. This removes the hacky implicit 'dynamically legal' status of FuncOp that was present previously, and leaves it up to the user to decide when/how to convert the signature of a function. PiperOrigin-RevId: 259161999
* NFC: Expose a ConversionPatternRewriter for use with ConversionPatterns.River Riddle2019-07-192-14/+20
| | | | | | This specific PatternRewriter will allow for exposing hooks in the future that are only useful for the conversion framework, e.g. type conversions. PiperOrigin-RevId: 258818122
* Refactor the conversion of block argument types in DialectConversion.River Riddle2019-07-191-2/+2
| | | | | | | | This cl begins a large refactoring over how signature types are converted in the DialectConversion infrastructure. The signatures of blocks are now converted on-demand when an operation held by that block is being converted. This allows for handling the case where a region is created as part of a pattern, something that wasn't possible previously. This cl also generalizes the region signature conversion used by FuncOp to work on any region of any operation. This generalization allows for removing the 'apply*Conversion' functions that were specific to FuncOp/ModuleOp. The implementation currently uses a new hook on TypeConverter, 'convertRegionSignature', but this should ideally be removed in favor of using Patterns. That depends on adding support to the PatternRewriter used by ConversionPattern to allow applying signature conversions to regions, which should be coming in a followup. PiperOrigin-RevId: 258645733
* Refactor DialectConversion to support different conversion modes.River Riddle2019-07-162-4/+4
| | | | | | | | | | | Users generally want several different modes of conversion. This cl refactors DialectConversion to provide two: * Partial (applyPartialConversion) - This mode allows for illegal operations to exist in the IR, and does not fail if an operation fails to be legalized. * Full (applyFullConversion) - This mode fails if any operation is not properly legalized to the conversion target. This allows for ensuring that the IR after a conversion only contains operations legal for the target. PiperOrigin-RevId: 258412243
* 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
* Rename FunctionAttr to SymbolRefAttr.River Riddle2019-07-122-4/+5
| | | | | | This allows for the attribute to hold symbolic references to other operations than FuncOp. This also allows for removing the dependence on FuncOp from the base Builder. PiperOrigin-RevId: 257650017
* NFC: Replace Module::getNamedFunction with lookupSymbol<FuncOp>.River Riddle2019-07-122-5/+7
| | | | | | This allows for removing the last direct reference to FuncOp from ModuleOp. PiperOrigin-RevId: 257498296
* NFC: Rename Module to ModuleOp.River Riddle2019-07-103-4/+4
| | | | | | Module is a legacy name that only exists as a typedef of ModuleOp. PiperOrigin-RevId: 257427248
* Update ModuleOp::create(...) to take a Location instead of a context.River Riddle2019-07-101-1/+1
| | | | | | This allows for giving a Module a more interesting location than 'Unknown'. PiperOrigin-RevId: 257310117
OpenPOWER on IntegriCloud