Commit graph

444 commits

Author SHA1 Message Date
Chenggang Zhao 2b2c13e672 [mlir][docs] A friendlier improvement for the Toy tutorial chapter 4.
Add notes for discarding private-visible functions in the Toy tutorial chapter 4.

Reviewed By: mehdi_amini

Differential Revision: https://reviews.llvm.org/D108026
2021-08-25 00:44:51 +00:00
Logan Chien 88125e8af1 [mlir] Fix attachInterface typo
This commit fixes the documentation typo regarding `attachInterface`.

Differential Revision: https://reviews.llvm.org/D108666
2021-08-24 15:17:52 -07:00
River Riddle 4e103a12d9 [mlir] Add support for VariadicOfVariadic operands
This revision adds native ODS support for VariadicOfVariadic operand
groups. An example of this is the SwitchOp, which has a variadic number
of nested operand ranges for each of the case statements, where the
number of case statements is variadic. Builtin ODS support allows for
generating proper accessors for the nested operand ranges, builder
support, and declarative format support. VariadicOfVariadic operands
are supported by providing a segment attribute to use to store the
operand groups, mapping similarly to the AttrSizedOperand trait
(but with a user defined attribute name).

`build` methods for VariadicOfVariadic operand expect inputs of the
form `ArrayRef<ValueRange>`. Accessors for the variadic ranges
return a new `OperandRangeRange` type, which represents a
contiguous range of `OperandRange`. In the declarative assembly
format, VariadicOfVariadic operands and types are by default
formatted as a comma delimited list of value lists:
`(<value>, <value>), (), (<value>)`.

Differential Revision: https://reviews.llvm.org/D107774
2021-08-23 20:32:31 +00:00
Aart Bik a5ae34afaa [mlir][linalg] fixed typo
Differential Revision: https://reviews.llvm.org/D107915
2021-08-11 11:59:15 -07:00
Alfsonso Gregory fb27e8c76e [MLIR][NFC] Get DiagnosticEngine as a reference in doc
'mlir::DiagnosticEngine::DiagnosticEngine(const mlir::DiagnosticEngine&)' is implicitly deleted because the default definition would be ill-formed.

Reviewed By: rdzhabarov

Differential Revision: https://reviews.llvm.org/D107287
2021-08-04 19:00:18 +00:00
River Riddle 3e5906499f [vscode-mlir] Update package.json in preparation for publishing
Quite a few things were out-of-date, or just not
organized well. This revision updates the extension
name, repo, icon, and many other components in
preperation for publishing the extension to the
marketplace.
2021-07-30 23:53:50 +00:00
Benjamin Kramer 1c9c2c91d4 [mlir] Remove the default isDynamicallyLegal hook
This is redundant with the callback variant and untested. Also remove
the callback-less methods for adding a dynamically legal op, as they
are no longer useful.

Differential Revision: https://reviews.llvm.org/D106786
2021-07-29 11:00:57 +02:00
River Riddle f8479d9de5 [mlir] Set the namespace of the BuiltinDialect to 'builtin'
Historically the builtin dialect has had an empty namespace. This has unfortunately created a very awkward situation, where many utilities either have to special case the empty namespace, or just don't work at all right now. This revision adds a namespace to the builtin dialect, and starts to cleanup some of the utilities to no longer handle empty namespaces. For now, the assembly form of builtin operations does not require the `builtin.` prefix. (This should likely be re-evaluated though)

Differential Revision: https://reviews.llvm.org/D105149
2021-07-28 21:00:10 +00:00
Stella Laurenzo 310c9496d8 Re-engineer MLIR python build support.
* Implements all of the discussed features:
  - Links against common CAPI libraries that are self contained.
  - Stops using the 'python/' directory at the root for everything, opening the namespace up for multiple projects to embed the MLIR python API.
  - Separates declaration of sources (py and C++) needed to build the extension from building, allowing external projects to build custom assemblies from core parts of the API.
  - Makes the core python API relocatable (i.e. it could be embedded as something like 'npcomp.ir', 'npcomp.dialects', etc). Still a bit more to do to make it truly isolated but the main structural reset is done.
  - When building statically, installed python packages are completely self contained, suitable for direct setup and upload to PyPi, et al.
  - Lets external projects assemble their own CAPI common runtime library that all extensions use. No more possibilities for TypeID issues.
  - Begins modularizing the API so that external projects that just include a piece pay only for what they use.
* I also rolled in a re-organization of the native libraries that matches how I was packaging these out of tree and is a better layering (i.e. all libraries go into a nested _mlir_libs package). There is some further cleanup that I resisted since it would have required source changes that I'd rather do in a followup once everything stabilizes.
* Note that I made a somewhat odd choice in choosing to recompile all extensions for each project they are included into (as opposed to compiling once and just linking). While not leveraged yet, this will let us set definitions controlling the namespacing of the extensions so that they can be made to not conflict across projects (with preprocessor definitions).
* This will be a relatively substantial breaking change for downstreams. I will handle the npcomp migration and will coordinate with the circt folks before landing. We should stage this and make sure it isn't causing problems before landing.
* Fixed a couple of absolute imports that were causing issues.

Differential Revision: https://reviews.llvm.org/D106520
2021-07-27 15:54:58 +00:00
Chia-hung Duan d7314b3c09 [mlir-tblgen] Support binding multi-results of NativeCodeCall
We are able to bind NativeCodeCall result as binding operation. To make
table-gen have better understanding in the form of helper function,
we need to specify the number of return values in the NativeCodeCall
template. A VoidNativeCodeCall is added for void case.

Reviewed By: jpienaar

Differential Revision: https://reviews.llvm.org/D102160
2021-07-21 11:23:22 +08:00
Frederik Gossen 9c90725eae [MLIR] Fix documentation of the ExecutionEngine in the toy tutorial example
Differential Revision: https://reviews.llvm.org/D105813
2021-07-13 13:23:43 +02:00
Chia-hung Duan 70eb3bfff0 [mlir-reduce] Fix the grammer in the doc
Reviewed By: jpienaar

Differential Revision: https://reviews.llvm.org/D105623
2021-07-09 08:01:35 +08:00
Tobias Gysi 226f925c3f [mlir][linalg][python] Update integration of OpDSL doc (NFC).
Move the OpDSL doc to a linalg sub folder and updated the integration in the main linalg documentation.

Differential Revision: https://reviews.llvm.org/D105188
2021-07-01 07:41:32 +00:00
Tobias Gysi 42d99bc376 [mlir][linalg][python] Update the OpDSL doc (NFC).
Update the OpDSL documentation to reflect recent changes. In particular, the updated documentation discusses:
- Attributes used to parameterize index expressions
- Shape-only tensor support
- Scalar parameters

Differential Revision: https://reviews.llvm.org/D105123
2021-06-30 12:27:17 +00:00
Chia-hung Duan 7dec20dbb6 [mlir-reduce] Add doc for usage of mlir-reduce
Reviewed By: jpienaar

Differential Revision: https://reviews.llvm.org/D103683
2021-06-29 18:20:23 +08:00
Jacques Pienaar 5bc9cc1332 [drr] Enable specifying range in NativeCodeCall replacement.
This enables creating a replacement rule where range of positional replacements
need not be spelled out, or are not known (e.g., enable having a rewrite that
forward all operands to a call generically).

Differential Revision: https://reviews.llvm.org/D104955
2021-06-28 13:42:16 -07:00
Jack Xia 4666f309df Fix typo in Toy Tutorial Ch-4
multiple_transpose -> multiply_transpose
2021-06-23 03:33:34 +00:00
River Riddle d1baf28954 [mlir] Add support to SourceMgrDiagnosticHandler for filtering FileLineColLocs
This revision adds support for passing a functor to SourceMgrDiagnosticHandler for filtering out FileLineColLocs when emitting a diagnostic. More specifically, this can be useful in situations where there may be large CallSiteLocs with locations that aren't necessarily important/useful for users.

For now the filtering support is limited to FileLineColLocs, but conceptually we could allow filtering for all locations types if a need arises in the future.

Differential Revision: https://reviews.llvm.org/D103649
2021-06-18 21:12:28 +00:00
Sean Silva 7f7be19e6a [mlir] Add notes about using external interface application.
Differential Revision: https://reviews.llvm.org/D104489
2021-06-18 07:42:47 -07:00
Alex Zinenko 23cdf7b6ed [mlir] separable registration of operation interfaces
This is similar to attribute and type interfaces and mostly the same mechanism
(FallbackModel / ExternalModel, ODS generation). There are minor differences in
how the concept-based polymorphism is implemented for operations that are
accounted for by ODS backends, and this essentially adds a test and exposes the
API.

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D104294
2021-06-17 12:00:31 +02:00
Alex Zinenko a4f81b2054 [mlir] ODS: emit interface traits outside of the interface class
ODS currently emits the interface trait class as a nested class inside the
interface class. As an unintended consequence, the default implementations of
interface methods have implicit access to static fields of the interface class,
e.g. those declared in `extraClassDeclaration`, including private methods (!),
or in the parent class. This may break the use of default implementations for
external models, which are not defined in the interface class, and generally
complexifies the abstraction.

Emit intraface traits outside of the interface class itself to avoid accidental
implicit visibility. Public static fields can still be accessed via explicit
qualification with a class name, e.g., `MyOpInterface::staticMethod()` instead
of `staticMethod`.

Update the documentation to clarify the role of `extraClassDeclaration` in
interfaces.

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D104384
2021-06-17 10:25:35 +02:00
River Riddle 854ef875b9 [mlir-vscode] Add a link to mlir.llvm.org at the top of the vscode extension doc 2021-06-16 18:22:02 -07:00
River Riddle d3c895a870 [mlir-lsp-server] Add an explicit blurb on where to send code contributions.
When the vscode extension is published, it may be unclear how to contribute improvements to the extension. This revision makes it clear that contributions should follow the traditional LLVM guidelines.
2021-06-16 18:22:01 -07:00
River Riddle fcecfcb92c [mlir-lsp-server][Docs] Tweak the documentation for the visual studio code extension
This revision updates the feature set, and cleans up the contributing section a little.
2021-06-16 17:58:53 -07:00
Mehdi Amini c8a3f561eb Decouple registring passes from specifying argument/description
This patch changes the (not recommended) static registration API from:

 static PassRegistration<MyPass> reg("my-pass", "My Pass Description.");

to:

 static PassRegistration<MyPass> reg;

And the explicit registration from:

  void registerPass("my-pass", "My Pass Description.",
                    [] { return createMyPass(); });

To:

  void registerPass([] { return createMyPass(); });

It is expected that Pass implementations overrides the getArgument() method
instead. This will ensure that pipeline description can be printed and parsed
back.

Differential Revision: https://reviews.llvm.org/D104421
2021-06-16 23:41:50 +00:00
Tobias Gysi ff2ef4d684 [mlir][linalg] Adapt yaml codegen to support scalar parameters.
The patch updates the C++ yaml code generation to support scalar operands as added in https://reviews.llvm.org/D104220.

Differential Revision: https://reviews.llvm.org/D104224
2021-06-15 15:20:48 +00:00
Alex Zinenko 9b2a1bcf6f [mlir] separable registration of attribute and type interfaces
It may be desirable to provide an interface implementation for an attribute or
a type without modifying the definition of said attribute or type. Notably,
this allows to implement interfaces for attributes and types outside of the
dialect that defines them and, in particular, provide interfaces for built-in
types. Provide the mechanism to do so.

Currently, separable registration requires the attribute or type to have been
registered with the context, i.e. for the dialect containing the attribute or
type to be loaded. This can be relaxed in the future using a mechanism similar
to delayed dialect interface registration.

See https://llvm.discourse.group/t/rfc-separable-attribute-type-interfaces/3637

Depends On D104233

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D104234
2021-06-15 15:20:27 +02:00
Marius Brehler f60d23c738 [mlir][docs] Reorder PassWrapper arguments
Fixes the order of template arguments passed to the `PassWrapper`.

Reviewed By: mehdi_amini

Differential Revision: https://reviews.llvm.org/D104132
2021-06-11 21:49:29 +02:00
Geoffrey Martin-Noble 4f6ec382c8 [MLIR] Document that Dialect Conversion traverses in preorder
Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D102525
2021-06-10 15:08:56 -07:00
River Riddle bb97959949 [mlir-lsp-server] Document the features provided by the language server
This revision adds focused documentation on each of the individual features of the server, with images showcasing how they look in vscode.

Differential Revision: https://reviews.llvm.org/D103942
2021-06-10 10:58:39 -07:00
Lei Zhang 56f60a1ce7 [mlir][spirv] Use SingleBlock + NoTerminator for spv.module
This allows us to remove the `spv.mlir.endmodule` op and
all the code associated with it.

Along the way, tightened the APIs for `spv.module` a bit
by removing some aliases. Now we use `getRegion` to get
the only region, and `getBody` to get the region's only
block.

Reviewed By: mravishankar, hanchung

Differential Revision: https://reviews.llvm.org/D103265
2021-06-09 14:00:06 -04:00
Pavel Krajcevski acc3ca3b7a Fix typo in Toy tutorial Ch1
This aligns the website with the actual test case in the repo.

Reviewed By: mehdi_amini

Differential Revision: https://reviews.llvm.org/D84193
2021-06-09 16:09:01 +00:00
Alex Zinenko ada9aa5a22 [mlir] Make MemRef element type extensible
Historically, MemRef only supported a restricted list of element types that
were known to be storable in memory. This is unnecessarily restrictive given
the open nature of MLIR's type system. Allow types to opt into being used as
MemRef elements by implementing a type interface. For now, the interface is
merely a declaration with no methods. Later, methods to query, e.g., the type
size or whether a type can alias elements of another type may be added.

Harden the "standard"-to-LLVM conversion against memrefs with non-builtin
types.

See https://llvm.discourse.group/t/rfc-memref-of-custom-types/3558.

Depends On D103826

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D103827
2021-06-08 11:11:30 +02:00
River Riddle 0289a2692e [mlir] Add support for filtering patterns based on debug names and labels
This revision allows for attaching "debug labels" to patterns, and provides to FrozenRewritePatternSet for  filtering patterns based on these labels (in addition to the debug name of the pattern). This will greatly simplify the ability to write tests targeted towards specific patterns (in cases where many patterns may interact),  will also simplify debugging pattern application by observing how application changes when enabling/disabling specific patterns.

To enable better reuse of pattern rewrite options between passes, this revision also adds a new PassUtil.td file to the Rewrite/ library that will allow for passes to easily hook into a common interface for pattern debugging. Two options are used to seed this utility, `disable-patterns` and `enable-patterns`, which are used to enable the filtering behavior indicated above.

Differential Revision: https://reviews.llvm.org/D102441
2021-06-02 12:05:25 -07:00
Lewuathe 119bf57ab6 Fix invalid math formulas in quantization doc
A single backslash is not properly escaped in the web documentation. We can make sure to escape for rendering subscripts.

Additionally, it also fixed the mal-formed equations in //"Affine to fixed point"// and //"Fixed point to affine"// sections. With this fix, the page is rendered as follows.

Reviewed By: mehdi_amini

Differential Revision: https://reviews.llvm.org/D101252
2021-06-01 03:50:59 +00:00
Markus Böck 31d1ae7975 [mlir][doc] Fix links and references in documentation of Tutorials
This patch is the third in a series of patches fixing markdown links and references inside the mlir documentation.

This patch addresses all broken references to other markdown files and sections inside the Tutorials folder.

Differential Revision: https://reviews.llvm.org/D103017
2021-05-25 20:18:50 +02:00
Tobias Gysi 6779fcb26f [mlir][linalg] Update Linalg.md (NFC).
Update the paragraph on generic / indexed_generic to reflect the unification of these operations.

Differential Revision: https://reviews.llvm.org/D102775
2021-05-25 17:46:41 +00:00
Markus Böck 9b99336d5d [mlir][doc] Fix links and references in documentation of Dialects
This patch is the first in a series of patches fixing markdown links and references inside the mlir documentation. I chose to split it in a few reviews to be able to iterate quicker and to ease review.

This patch addresses all broken references to other markdown files and sections inside the Dialects folder.

One change that was also done was to insert '/' between the markdown files and section:
Example:
Builtin.md#integertype
was changed to:
Builtin.md/#integertype

After compilation, hugo then translates the later to jump directly to the integer type section, but not the former. Not inserting the slash would simply jump to just the Builtin page, instead of the integertype section. I therefore changed occurrences of the former version to the later as well.

Differential Revision: https://reviews.llvm.org/D103011
2021-05-25 14:51:15 +02:00
Markus Böck 5e2a302e37 [mlir][doc] Fix links and references in documentation of Rationale
This patch is the second in a series of patches fixing markdown links and references inside the mlir documentation.

This patch addresses all broken references to other markdown files and sections inside the Rationale folder.

In addition to fixing the links and references like in the previous patch, I also changed references which are URLs to the mlir.llvm.org/docs website, to proper relative markdown references instead.

Differential Revision: https://reviews.llvm.org/D103013
2021-05-25 14:48:07 +02:00
Markus Böck d35bd98651 [mlir][doc] Fix links and references in top level docs directory
This is the fourth and final patch in a series of patches fixing markdown links and references inside the mlir documentation. This patch combined with the other three should fix almost every broken link on mlir.llvm.org as far as I can tell.

This patch in particular addresses all Markdown files in the top level docs directory.

Differential Revision: https://reviews.llvm.org/D103032
2021-05-24 18:43:00 +02:00
Uday Bondhugula 9c21ddb70a [MLIR] Make MLIR cmake variable names consistent
Fix inconsistent MLIR CMake variable names. Consistently name them as
MLIR_ENABLE_<feature>.

Eg: MLIR_CUDA_RUNNER_ENABLED -> MLIR_ENABLE_CUDA_RUNNER

MLIR follows (or has mostly followed) the convention of naming
cmake enabling variables in the from MLIR_ENABLE_... etc. Using a
convention here is easy and also important for convenience. A counter
pattern was started with variables named MLIR_..._ENABLED. This led to a
sequence of related counter patterns: MLIR_CUDA_RUNNER_ENABLED,
MLIR_ROCM_RUNNER_ENABLED, etc.. From a naming standpoint, the imperative
form is more meaningful. Additional discussion at:
https://llvm.discourse.group/t/mlir-cmake-enable-variable-naming-convention/3520

Switch all inconsistent ones to the ENABLE form. Keep the couple of old
mappings needed until buildbot config is migrated.

Differential Revision: https://reviews.llvm.org/D102976
2021-05-24 08:43:10 +05:30
Andrew Young ab3cd2601b
[mlir][docs] Add memref and sparse_tensor to Passes.md
These pass documents belong on the main pass page, and not generated as
top level pages.

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D102947
2021-05-21 15:23:39 -07:00
Marius Brehler b3127c94dd [mlir][docs] Fix links to index and integer types
Reviewed By: mehdi_amini

Differential Revision: https://reviews.llvm.org/D102922
2021-05-21 18:21:29 +02:00
Nicolas Vasilache 8eb18a0f3e [mlir][Standard] NFC - Drop remaining EDSC usage
Drop the remaining EDSC subdirectories and update all uses.

Differential Revision: https://reviews.llvm.org/D102911
2021-05-21 10:40:39 +00:00
River Riddle 92469ca027 [mlir] Refactor the implementation of pass crash reproducers
The current implementation has several key limitations and weirdness, e.g local reproducers don't support dynamic pass pipelines, error messages don't include the passes that failed, etc. This revision refactors the implementation to support more use cases, and also be much cleaner.

The main change in this revision, aside from moving the implementation out of Pass.cpp and into its own file, is the addition of a crash recovery pass instrumentation. For local reproducers, this instrumentation handles setting up the recovery context before executing each pass. For global reproducers, the instrumentation is used to provide a more detailed error message, containing information about which passes are running and on which operations.

Example of new message:

```
error: Failures have been detected while processing an MLIR pass pipeline
note: Pipeline failed while executing [`TestCrashRecoveryPass` on 'module' operation: @foo]: reproducer generated at `crash-recovery.mlir.tmp`
```

Differential Revision: https://reviews.llvm.org/D101854
2021-05-19 16:59:53 -07:00
River Riddle 64ce90e1af [mlir] Add a new print-ir-after-failure IR pass printing flag
This flag will print the IR after a pass only in the case where the pass failed. This can be useful to more easily view the invalid IR, without needing to print after every pass in the pipeline.

Differential Revision: https://reviews.llvm.org/D101853
2021-05-19 16:54:20 -07:00
hasheddan 0316f3e649 [mlir][docs] Fix minor typos in vector dialect docs
Updates a minor typo in vector dialect documentation.

Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D101203
2021-05-19 14:20:28 -07:00
River Riddle 2257e4a70e [mlir] Allow derived rewrite patterns to define a non-virtual initialize hook
This is a hook that allows for providing custom initialization of the pattern, e.g. if it has bounded recursion, setting the debug name, etc., without needing to define a custom constructor. A non-virtual hook was chosen to avoid polluting the vtable with code that we really just want to be inlined when constructing the pattern. The alternative to this would be to just define a constructor for each pattern, this unfortunately creates a lot of otherwise unnecessary boiler plate for a lot of patterns and a hook provides a much simpler/cleaner interface for the very common case.

Differential Revision: https://reviews.llvm.org/D102440
2021-05-18 14:40:32 -07:00
River Riddle 93cb71a464 [mlir-docs] Add a blurb on recursion during pattern application
We currently do not document how the pattern rewriter infra treats recursion when it gets detected. This revision adds a blurb on recursion in patterns, and how patterns can signal that they are equipped to handle it.

Differential Revision: https://reviews.llvm.org/D102439
2021-05-18 14:40:32 -07:00
Marius Brehler dfd929d261 [mlir][docs] Fix broken link to Toy example 2021-05-18 07:47:12 +00:00