Commit Graph

199 Commits

Author SHA1 Message Date
River Riddle d5b60ee840 Replace Operation::isa with llvm::isa.
--

PiperOrigin-RevId: 247789235
2019-05-20 13:37:52 -07:00
River Riddle adca3c2edc Replace Operation::cast with llvm::cast.
--

PiperOrigin-RevId: 247785983
2019-05-20 13:37:42 -07:00
River Riddle c5ecf9910a Add support for using llvm::dyn_cast/cast/isa for operation casts and replace usages of Operation::dyn_cast with llvm::dyn_cast.
--

PiperOrigin-RevId: 247780086
2019-05-20 13:37:31 -07:00
MLIR Team 41d90a85bd Automated rollback of changelist 247778391.
PiperOrigin-RevId: 247778691
2019-05-20 13:37:20 -07:00
River Riddle 02e03b9bf4 Add support for using llvm::dyn_cast/cast/isa for operation casts and replace usages of Operation::dyn_cast with llvm::dyn_cast.
--

PiperOrigin-RevId: 247778391
2019-05-20 13:37:10 -07:00
Mehdi Amini bd8ed0d215 Fix unused variable warning in the Toy tutorial (NFC)
--

PiperOrigin-RevId: 247672377
2019-05-10 19:29:58 -07:00
Mehdi Amini 52d0dbbd2a Make header-defined method inline instead of static (NFC)
This is fixing a clang warning when this header is included in a file
    that does not use this function.

--

PiperOrigin-RevId: 247557803
2019-05-10 19:27:16 -07:00
Mehdi Amini 6459c821bf Fix class/struct mismatch between declaration/definition (NFC)
Fix clang warnings

--

PiperOrigin-RevId: 247557395
2019-05-10 19:27:07 -07:00
River Riddle b7dc252683 NFC: Make ParseResult public and update the OpAsmParser(and thus all of the custom operation parsers) to use it instead of bool.
--

PiperOrigin-RevId: 246955523
2019-05-10 19:23:24 -07:00
River Riddle 4ea887be41 Namespaceify a few explicit template specializations to appease errors caused by a bug in gcc versions < 7.0.
(https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56480)

--

PiperOrigin-RevId: 246664463
2019-05-06 08:29:09 -07:00
River Riddle 3b930b0d70 Add explicit friendship with Operation to each derived op class to ensure access to the inherited protected constructor of `Op`. Some compiler versions have different rules for the visibility of inherited constructors.
--

PiperOrigin-RevId: 246661686
2019-05-06 08:28:50 -07:00
Jacques Pienaar dd726ea99d Update to address missing cmake target & qualify make_pair.
--

PiperOrigin-RevId: 246355137
2019-05-06 08:24:41 -07:00
Geoffrey Martin-Noble 45c8245cca Substitute getI64IntegerAttr for the more verbose code it replaces.
--

PiperOrigin-RevId: 246227344
2019-05-06 08:24:12 -07:00
Nicolas Vasilache 56c7a957bf Parsing support for Range, View and Slice operations
This CL implements the previously unsupported parsing for Range, View and Slice operations.
    A pass is introduced to lower to the LLVM.
    Tests are moved out of C++ land and into mlir/test/Examples.
    This allows better fitting within standard developer workflows.

--

PiperOrigin-RevId: 245796600
2019-05-06 08:20:55 -07:00
River Riddle 1423acc03c Rename isa_nonnull to isa_and_nonnull to match the upstream llvm name.
--

PiperOrigin-RevId: 244928036
2019-04-23 22:03:14 -07:00
Guangda Lai 7977e62b96 Fix typo (transpose -> reshape).
--

PiperOrigin-RevId: 244270801
2019-04-23 22:00:45 -07:00
Nicolas Vasilache 8370cc7492 Start a Linalg dialect
This CL starts implementing a Linalg dialect with the objective of supporting
    optimizing compilation of loops and library calls for a subset of common linear
    algebra operations.

    This CL starts by simply adding a linalg.range type and an operation with the
    proper roundtripping test.

--

PiperOrigin-RevId: 244189468
2019-04-18 11:50:27 -07:00
Chris Lattner 09c053bfd0 Expand the pretty dialect type system to support arbitrary punctuation and
other characters within the <>'s now that we can.  This will allow quantized
    types to use the pretty syntax (among others) after a few changes.

--

PiperOrigin-RevId: 243521268
2019-04-18 11:48:09 -07:00
Lei Zhang 0836f670f1 Add missing dependencies for EDSC and linalg libraries
This solves the missing "mlir/StandardOps/Ops.h.inc" issue when building
    a fresh checkout on macOS.

--

PiperOrigin-RevId: 243120388
2019-04-11 12:35:29 -07:00
Mehdi Amini 6c6ed466a6 Expose `setupTargetTriple` as a public static method on ExecutionEngine
This allows client to be able to reuse the same logic to setup a module
    for the ExecutionEngine without instanciating one. One use case is running
    the optimization pipeline but not JIT-ing.

--

PiperOrigin-RevId: 242614380
2019-04-11 10:51:24 -07:00
Mehdi Amini c4dee61c0e Fix Toy cmake build: add missing includes
--

PiperOrigin-RevId: 242609231
2019-04-08 23:27:02 -07:00
Mehdi Amini c39592b09c Toy tutorial Chapter 5: Lowering to Linalg and LLVM
--

PiperOrigin-RevId: 242606796
2019-04-08 23:26:54 -07:00
Mehdi Amini a43f216fd5 Automated rollback of changelist 242546977.
PiperOrigin-RevId: 242604949
2019-04-08 23:26:46 -07:00
Nicolas Vasilache 1ee07e7fde De-templatize TensorContractionBase (Linalg example/tutorial)
TensorContractionBase has become too unwieldy with all the CRTP manipulation once less trivial transformations are implemented.
    This CL drops CRTP for inheritance and uses the same name comparison trick to figure out what to cast into.
    As a byproduct, all the -inl.h files disappear.
    To maintain the separation between directories, a LINALG_STEP variable is introduced

--

PiperOrigin-RevId: 242546977
2019-04-08 19:17:56 -07:00
Nicolas Vasilache 046a993967 Add CMakeLists rules for Linalg
--

PiperOrigin-RevId: 242454319
2019-04-08 19:17:56 -07:00
Nicolas Vasilache ca89e7167d Fix build for the Linalg example dialect with MacOS
--

PiperOrigin-RevId: 242443831
2019-04-08 19:17:56 -07:00
Alex Zinenko adb0ca0732 Example Linalg3: manually register the Linalg dialect
This dialect does not have a global constructor and has to be registered
    manually in `main`.  Also fix the way it is exercised in the test.

--

PiperOrigin-RevId: 242434886
2019-04-08 19:17:56 -07:00
Alex Zinenko 8e193e617c Change initialization syntax for ScopedContext in examples
For some reason, the OSS build on macOS was not happy with the initialization
    syntax and was attempting to call a copy constructor.  Hotfix it to use a
    different syntax pending further investigation.

--

PiperOrigin-RevId: 242432634
2019-04-08 19:17:56 -07:00
Mehdi Amini 89d5d36964 Fix bug in Toy tutorial where IR emission stopped after any `print`
--

PiperOrigin-RevId: 242407970
2019-04-08 18:54:25 -07:00
Mehdi Amini fea0560816 Fix Linalg3 lowering to use the floating point element type matching the view
It used to be hardcoded to f32, but Toy tutorial is using f64.

--

PiperOrigin-RevId: 242370172
2019-04-07 18:22:34 -07:00
Mehdi Amini 364b7e624e Add support for f64 type conversion for Linalg dialect to LLVM lowering
--

PiperOrigin-RevId: 242345259
2019-04-07 18:22:22 -07:00
Chris Lattner 72441fcbf2 Change the asmprinter to use pretty syntax for dialect types when it can,
making the IR dumps much nicer.

    This is part 2/3 of the path to making dialect types more nice.  Part 3/3 will
    slightly generalize the set of characters allowed in pretty types and make it
    more principled.

--

PiperOrigin-RevId: 242249955
2019-04-07 18:21:13 -07:00
Nicolas Vasilache a1b4cae30a Post commit cleanups to the Linalg dialect
--

PiperOrigin-RevId: 242181687
2019-04-07 18:20:19 -07:00
River Riddle e4628b79fb Add new utilities for RTTI Operation casting: dyn_cast_or_null and 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
2019-04-07 18:20:07 -07:00
Alex Zinenko 6196c8a9fd Linalg3 example: implement JIT-compilation and execution
Use MLIR's ExecutionEngine to demonstrate how one can implement a simple
    JIT-compiler and executor after fully lowering the Linalg dialect to the LLVM
    IR dialect, using the direct conversion (not going through standard
    loads/stores).

--

PiperOrigin-RevId: 242127690
2019-04-07 18:19:35 -07:00
Mehdi Amini 01e8ec94c3 Fix CMake build: account for renamed files and add missing include on MacOS
--

PiperOrigin-RevId: 242101364
2019-04-05 07:43:23 -07:00
Nicolas Vasilache 92df395068 Linalg portion of the tutorial - part 4
This CL adds declarative tiling support in the linalg dialect by providing:
    1. loop tiling on linalg ops by simply calling into mlir::tile
    2. view tiling on linalg ops by:
      a. computing the subview between for each tile dimension based on the loop tile size and the mapping of loops to operand ranges.
      b. declaring that the tiled form of a tensorcontraction is the same tensorcontraction on subviews, which essentially gives us a recursive form.

    Point 2.b is potentially subject to change in the future.

--

PiperOrigin-RevId: 242058658
2019-04-05 07:43:14 -07:00
River Riddle fde21c6faf NFC: Fix a few typos in the tutorials and one in the comment of FunctionAttr::dropFunctionReference.
--

PiperOrigin-RevId: 242050934
2019-04-05 07:43:05 -07:00
Mehdi Amini d33a9dcc73 Add Chapter 4 for the Toy tutorial: shape inference, function specialization, and basic combines
--

PiperOrigin-RevId: 242050514
2019-04-05 07:42:56 -07:00
Nicolas Vasilache 623e4b9711 Linalg portion of the tutorial - part 3-3
This CL adds the last bit to convert from linalg.LoadOp and linalg.StoreOp to the affine dialect, as well as a unit test to exercise the conversion.

--

PiperOrigin-RevId: 242045826
2019-04-05 07:42:38 -07:00
River Riddle a83181cd20 NFC: Fix erroneous use of 'OpaqueType' with 'Type' when setting the ToyTypeKind, as well as a few mistakes in Chapter 2 of the Toy tutorial.
--

PiperOrigin-RevId: 242021477
2019-04-05 07:42:10 -07:00
River Riddle 6fa3181329 Remove the non-postorder walk functions from Function/Block/Instruction and rename walkPostOrder to walk.
--

PiperOrigin-RevId: 241965239
2019-04-05 07:41:23 -07:00
Alex Zinenko 8b790434e5 Example Linalg3: support Load/Store conversion from Linalg to LLVM IR dialect
Load and Store Linalg operations are converter to their LLVM IR counterparts
    preceded by a sequence of operations that recover the effective address of the
    accessed element.  The address is computed given the subscripts and the view
    descriptor as

        base_pointer + base_offset + SUM_i subscript_i * stride_i.

    Manual testing shows that the resulting LLVM IR for the matrix multiplication
    example can be compiled and executed, producing correct results.

--

PiperOrigin-RevId: 241889003
2019-04-05 07:40:21 -07:00
Mehdi Amini f0a328b6d5 Chapter 3 for Toy tutorial: introduction of a dialect
--

PiperOrigin-RevId: 241849162
2019-04-03 19:22:32 -07:00
Mehdi Amini 3a2955fa1f Rename UnknownType to OpaqueType (NFC)
This came up in a review of the tutorial, it was suggested that "opaque" is more
    descriptive than "unknown" here.

--

PiperOrigin-RevId: 241832927
2019-04-03 19:21:47 -07:00
Mehdi Amini a261ce5b40 Move the top-level `tutorial` as `Linalg` nested in the examples folder
--

PiperOrigin-RevId: 241831176
2019-04-03 19:21:38 -07:00
Mehdi Amini 5854fb9b94 Fix Toy tutorial gcc 7 build (NFC)
--

PiperOrigin-RevId: 241613710
2019-04-02 15:16:30 -07:00
Mehdi Amini 213dda687b Chapter 2 of the Toy tutorial
This introduces a basic MLIRGen through straight AST traversal,
    without dialect registration at this point.

--

PiperOrigin-RevId: 241588354
2019-04-02 13:41:00 -07:00
Mehdi Amini 38b71d6b84 Initial version for chapter 1 of the Toy tutorial
--

PiperOrigin-RevId: 241549247
2019-04-02 13:40:06 -07:00