Commit Graph

99 Commits

Author SHA1 Message Date
Boian Petkantchin f1b922188e [MLIR][Math] Add erf to math dialect
Add math.erf lowering to libm call.
Add math.erf polynomial approximation.

Reviewed By: silvas, ezhulenev

Differential Revision: https://reviews.llvm.org/D112200
2021-10-25 18:30:17 +00:00
xndcn 8c1553f0d7 [mlir][spirv] Add memory semantics verify for atomic operations
Differential Revision: https://reviews.llvm.org/D111510
2021-10-14 00:00:55 +08:00
Lei Zhang 070b0af9b8 [mlir][spirv] Fix path in define_enum.sh script
Reviewed By: mravishankar

Differential Revision: https://reviews.llvm.org/D108310
2021-10-05 09:32:01 -04:00
Mehdi Amini 4e7c0a37c9 Update MLIR generate-test-checks.py to add the notice from the source into the generated file
Folks may not read the source of the tool and miss these instructions.

Differential Revision: https://reviews.llvm.org/D110082
2021-09-20 23:19:40 +00:00
River Riddle 0d74bd332d [vscode-mlir] Add proper support for mlir markdown codeblocks
A special language contribution is required for properly
supporting markdown code blocks in vscodes builtin markdown
grammar, see https://github.com/mjbvz/vscode-fenced-code-block-grammar-injection-example
for more details.
2021-08-03 19:55:31 +00:00
River Riddle 634b086f6e [vscode-mlir] Fix the package repo url.
It should be llvm/vscode-mlir not llvm-project/vscode-mlir.
2021-07-31 01:10:27 +00:00
River Riddle 03b2d1a659 [mlir-vscode] Create a proper output channel for the MLIRContext
This allows for reusing the same output channel when the extension reloads after updating the server. Currently, whenever the extension restarts a new output channel is created (which can lead to a large number of seemingly dead output channels).
2021-07-30 23:53:50 +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
River Riddle 473a21c0e9 [vscode-mlir] Add support for restarting the server on setting/server changes
This revision adds detection for changes to either the mlir-lsp-server binary or the setting, and prompts the user to restart the server. Whether the user gets prompted or not is a configurable setting in the extension, and this setting may updated based on the user response to the prompt.

Differential Revision: https://reviews.llvm.org/D104501
2021-06-29 00:08:44 +00:00
Uday Bondhugula 18c8c934d8 [MLIR] Introduce scf.execute_region op
Introduce the execute_region op that is able to hold a region which it
executes exactly once. The op encapsulates a CFG within itself while
isolating it from the surrounding control flow. Proposal discussed here:
https://llvm.discourse.group/t/introduce-std-inlined-call-op-proposal/282

execute_region enables one to inline a function without lowering out all
other higher level control flow constructs (affine.for/if, scf.for/if)
to the flat list of blocks / CFG form. It thus allows the benefit of
transforms on higher level control flow ops available in the presence of
the inlined calls. The inlined calls continue to benefit from
propagation of SSA values across their top boundary. Functions won’t
have to remain outlined until later than desired.  Abstractions like
affine execute_regions, lambdas with implicit captures could be lowered
to this without first lowering out structured loops/ifs or outlining.
But two potential early use cases are of: (1) an early inliner (which
can inline functions by introducing execute_region ops), (2) lowering of
an affine.execute_region, which cleanly maps to an scf.execute_region
when going from the affine dialect to the scf dialect.

Differential Revision: https://reviews.llvm.org/D75837
2021-06-18 15:22:33 +05:30
River Riddle c0e6f2f43a [mlir-vscode] Fix dependencies to enable packaging the extension properly. 2021-06-10 11:34:04 -07:00
River Riddle b810e3a552 [mlir] Add a vscode language extension for MLIR
This utilizes the mlir-lsp server to provide language services for MLIR files opened in vscode. The extension currently supports syntax highlighting, as well as tracking definitions/uses/source locations for SSA values and blocks.

Differential Revision: https://reviews.llvm.org/D100607
2021-04-21 14:44:37 -07:00
Jacques Pienaar 04c66edd32 [mlir] Add simple jupyter kernel
Simple jupyter kernel using mlir-opt and reproducer to run passes.
Useful for local experimentation & generating examples. The export to
markdown from here is not immediately useful nor did I define a
CodeMirror synax to make the HTML output prettier. It only supports one
level of history (e.g., `_`) as I was mostly using with expanding a
pipeline one pass at a time and so was all I needed.

I placed this in utils directory next to editor & debugger utils.

Differential Revision: https://reviews.llvm.org/D95742
2021-02-21 18:16:06 -08:00
Lei Zhang 167fb9b4b4 [mlir][spirv] Fix script for availability autogen and refresh ops
Previously we only autogen the availability for ops that are
direct instantiating `SPV_Op` and expected other subclasses of
`SPV_Op` to define aggregated availability for all ops. This is
quite error prone and we can miss capabilities for certain ops.
Also it's arguable to have multiple levels of subclasses and try
to deduplicate too much: having the availability directly in the
op can be quite explicit and clear. A few extra lines of
declarative code is fine.

Reviewed By: mravishankar

Differential Revision: https://reviews.llvm.org/D95236
2021-01-22 13:07:36 -05:00
MaheshRavishankar 615167c9f7 [mlir]][SPIRV] Define OrderedOp and UnorderedOp and add lowerings from Standard.
Define OrderedOp and UnorderedOp instructions in SPIR-V and convert
cmpf operations with `ord` and `uno` tag to these instructions
respectively.

Differential Revision: https://reviews.llvm.org/D95098
2021-01-21 07:56:44 -08:00
MaheshRavishankar 4234292ecf [mlir][SPIRV] Rename OpSpecConstantOperation -> OpSpecConstantOp
The SPIR-V spec uses OpSpecConstantOp. Using an inconsistent name
makes the dialect generation scripts fail. Update to use the right
operation name, and fix the auto generation scripts as well.

Differential Revision: https://reviews.llvm.org/D95097
2021-01-21 07:56:43 -08:00
Valentin Clement cf0173de69 [mlir] Add better support for f80 and f128
Add builtin f80 and f128 following @schweitz proposition
https://llvm.discourse.group/t/rfc-adding-better-support-for-higher-precision-floating-point/2526/5

Reviewed By: ftynse, rriddle

Differential Revision: https://reviews.llvm.org/D94737
2021-01-15 10:29:48 -05:00
Sean Silva 129d6e554e [mlir] Move `std.tensor_cast` -> `tensor.cast`.
This is almost entirely mechanical.

Differential Revision: https://reviews.llvm.org/D93357
2020-12-17 16:06:56 -08:00
Sean Silva 444822d77a Revert "Revert "[mlir] Start splitting the `tensor` dialect out of `std`.""
This reverts commit 0d48d265db.

This reapplies the following commit, with a fix for CAPI/ir.c:

[mlir] Start splitting the `tensor` dialect out of `std`.

This starts by moving `std.extract_element` to `tensor.extract` (this
mirrors the naming of `vector.extract`).

Curiously, `std.extract_element` supposedly works on vectors as well,
and this patch removes that functionality. I would tend to do that in
separate patch, but I couldn't find any downstream users relying on
this, and the fact that we have `vector.extract` made it seem safe
enough to lump in here.

This also sets up the `tensor` dialect as a dependency of the `std`
dialect, as some ops that currently live in `std` depend on
`tensor.extract` via their canonicalization patterns.

Part of RFC: https://llvm.discourse.group/t/rfc-split-the-tensor-dialect-from-std/2347/2

Differential Revision: https://reviews.llvm.org/D92991
2020-12-11 14:30:50 -08:00
Sean Silva 0d48d265db Revert "[mlir] Start splitting the `tensor` dialect out of `std`."
This reverts commit cab8dda90f.

I mistakenly thought that CAPI/ir.c failure was unrelated to this
change. Need to debug it.
2020-12-11 14:15:41 -08:00
Sean Silva cab8dda90f [mlir] Start splitting the `tensor` dialect out of `std`.
This starts by moving `std.extract_element` to `tensor.extract` (this
mirrors the naming of `vector.extract`).

Curiously, `std.extract_element` supposedly works on vectors as well,
and this patch removes that functionality. I would tend to do that in
separate patch, but I couldn't find any downstream users relying on
this, and the fact that we have `vector.extract` made it seem safe
enough to lump in here.

This also sets up the `tensor` dialect as a dependency of the `std`
dialect, as some ops that currently live in `std` depend on
`tensor.extract` via their canonicalization patterns.

Part of RFC: https://llvm.discourse.group/t/rfc-split-the-tensor-dialect-from-std/2347/2

Differential Revision: https://reviews.llvm.org/D92991
2020-12-11 13:50:55 -08:00
River Riddle 09f7a55fad [mlir][Types][NFC] Move all of the builtin Type classes to BuiltinTypes.h
This is part of a larger refactoring the better congregates the builtin structures under the BuiltinDialect. This also removes the problematic "standard" naming that clashes with the "standard" dialect, which is not defined within IR/. A temporary forward is placed in StandardTypes.h to allow time for downstream users to replaced references.

Differential Revision: https://reviews.llvm.org/D92435
2020-12-03 18:02:10 -08:00
Christian Sigg e851e566d4 [mlir] Fix TypeID lookup in GDB pretty printers.
The TypeID instance was moved in D89153.

It wasn't caught that it broke MLIR pretty printers because pre-merge checks don't run check-debuginfo.

Avoid disabling all MLIR printers in case this happens again by catching the exception.

Reviewed By: stellaraccident

Differential Revision: https://reviews.llvm.org/D90191
2020-10-27 07:12:32 +01:00
Kirsten Lee f98bb414f5 Add a mlir natvis file for debugging with Visual Studio
Differential Revision: https://reviews.llvm.org/D89601
2020-10-23 14:15:01 -07:00
Christian Sigg e9b3884161 Add GDB prettyprinters for a few more MLIR types.
Reviewed By: dblaikie, jpienaar

Differential Revision: https://reviews.llvm.org/D87159
2020-09-30 21:22:47 +02:00
OCHyams 485e6db872 Revert "Adding GDB PrettyPrinter for mlir::Identifier."
This reverts commit 9e9e6e698d.

This commit is causing builds that include the 'debuginfo-tests' project to
fail.

Apple has a public bot which shows the failure:
http://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/23667/console
2020-09-03 08:28:15 +01:00
Christian Sigg 9e9e6e698d Adding GDB PrettyPrinter for mlir::Identifier.
This is the first bit from D73546. Primarily setting up the corresponding test. Will add more pretty printers in a separate revision.

Reviewed By: dblaikie

Differential Revision: https://reviews.llvm.org/D86937
2020-09-03 08:18:09 +02:00
Uday Bondhugula b8cc449b84 [MLIR][NFC] Update MLIR vim syntax file - std ops + types
Update vim syntax file to include more std ops, and for int types.

Differential Revision: https://reviews.llvm.org/D86370
2020-08-22 11:20:57 +05:30
River Riddle 9db53a1827 [mlir][NFC] Remove usernames and google bug numbers from TODO comments.
These were largely leftover from when MLIR was a google project, and don't really follow LLVM guidelines.
2020-07-07 01:40:52 -07:00
ergawy 4837562de4 [MLIR][SPIRV] Extend automation script to generate coverage report.
This patch adds a new cli argument to the automation script to generate
a report of the current SPIRV spec instruction coverage. It dumps to the
standard output a YAML string with the coverage information.

Differential Revision: https://reviews.llvm.org/D82006
2020-06-23 11:42:59 -04:00
Tim Shen b877f33d93 [MLIR] Add documentation for generate-check-lines.py 2020-06-16 11:39:02 -07:00
Tim Shen a6150de447 [MLIR] Remove generated spaces at eof for generate-test-checks.py. 2020-06-16 11:28:36 -07:00
Tim Shen 25b3806788 [MLIR] Rework generate-test-checks.py to attach CHECK lines to the source (test) file.
Summary:
This patch adds --source flag to indicate the source file. Then it tries to find insert
points in the source file and insert corresponding checks at those places.

Example output from Tensorflow XLA:

// -----

// CHECK-LABEL:   func @main.3(
// CHECK-SAME:                 %[[VAL_0:.*]]: memref<2x2xf32> {xla_lhlo.params = 0 : index},
// CHECK-SAME:                 %[[VAL_1:.*]]: memref<16xi8> {xla_lhlo.alloc = 0 : index, xla_lhlo.liveout = true}) {
// CHECK:           %[[VAL_2:.*]] = constant 0 : index
// CHECK:           %[[VAL_3:.*]] = constant 0 : index
// CHECK:           %[[VAL_4:.*]] = std.view %[[VAL_1]]{{\[}}%[[VAL_3]]][] : memref<16xi8> to memref<2x2xf32>
// CHECK:           "xla_lhlo.tanh"(%[[VAL_0]], %[[VAL_4]]) : (memref<2x2xf32>, memref<2x2xf32>) -> ()
// CHECK:           return
// CHECK:         }
func @main(%value0: tensor<2x2xf32>) -> tensor<2x2xf32> {
  %res = "xla_hlo.tanh"(%value0) : (tensor<2x2xf32>) -> tensor<2x2xf32>
  return %res : tensor<2x2xf32>
}

Differential Revision: https://reviews.llvm.org/D81903
2020-06-16 11:15:46 -07:00
Uday Bondhugula 136d78ca6b [MLIR][NFC] Update vim syntax file
Add a few more commonly used ops and missing keywords.
2020-06-14 18:03:26 +05:30
Wen-Heng (Jack) Chung 7bfcb9120f Use python3 in generate-test-checks.py.
Summary: Upgrade to python3 in generate-test-checks.py .

Subscribers: mehdi_amini, rriddle, jpienaar, shauheen, antiagainst, nicolasvasilache, arpith-jacob, mgester, lucyrfox, liufengdb, stephenneuendorffer, Joonsoo, grosul1, frgossen, Kayjukh, jurahul, msifontes

Tags: #mlir

Differential Revision: https://reviews.llvm.org/D81701
2020-06-11 19:19:22 -05:00
Sean Silva 0aa97ad5c8 [mlir] Change generate-test-checks.py to `%[[V:.*]]` style
Summary:
This style seems to be the preferred style lately as it plays better
with op syntaxes that include `[` and `]`.

Input:
```
module {
  func @f(%arg0 : i32) -> i32 {
    %0 = addi %arg0, %arg0 : i32
    %1 = muli %arg0, %0 : i32
    return %1 : i32
  }
}
```

New output:

```
// NOTE: Assertions have been autogenerated by utils/generate-test-checks.py
// CHECK:       module {

// CHECK-LABEL:   func @f(
// CHECK-SAME:            %[[VAL_0:.*]] : i32) -> i32 {
// CHECK:           %[[VAL_1:.*]] = addi %[[VAL_0]], %[[VAL_0]] : i32
// CHECK:           %[[VAL_2:.*]] = muli %[[VAL_0]], %[[VAL_1]] : i32
// CHECK:           return %[[VAL_2]] : i32
// CHECK:         }
// CHECK:       }
```

Old output:
```
// NOTE: Assertions have been autogenerated by utils/generate-test-checks.py
// CHECK:       module {

// CHECK-LABEL:   func @f(
// CHECK-SAME:            [[VAL_0:%.*]] : i32) -> i32 {
// CHECK:           [[VAL_1:%.*]] = addi [[VAL_0]], [[VAL_0]] : i32
// CHECK:           [[VAL_2:%.*]] = muli [[VAL_0]], [[VAL_1]] : i32
// CHECK:           return [[VAL_2]] : i32
// CHECK:         }
// CHECK:       }
```

Differential Revision: https://reviews.llvm.org/D79836
2020-05-13 14:50:14 -07:00
Lei Zhang a9cb529a84 [mlir][spirv] NFC: use Optional to replace SPV_Optional
Differential Revision: https://reviews.llvm.org/D78046
2020-04-13 15:44:06 -04:00
Kazuaki Ishizaki 5aacce3db2 [mlir] NFC: Fix trivial typo
Differential Revision: https://reviews.llvm.org/D77473
2020-04-05 11:30:30 +09:00
Lei Zhang d26435c170 [mlir][spirv] Change op doc description autogen separator
This commit changes the separator line for dividing auto-generated
docs from spec and manually added appendix from "### Custom assembly
form" to "<!-- End of AutoGen section -->". This is in preparation
to use the declarative assembly form in MLIR core. We will replace
more and more manually written assembly forms to be autogenerated.

Differential Revision: https://reviews.llvm.org/D77158
2020-03-31 15:28:06 -04:00
Lei Zhang 267483ac70 [mlir][spirv] Support implied extensions and capabilities
In SPIR-V, when a new version is introduced, it is possible some
existing extensions will be incorporated into it so that it becomes
implicitly declared if targeting the new version. This affects
conversion target specification because we need to take this into
account when allowing what extensions to use.

For a capability, it may also implies some other capabilities,
for example, the `Shader` capability implies `Matrix` the capability.
This should also be taken into consideration when preparing the
conversion target: when we specify an capability is allowed, all
its recursively implied capabilities are also allowed.

This commit adds utility functions to query implied extensions for
a given version and implied capabilities for a given capability
and updated SPIRVConversionTarget to use them.

This commit also fixes a bug in availability spec. When a symbol
(op or enum case) can be enabled by an extension, we should drop
it's minimal version requirement. Being enabled by an extension
naturally means the symbol can be used by *any* SPIR-V version
as long as the extension is supported. The grammar still encodes
the 'version' field for such cases, but it should be interpreted
as a different way: rather than meaning a minimal version
requirement, it says the symbol becomes core at that specific
version.

Differential Revision: https://reviews.llvm.org/D72765
2020-01-17 08:01:57 -05:00
Lei Zhang ccedb918bb [mlir][spirv] Use symbolize functions in enum attribute predicates
By default, for an enum attribute, we will generate a list of equality
comparisons for all supported cases inside it's predicate. This list
can be fairly large for certain SPIR-V enum attributes. Instead, we
already have such a list generated by EnumsGen in the symbolize
functions. Leverage that to simplify the generated C++ code.

Differential Revision: https://reviews.llvm.org/D72763
2020-01-16 21:32:01 -05:00
Lei Zhang 6a97013590 [mlir][spirv] Add implied capabilities and availability for capabilities
Certain SPIR-V capabilities are only available in certain SPIR-V versions
or extensions. Also a SPIR-V capability may implicitly declares other
capabilities.

This commit updates gen_spirv_dialect.py to support generating such
information into SPIRVBase.td. It requires us to topologically sort
all capabilities because now a capability can refer to another one.

This commits also registers a few extensions because their symbols are
used by capability availability.

Note that this commit hasn't updated SPIRVConversionTarget to take
into consideration such relationship yet. That will be done in a
following-up commit.

Differential Revision: https://reviews.llvm.org/D72760
2020-01-16 21:32:01 -05:00
Kazuaki Ishizaki 73f371c31d [mlir] NFC: Fix trivial typos
Summary: Fix trivial typos

Differential Revision: https://reviews.llvm.org/D72672
2020-01-16 23:58:58 +01:00
Lei Zhang 98856b22cd [mlir][spirv] Update SPIR-V enums and ops with availability spec
This commit updates gen_spirv_dialect.py to query the grammar and
generate availability spec for various enum attribute definitions
and all defined ops.

Reviewed By: mravishankar

Differential Revision: https://reviews.llvm.org/D72095
2020-01-02 14:09:02 -05:00
chelxom d2a8e14177 Fix the MLIR Vim syntax file: the keyword group was missing 2019-12-26 04:50:38 +00:00
Lei Zhang a5d5d29125 Update SPIR-V.md
This CL updates SPIR-V.md to reflect recent developments
in the SPIR-V dialect and its conversions.

Along the way, also updates the doc for define_inst.sh.

PiperOrigin-RevId: 286933546
2019-12-23 16:15:52 -08:00
Mehdi Amini 56222a0694 Adjust License.txt file to use the LLVM license
PiperOrigin-RevId: 286906740
2019-12-23 15:33:37 -08:00
Uday Bondhugula 47034c4bc5 Introduce prefetch op: affine -> std -> llvm intrinsic
Introduce affine.prefetch: op to prefetch using a multi-dimensional
subscript on a memref; similar to affine.load but has no effect on
semantics, but only on performance.

Provide lowering through std.prefetch, llvm.prefetch and map to llvm's
prefetch instrinsic. All attributes reflected through the lowering -
locality hint, rw, and instr/data cache.

  affine.prefetch %0[%i, %j + 5], false, 3, true : memref<400x400xi32>

Signed-off-by: Uday Bondhugula <uday@polymagelabs.com>

Closes 

COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/225 from bondhugula:prefetch 4c3b4e93bc64d9a5719504e6d6e1657818a2ead0
PiperOrigin-RevId: 286212997
2019-12-18 10:00:04 -08:00
Mahesh Ravishankar 80ec474a65 Add atomic operations to SPIR-V dialect.
Some changes to the dialect generation script to allow specification
of different base class to derive from in ODS.

PiperOrigin-RevId: 285859230
2019-12-16 15:05:51 -08:00
Alex Zinenko ac4873322f Drop Markdown style annotations
These come from a non-standard extenion that is not available on Github, so it
only clutters the documentation source with {.mlir} or {.ebnf} tags.

PiperOrigin-RevId: 284733003
2019-12-10 03:00:57 -08:00