summaryrefslogtreecommitdiffstats
path: root/mlir/examples/toy
Commit message (Collapse)AuthorAgeFilesLines
* [MLIR] Fix broken link locations after move to monorepoDaniel Galvez2020-01-147-8/+8
| | | | | | | | | | 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-1117-63/+58
| | | | | | | | | | 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-2328-258/+245
| | | | | | 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-23100-1300/+400
| | | | PiperOrigin-RevId: 286906740
* NFC: Introduce new ValuePtr/ValueRef typedefs to simplify the transition to ↵River Riddle2019-12-2228-261/+272
| | | | | | | | | | 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-177-7/+7
| | | | | | | 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-177-99/+70
| | | | PiperOrigin-RevId: 286066371
* Fix minor spelling tweaks.shanshanpt2019-12-096-6/+6
| | | | | | | 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-097-7/+7
| | | | | | Closes tensorflow/mlir#304 PiperOrigin-RevId: 284568358
* minor spelling tweaksKazuaki Ishizaki2019-12-061-1/+1
| | | | | | | Closes tensorflow/mlir#290 COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/290 from kiszk:spelling_tweaks_201912 9d9afd16a723dd65754a04698b3976f150a6054a PiperOrigin-RevId: 284169681
* minor spelling tweaksKazuaki Ishizaki2019-12-043-6/+6
| | | | | | | Closes tensorflow/mlir#250 COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/250 from kiszk:spelling_tweaks_201911 50fc04443723190b764e824b6fcd2469fecb56e6 PiperOrigin-RevId: 283733032
* Introduce Linkage attribute to the LLVM dialectAlex Zinenko2019-12-022-4/+6
| | | | | | | | | | | LLVM IR supports linkage on global objects such as global variables and functions. Introduce the Linkage attribute into the LLVM dialect, backed by an integer storage. Use this attribute on LLVM::GlobalOp and make it mandatory. Implement parsing/printing of the attribute and conversion to LLVM IR. See tensorflow/mlir#277. PiperOrigin-RevId: 283309328
* NFC: Remove unnecessarily guarded tablegen includes.River Riddle2019-11-2215-42/+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
* Fix mismatched-tags warningJacques Pienaar2019-11-161-1/+1
| | | | PiperOrigin-RevId: 280888290
* Modify tutorial and other documentation for consistency, clarity, and ↵Lucy Fox2019-11-151-2/+2
| | | | | | correctness. PiperOrigin-RevId: 280678392
* Move Affine to Standard conversion to lib/ConversionAlex Zinenko2019-11-144-2/+6
| | | | | | | This is essentially a dialect conversion and conceptually belongs to conversions. PiperOrigin-RevId: 280460034
* Add support for nested symbol references.River Riddle2019-11-118-12/+12
| | | | | | | | | | | | | | | | | | 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-096-0/+12
| | | | | | | | Toy tutorial compiler Fix tensorflow/mlir#229 PiperOrigin-RevId: 279557863
* Add Ch-7 of the toy tutorial detailing how to define new types.River Riddle2019-11-0723-0/+4516
| | | | | | This chapter adds a new composite type to Toy, and shows the process of adding a new type to the IR, adding and updating operations to use it, and constant folding operations producing it. PiperOrigin-RevId: 279107885
* NFC: Tidy up the implementation of operations in the Toy tutorialRiver Riddle2019-11-0610-202/+246
| | | | | | 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-0636-1306/+1225
| | | | | | bit of the implementation. PiperOrigin-RevId: 278982817
* NFC: Use #ifndef in various .td files instead of #ifdef and #elseLei Zhang2019-10-318-38/+19
| | | | | | | | | | 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-244-18/+25
| | | | | | 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-235-35/+5
| | | | | | This was used for shape inference in the previous tutorial flow. PiperOrigin-RevId: 276351916
* Cleanup and rewrite Ch-4.md.River Riddle2019-10-216-2/+20
| | | | | | 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-213-60/+3
| | | | | | MulOp now represents an element-wise multiplication instead of a matrix multiplication. PiperOrigin-RevId: 275886774
* Fix minor spelling tweaks (NFC)Kazuaki Ishizaki2019-10-2015-27/+27
| | | | | | Closes tensorflow/mlir#175 PiperOrigin-RevId: 275726876
* Add SourceMgrDiagnosticHandler to toyJacques Pienaar2019-10-193-9/+15
| | | | PiperOrigin-RevId: 275659433
* Use new eraseOp instead of replaceOp with empty valuesGeoffrey Martin-Noble2019-10-191-1/+1
| | | | PiperOrigin-RevId: 275631166
* NFC: Remove trivial builder get methods.River Riddle2019-10-1710-40/+40
| | | | | | These don't add any value, and some are even more restrictive than the respective static 'get' method. PiperOrigin-RevId: 275391240
* Add Ch.6 of the Toy tutorial.River Riddle2019-10-1723-0/+3680
| | | | | | This chapters introduces the notion of a full conversion, and adds support for lowering down to the LLVM dialect, LLVM IR, and thus code generation. PiperOrigin-RevId: 275337786
* Fix invalid transpose in example and add proper verification.River Riddle2019-10-168-8/+74
| | | | | | 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-1625-2296/+1473
| | | | | | 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
* Add support for inlining toy call operations.River Riddle2019-10-166-7/+67
| | | | | | The GenericCallOp needed to have the CallOpInterface to be picked up by the inliner. This also adds a CastOp to perform shape casts that are generated during inlining. The casts generated by the inliner will be folded away after shape inference. PiperOrigin-RevId: 275150438
* Fix typo in tutorial.reinerp2019-10-162-2/+2
| | | | PiperOrigin-RevId: 275147795
* Code cleanups on Ch.4River Riddle2019-10-167-92/+121
| | | | | | This change performs general cleanups of the implementation of ch.4 and fixes some bugs. For example, the operations currently don't inherit from the shape inference interface. PiperOrigin-RevId: 275089914
* Update Chapter 4 of the Toy tutorialSana Damani2019-10-1617-1358/+1005
| | | | | | | | | | This Chapter now introduces and makes use of the Interface concept in MLIR to demonstrate ShapeInference. END_PUBLIC Closes tensorflow/mlir#191 PiperOrigin-RevId: 275085151
* NFC: Remove NoSideEffect traits from all ops except for ConstantOp.River Riddle2019-10-161-4/+4
| | | | | | These traits are added in chapter 3 when we begin discussion optimization on the toy operations. PiperOrigin-RevId: 274974010
* NFC: Various code cleanups for Ch3.River Riddle2019-10-163-50/+56
| | | | | | This change refactors the toyc driver to be much cleaner and easier to extend. It also cleans up a few comments in the combiner. PiperOrigin-RevId: 274973808
* NFC: Split out ToyOpsIncGen into a separate CMakeLists.txt.River Riddle2019-10-156-10/+13
| | | | | | This fixes an issue with make where it fails to properly handle the dependency ordering. PiperOrigin-RevId: 274897702
* Update Chapter 3 to demonstrate pattern match and rewrite optimizationsSana Damani2019-10-1512-907/+804
| | | | | | | | | This is using Table-driven Declarative Rewrite Rules (DRR), the previous version of the tutorial only showed the C++ patterns. Closes tensorflow/mlir#187 PiperOrigin-RevId: 274852321
* Merge Ch3 of the Toy tutorial into chapter 2.River Riddle2019-10-146-88/+526
| | | | | | This effectively rewrites Ch.2 to introduce dialects, operations, and registration instead of deferring to Ch.3. This allows for introducing the best practices up front(using ODS, registering operations, etc.), and limits the opaque API to the chapter document instead of the code. PiperOrigin-RevId: 274724289
* 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-0410-26/+26
| | | | 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-206-112/+112
| | | | | | 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-1810-36/+36
| | | | PiperOrigin-RevId: 269803466
* Refactor the pass manager to support operations other than FuncOp/ModuleOp.River Riddle2019-09-022-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Update Ch.2 of the Toy tutorial.River Riddle2019-08-275-223/+207
| | | | | | | | The code and documentation for this chapter of the tutorial have been updated to follow the new flow. The toy 'array' type has been replaced by usages of the MLIR tensor type. The code has also been cleaned up and modernized. Closes tensorflow/mlir#101 PiperOrigin-RevId: 265744086
OpenPOWER on IntegriCloud