Commit Graph

48 Commits

Author SHA1 Message Date
Julian Lettner 99d6e05e71 [lit] Improve naming of test result categories
Improve consistency when printing test results:
Previously we were using different labels for group names (the header
for the list of, e.g., failing tests) and summary count lines.  For
example, "Failing Tests"/"Unexpected Failures".  This commit changes lit
to label things consistently.

Improve wording of labels:
When talking about individual test results, the first word in
"Unexpected Failures", "Expected Passes", and "Individual Timeouts" is
superfluous.  Some labels contain the word "Tests" and some don't.
Let's simplify the names.

Before:
```
Failing Tests (1):
  ...

Expected Passes    : 3
Unexpected Failures: 1
```

After:
```
Failed Tests (1):
  ...

Passed: 3
Failed: 1
```

Reviewed By: ldionne

Differential Revision: https://reviews.llvm.org/D77708
2020-06-05 08:14:42 -07:00
Marius Brehler b0b2507717 [mlir] Add test to check if standalone dialect is registered
Summary: Add a test to check if the standalone dialect is registered within standalone-opt. Similar to the mlir-opt commandline.mlir test.

Reviewers: Kayjukh, stephenneuendorffer

Reviewed By: Kayjukh

Subscribers: mehdi_amini, rriddle, jpienaar, shauheen, antiagainst, nicolasvasilache, arpith-jacob, mgester, lucyrfox, liufengdb, Joonsoo, grosul1, frgossen, jurahul, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D80764
2020-05-29 00:34:34 +02:00
Marius Brehler 3bff62d45f [mlir] Extend standalone example by standalone-translate
Extend the standalone by standalone-translate, based on mlir-translate.

Differential Revision: https://reviews.llvm.org/D80737
2020-05-28 14:07:55 -07:00
Rahul Joshi 5633813bf3 [MLIR] Fix several misc issues in in Toy tutorial
Summary:
- Fix comments in several places
- Eliminate extra ' in AST dump and adjust tests accordingly

Differential Revision: https://reviews.llvm.org/D78399
2020-05-11 16:56:47 -07:00
Stephen Neuendorffer 175a3df9c7 [MLIR] Add a tests for out of tree dialect example.
This attempts to ensure that out of tree usage remains stable.

Differential Revision: https://reviews.llvm.org/D78656
2020-05-05 09:22:49 -07:00
Lucy Fox a0d5e54966 [MLIR] Update tutorial to add missing tests and bring directory paths and code snippets up to date.
Summary:
The tests referred to in Chapter 3 of the tutorial were missing from the tutorial test
directory; this adds those missing tests. This also cleans up some stale directory paths and code
snippets used throughout the tutorial.

Differential Revision: https://reviews.llvm.org/D76809
2020-04-17 20:15:16 -07:00
Lucy Fox a6b427167e [MLIR] Update tutorial to add missing tests and bring directory paths and code snippets up to date.
Summary:
The tests referred to in Chapter 3 of the tutorial were missing from the tutorial test
directory; this adds those missing tests. This also cleans up some stale directory paths and code
snippets used throughout the tutorial.

Differential Revision: https://reviews.llvm.org/D76809
2020-04-17 20:15:15 -07:00
Lucy Fox 495cf27291 [MLIR] Update tutorial to add missing tests and bring directory paths and code snippets up to date.
Summary:
The tests referred to in Chapter 3 of the tutorial were missing from the tutorial test
directory; this adds those missing tests. This also cleans up some stale directory paths and code
snippets used throughout the tutorial.

Subscribers: mehdi_amini, rriddle, jpienaar, burmako, shauheen, antiagainst, nicolasvasilache, arpith-jacob, mgester, aartbik, liufengdb, Joonsoo, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D76809
2020-04-17 20:15:15 -07:00
Matthias Kramm cb530ec8b8 [mlir][Tutorial] Make parsing an empty file print a better error.
Summary:
Previously, we would, for an empty file, print the somewhat confusing
  Assertion `tok == curTok [...]' failed.
With this change, we now print
  Parse error [...]: expected 'def' [...]

This only affects the parser from chapters 1-6, since the more advanced
chapter 7 parser is actually able to generate an empty module from an
empty file.  Nonetheless, this commit also adds the additional check to
the chapter 7 parser, for consistency.

Differential Revision: https://reviews.llvm.org/D75534
2020-03-03 13:21:05 -08:00
River Riddle 0050e8f0cf [mlir][Tutorial] Add a section to Toy Ch.2 detailing the custom assembly format.
Summary:
This details the C++ format as well as the new declarative format. This has been one of the major missing pieces from the toy tutorial.

Differential Revision: https://reviews.llvm.org/D74938
2020-02-21 15:15:32 -08:00
River Riddle 57540c96be [mlir] Replace toy::DeadFunctionEliminationPass with symbolDCEPass.
Summary:
The dead function elimination pass in toy was a temporary stopgap until we had proper dead function elimination support in MLIR. Now that this functionality is available, this pass is no longer necessary.

Differential Revision: https://reviews.llvm.org/D72483
2020-01-27 23:48:06 -08:00
Aart Bik 9f89c34f4b Fixed typo in Toy tutorial (second var e -> var f)
PiperOrigin-RevId: 282810649
2019-11-27 11:58:45 -08:00
River Riddle 6b4e30b7c8 Add Ch-7 of the toy tutorial detailing how to define new types.
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
2019-11-07 09:54:04 -08:00
River Riddle 4514cdd5eb Cleanup and rewrite Ch-4.md.
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
2019-10-21 11:32:39 -07:00
River Riddle 941a1c4332 NFC: Fix remaining usages of MulOp as matrix multiplication.
MulOp now represents an element-wise multiplication instead of a matrix multiplication.

PiperOrigin-RevId: 275886774
2019-10-21 11:31:32 -07:00
River Riddle 1bdfc9e74d NFC: Fix typo : Retur -> Return
PiperOrigin-RevId: 275745931
2019-10-20 15:13:20 -07:00
River Riddle dae0ae6879 NFC: Delete the Linalg tutorial.
This part of the tutorial is now covered by a new flow in Toy. This also removes a point of confusion as there is also a proper Linalg dialect.

PiperOrigin-RevId: 275338933
2019-10-17 14:27:37 -07:00
River Riddle 0372eb413f Add Ch.6 of the Toy tutorial.
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
2019-10-17 14:22:13 -07:00
River Riddle bdc250c5a7 Fix invalid transpose in example and add proper verification.
The transpose in the example had the same result type as its input, which is incorrect.

PiperOrigin-RevId: 275186568
2019-10-16 22:37:00 -07:00
River Riddle 1ba9bb0507 Add Ch.5 of the toy tutorial.
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
2019-10-16 17:45:09 -07:00
River Riddle 7045471913 Add support for inlining toy call operations.
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
2019-10-16 17:32:57 -07:00
Sana Damani 3940b90d84 Update Chapter 4 of the Toy tutorial
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
2019-10-16 12:19:39 -07:00
Jacques Pienaar e88dbc8c95 Update comments in ast.toy
PiperOrigin-RevId: 275084969
2019-10-16 12:08:24 -07:00
Sana Damani cd45b0c8d9 Update Chapter 3 to demonstrate pattern match and rewrite optimizations
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
2019-10-15 11:40:44 -07:00
River Riddle 300112e135 Merge Ch3 of the Toy tutorial into chapter 2.
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
2019-10-14 21:13:45 -07:00
Alex Zinenko 8c2ea32072 Emit LLVM IR equivalent of sizeof when lowering alloc operations
Originally, the lowering of `alloc` operations has been computing the number of
bytes to allocate when lowering based on the properties of MLIR type. This does
not take into account type legalization that happens when compiling LLVM IR
down to target assembly. This legalization can widen the type, potentially
leading to out-of-bounds accesses to `alloc`ed data due to mismatches between
address computation that takes the widening into account and allocation that
does not. Use the LLVM IR's equivalent of `sizeof` to compute the number of
bytes to be allocated:
  %0 = getelementptr %type* null, %indexType 0
  %1 = ptrtoint %type* %0 to %indexType
adapted from
http://nondot.org/sabre/LLVMNotes/SizeOf-OffsetOf-VariableSizedStructs.txt

PiperOrigin-RevId: 274159900
2019-10-11 06:33:26 -07:00
Nicolas Vasilache 923b33ea16 Normalize MemRefType lowering to LLVM as strided MemRef descriptor
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
2019-09-30 11:58:54 -07:00
Nicolas Vasilache b569c969f0 Remove spurious debug spew in tests
PiperOrigin-RevId: 271624731
2019-09-27 12:31:43 -07:00
Nicolas Vasilache ddf737c5da Promote MemRefDescriptor to a pointer to struct when passing function boundaries in LLVMLowering.
The strided MemRef RFC discusses a normalized descriptor and interaction with library calls (https://groups.google.com/a/tensorflow.org/forum/#!topic/mlir/MaL8m2nXuio).
Lowering of nested LLVM structs as value types does not play nicely with externally compiled C/C++ functions due to ABI issues.
Solving the ABI problem generally is a very complex problem and most likely involves taking
a dependence on clang that we do not want atm.

A simple workaround is to pass pointers to memref descriptors at function boundaries, which this CL implement.

PiperOrigin-RevId: 271591708
2019-09-27 09:57:36 -07:00
Nicolas Vasilache 42d8fa667b Normalize lowering of MemRef types
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
2019-09-24 11:21:49 -07:00
Alex Zinenko c335d9d313 LLVM dialect: prefix auxiliary operations with "mlir."
Some of the operations in the LLVM dialect are required to model the LLVM IR in
MLIR, for example "constant" operations are needed to declare a constant value
since MLIR, unlike LLVM, does not support immediate values as operands.  To
avoid confusion with actual LLVM operations, we prefix such axuiliary
operations with "mlir.".

PiperOrigin-RevId: 266942838
2019-09-03 09:10:56 -07:00
River Riddle 6f68def852 Update Ch.2 of the Toy tutorial.
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
2019-08-27 12:44:27 -07:00
River Riddle 89bc449cee Standardize the value numbering in the AsmPrinter.
Change the AsmPrinter to number values breadth-first so that values in adjacent regions can have the same name. This allows for ModuleOp to contain operations that produce results. This also standardizes the special name of region entry arguments to "arg[0-9+]" now that Functions are also operations.

PiperOrigin-RevId: 257225069
2019-07-09 10:41:00 -07:00
River Riddle 679a3b4191 Change the attribute dictionary syntax to separate name and value with '='.
The current syntax separates the name and value with ':', but ':' is already overloaded by several other things(e.g. trailing types). This makes the syntax difficult to parse in some situtations:

Old:
  "foo: 10 : i32"

New:
  "foo = 10 : i32"
PiperOrigin-RevId: 255097928
2019-06-25 19:06:34 -07:00
River Riddle 4842b2d42e Modify the syntax of the the ElementsAttrs to print the type as a colon type.
This is the standard syntax for types on operations, and is also already used by IntegerAttr and FloatAttr.

Example:
  dense<5> : tensor<i32>
  dense<[3]> : tensor<1xi32>
PiperOrigin-RevId: 255069157
2019-06-25 16:06:58 -07:00
Geoffrey Martin-Noble fd99b6ce97 Remove unnecessary -verify-diagnostics
These were likely added in error because of confusion about the flag when it was just called "-verify". The extra flag doesn't cause much harm, but it does make mlir-opt do more work and clutter the RUN line

PiperOrigin-RevId: 254037016
2019-06-19 23:08:13 -07:00
Geoffrey Martin-Noble d7d69569e7 Rename -verify mlir-opt flag to -verify-expected-diagnostics
This name has caused some confusion because it suggests that it's running op verification (and that this verification isn't getting run by default).

PiperOrigin-RevId: 254035268
2019-06-19 23:08:03 -07:00
River Riddle b5a34406a8 Update the Parser to support parsing/printing DenseElementAttrs with a splat value. The syntax for this is the same as 0-D tensors:
dense<tensor<100x100x100xi32>, 10>
  dense<tensor<1x1x1xi64>, -5>

PiperOrigin-RevId: 252907880
2019-06-19 23:00:24 -07:00
River Riddle 06b0db5311 Remove the Toy/* file path from the location check lines. This assumes a specific file path format that breaks on MSVC.
--

PiperOrigin-RevId: 250549223
2019-06-01 20:07:40 -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
Mehdi Amini c39592b09c Toy tutorial Chapter 5: Lowering to Linalg and LLVM
--

PiperOrigin-RevId: 242606796
2019-04-08 23:26:54 -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
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
Mehdi Amini 092f3facad Fix Toy Ch3 testing with CMake
Mainly a missing dependency caused the tests to pass if one already built
    the repo, but not from a clean (or incremental) build.

--

PiperOrigin-RevId: 241852313
2019-04-03 19:22:42 -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 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