Commit Graph

672 Commits

Author SHA1 Message Date
bixia1 4329ca61e8 [mlir][sparse] Add sparse_tensor.sort operator.
Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D134482
2022-09-27 12:00:08 -07:00
Lorenzo Chelini 4db3a649ea [MLIR] Expose `getAsValues` in `StaticValueUtils.h` (NFC) [reland]
The utility function should live in `StaticValueUtils.h` as it provides
a convenient way to convert a vector of OpFoldResults into a vector of
Values.

Reviewed By: nicolasvasilache, cota

Differential Revision: https://reviews.llvm.org/D134451
2022-09-27 11:18:25 -04:00
Christian Sigg 7876469c77 [Bazel] Remove template_rule and use @bazel_skylib's expand_template instead.
Reviewed By: GMNGeoffrey

Differential Revision: https://reviews.llvm.org/D134347
2022-09-26 15:29:59 +02:00
Guillaume Chatelet aec908f9b2 [libc][NFC] Move bzero_inline to separate file
This allows for easier discovery.
2022-09-26 12:57:51 +00:00
Oleg Shyshkov 4f1c124251 [mlir] Add IteratorType enum to StructuredOpsUtils.
Summary:
Use the new enum in TilingIterface and verify that `iterator_type` attribute in
LinalgOp interface is compatible with the enum values. Later IteratorType enum
will be used in LinalgInterface to replace the current `iterator_type` attribute
array of string.

Existing enums in Linalg are moved into a separate td file and tablegen build
target. This is necessary, have one I32EnumAttr in a shared space that generated
enum class definition and EnumAttrs is dialect-specific location. Otherwise
there might be a conflict that I32EnumAttr generates enum definitions in
multiple places.

Differential Revision: https://reviews.llvm.org/D134634
2022-09-26 11:09:46 +00:00
Adrian Kuegel 585010b4b0 Revert "[mlir][Bazel] Port 730ae80d3e1c47f93f725acb2d37f06fcba06953"
This reverts commit ec8f08ce08.

The change that needed this BUILD fix was reverted.
2022-09-26 10:09:02 +02:00
Adrian Kuegel a096164134 Revert "[mlir][Bazel] Port 730ae80d3e part 2."
This reverts commit b4cc363e86.

The change which needed this BUILD fix was reverted.
2022-09-26 10:04:56 +02:00
Adrian Kuegel b4cc363e86 [mlir][Bazel] Port 730ae80d3e part 2. 2022-09-26 09:51:22 +02:00
Adrian Kuegel ec8f08ce08 [mlir][Bazel] Port 730ae80d3e 2022-09-26 09:45:24 +02:00
Adrian Kuegel a3df255e9c [mlir][Bazel] Port afb0b21f24 2022-09-26 09:38:22 +02:00
Arthur Eubanks 7a8b9307ca [bazel] Always specify --strip=never 2022-09-25 18:49:49 -07:00
Arthur Eubanks 2698be0cc9 [bazel] Add some general build flags 2022-09-25 18:22:22 -07:00
Lei Zhang 465ec4e0b4 [mlir] NFC: move mergeOffsetsSizesAndStrides into Affine/Utils
So that these utility functions can also be used ViewLikeInterface
ops not in the memref dialect.

Reviewed By: mravishankar, christopherbate

Differential Revision: https://reviews.llvm.org/D134487
2022-09-23 13:28:11 -04:00
Arthur Eubanks 0de7c15c88 [bazel] Be consistent and say we don't support libfpm everywhere
We're inconsistent about saying whether or not we support libfpm in the bazel build.

This should perhaps be configurable via a --config.

This allows the buildbots to see when llvm-exegesis-related breakages occur.

Differential Revision: https://reviews.llvm.org/D134510
2022-09-23 09:27:55 -07:00
Jordan Rupprecht 892260d7f3 [bazel] Respect llvm_target_list in llvm-exegesis
- 47afaf2eb0 changed llvm-exegesis cmake rules
- 5b2f838db4 ported them to bazel, but did so by adding all the `lib/{target}/*.cpp` sources in exegesis to the build rule
- c7bf9d084d removed it, because it breaks users who don't build Mips and fail when building `lib/Mips/*.cpp`. But that in turn breaks those who *do* build the Mips target.

This should hopefully fix it for the final time by using selectively build subdirectories of exegesis target libs using llvm_target_exegesis, which is derived from llvm_targets, and is the list that can vary based on the downstream user.

I verified this builds with and without `Mips` in the `DEFAULT_TARGETS` configure list, and also double checked with `bazel query --output=build @llvm-project//llvm:Exegesis` that `lib/Mips/Target.cpp` is being included if and only if `Mips` is in the target list.

Reviewed By: aeubanks

Differential Revision: https://reviews.llvm.org/D134512
2022-09-22 19:20:04 -07:00
Arthur Eubanks c068ea230b [bazel] Remove "nobuildkite" flag for targets depending on libxml2
The buildbots do have libxml2 installed.
2022-09-22 18:30:44 -07:00
Caroline Tice c7bf9d084d [bazel] Remove Mips from Exegesis cc_library definition
Recent update added 'tools/llvm-exegesis/lib/Mips/*.cpp' to srcs for Exegesis cc_library. This was not needed, and in fact breaks things. This CL removes that one change.

Reviewed By: aeubanks

Differential Revision: https://reviews.llvm.org/D134505
2022-09-22 17:39:53 -07:00
Jordan Rupprecht 5b2f838db4 [bazel] Port 47afaf2eb0 to bazel 2022-09-22 15:00:15 -07:00
Adrian Kuegel 539fa1df46 [mlir][Bazel] Port f5fe92f693 2022-09-21 07:51:36 +02:00
Frederik Gossen 6e50d66419 [MLIR] Update bazel build files after 242d558658
Differential Revision: https://reviews.llvm.org/D134301
2022-09-20 15:20:22 -04:00
Peiming Liu 52887071ea [mlir][scf] Support simple symbolic expression without depending on AffineDialect to simply trivial loops.
Remove dependence of AffineDialect

Reviewed By: mehdi_amini

Differential Revision: https://reviews.llvm.org/D134291
2022-09-20 18:13:05 +00:00
Peiming Liu d518fc28b6 [mlir][scf] Support simple symbolic expression when simplify loops
Reviewed By: aartbik, ThomasRaoux

Differential Revision: https://reviews.llvm.org/D134204
2022-09-19 21:50:01 +00:00
Dmitri Gribenko 7b7559aa43 [bazel] Port ba8424a251 2022-09-19 21:21:08 +02:00
Benjamin Kramer 9b2a3d20f2 [bazel] Port 233de4e808 2022-09-19 16:38:20 +02:00
Christian Sigg a6e91040ea [Bazel] Allow lit_test() macro to be used from other repos.
Wrap implicit dependencies in Label() so that they refer to @llvm-project, see https://bazel.build/rules/lib/Label#Label.

This change allows lit_test() to be used from other bazel repositories.
2022-09-17 11:06:07 +02:00
Groverkss 8c867f7827 [MLIR][Presburger] Improve unittest parsing
This patch adds better functions for parsing MultiAffineFunctions and
PWMAFunctions in Presburger unittests.

A PWMAFunction can now be parsed as:

```
PWMAFunction result = parsePWMAF({
    {"(x, y) : (x >= 10, x <= 20, y >= 1)", "(x, y) -> (x + y)"},
    {"(x, y) : (x >= 21)", "(x, y) -> (x + y)"},
    {"(x, y) : (x <= 9)", "(x, y) -> (x - y)"},
    {"(x, y) : (x >= 10, x <= 20, y <= 0)", "(x, y) -> (x - y)"},
});
```

which is much more readable than the old format since the output can be
described as an AffineMap, instead of coefficients.

This patch also adds support for parsing divisions in MultiAffineFunctions
and PWMAFunctions which was previously not possible.

Reviewed By: arjunp

Differential Revision: https://reviews.llvm.org/D133654
2022-09-15 19:28:49 +01:00
Haojian Wu 6c9d2ee490 Revert "Fix bazel build after 84d07d021333f7b5716f0444d5c09105557272e0."
This reverts commit 10250c5a2a as the
related patch is being reverted.
2022-09-15 20:02:27 +02:00
Haojian Wu 10250c5a2a Fix bazel build after 84d07d0213. 2022-09-15 13:52:46 +02:00
Christian Sigg 70ac466676 [Bazel] Add lit tests to bazel builds.
Add BUILD.bazel files for most of the MLIR tests and lit tests itself.

Reviewed By: mehdi_amini

Differential Revision: https://reviews.llvm.org/D133455
2022-09-15 07:49:37 +02:00
Christian Sigg d308113354 [Bazel] Bump bazel version to 5.0.
See https://discourse.llvm.org/t/use-bazelisk-for-bazel-buildbots/65188.

Reviewed By: mehdi_amini

Differential Revision: https://reviews.llvm.org/D133750
2022-09-13 20:09:13 +02:00
Haojian Wu 6a49c801a7 Fix Bazel build for llvm-lipo (61e5438498) 2022-09-13 10:26:43 +02:00
Fangrui Song 0845969a28 [Bazel] Port eb65327fe9 2022-09-09 15:35:52 -07:00
Benjamin Kramer f055d9c549 [bazel] Port 7fa1d743d0 2022-09-09 09:31:13 +02:00
Christopher Bate f4a478cd01 [mlir][Tensor] Add rewrites to extract slices through `tensor.collape_shape`
This change adds a set of utilities to replace the result of a
`tensor.collapse_shape -> tensor.extract_slice` chain with the
equivalent result formed by aggregating slices of the
`tensor.collapse_shape` source. In general, it is not possible to
commute `extract_slice` and `collapse_shape` if linearized dimensions
are sliced. The i-th dimension of the `tensor.collapse_shape`
result is a "linearized sliced dimension" if:

1) Reassociation indices of tensor.collapse_shape in the i'th position
   is greater than size 1 (multiple dimensions of the input are collapsed)
2) The i-th dimension is sliced by `tensor.extract_slice`.

We can work around this by stitching together the result of
`tensor.extract_slice` by iterating over any linearized sliced dimensions.
This is equivalent to "tiling" the linearized-and-sliced dimensions of
the `tensor.collapse_shape` operation in order to manifest the result
tile (the result of the `tensor.extract_slice`). The user of the
utilities must provide the mechanism to create the tiling (e.g. a loop).
In the tests, it is demonstrated how to apply the utilities using either
`scf.for` or `scf.foreach_thread`.

The below example illustrates the pattern using `scf.for`:

```
%0 = linalg.generic ... -> tensor<3x7x11x10xf32>
%1 = tensor.collapse_shape %0 [[0, 1, 2], [3]] : ... to tensor<341x10xf32>
%2 = tensor.extract_slice %1 [13, 0] [10, 10] [2, 1] : .... tensor<10x10xf32>
```

We can construct %2 by generating the following IR:

```
%dest = linalg.init_tensor() : tensor<10x10xf32>
%2 = scf.for %iv = %c0 to %c10 step %c1 iter_args(%arg0) -> tensor<10x10xf32> {
   // Step 1: Map this output idx (%iv) to a multi-index for the input (%3):
   %linear_index = affine.apply affine_map<(d0)[]->(d0*2 + 11)>(%iv)
   %3:3 = arith.delinearize_index %iv into (3, 7, 11)
   // Step 2: Extract the slice from the input
   %4 = tensor.extract_slice %0 [%3#0, %3#1, %3#2, 0] [1, 1, 1, 10] [1, 1, 1, 1] :
         tensor<3x7x11x10xf32> to tensor<1x1x1x10xf32>
   %5 = tensor.collapse_shape %4 [[0, 1, 2], [3]] :
         tensor<1x1x1x10xf32> into tensor<1x10xf32>
   // Step 3: Insert the slice into the destination
   %6 = tensor.insert_slice %5 into %arg0 [%iv, 0] [1, 10] [1, 1] :
         tensor<1x10xf32> into tensor<10x10xf32>
   scf.yield %6 : tensor<10x10xf32>
}
```

The pattern was discussed in the RFC here: https://discourse.llvm.org/t/rfc-tensor-extracting-slices-from-tensor-collapse-shape/64034

Reviewed By: nicolasvasilache

Differential Revision: https://reviews.llvm.org/D129699
2022-09-08 21:58:21 -06:00
rdzhabarov fba411aa47 Revert "Fix bazel deps.". Original change has been reverted.
This reverts commit b3999fd261.
2022-09-08 22:11:44 +00:00
rdzhabarov b3999fd261 Fix bazel deps. 2022-09-08 21:21:20 +00:00
Quentin Colombet e833fdcd05 [mlir] Add missing dependency in bazel build
The MemRefTransform library now depends on ArithmeticUtils because
of the newly added SimplifyExtractStridedMetadata pass.
2022-09-08 18:51:14 +00:00
Christian Sigg 250cde6ea9 [MLIR] NFC: add back exports_files(["run_lit.sh"]). 2022-09-08 07:46:10 +02:00
Christian Sigg 482aff4576 [MLIR] NFC: add back `exports_files(["LICENSE.txt"])`. 2022-09-07 22:14:12 +02:00
Christian Sigg c69c780aef [MLIR] NFC: expand comment in bazel BUILD file
... and remove unnecessry `exports_files()`.
2022-09-07 22:00:18 +02:00
Fangrui Song 98fe49c463 [Bazel] Make clang/unittests:lex_tests depend on //llvm:TestingSupport 2022-09-07 12:51:31 -07:00
Oleg Shyshkov fcab0a04c5 [mlir] Change CombiningKind in Vector dialect to EnumAttr.
CombiningKind was implemented before EnumAttr, so it reimplements the same behaviour with the custom code. Except for a few places, EnumAttr is a drop-in replacement.

Reviewed By: nicolasvasilache, pifon2a

Differential Revision: https://reviews.llvm.org/D133343
2022-09-07 13:40:45 +02:00
Benjamin Kramer a7c6cdc5cf [bazel] port 5dbc7cf7ca 2022-09-06 17:43:04 +02:00
Christian Sigg 0f2ec35691 [MLIR] Switch lit tests to %mlir_lib_dir and %mlir_src_dir replacements.
The old replacements will be removed soon:
- `%linalg_test_lib_dir`
- `%cuda_wrapper_library_dir`
- `%spirv_wrapper_library_dir`
- `%vulkan_wrapper_library_dir`
- `%mlir_runner_utils_dir`
- `%mlir_integration_test_dir`

Reviewed By: herhut

Differential Revision: https://reviews.llvm.org/D133270
2022-09-06 12:34:14 +02:00
Mehdi Amini 89418ddcb5 Plumb write_bytecode to the Python API
This adds a `write_bytecode` method to the Operation class.
The method takes a file handle and writes the binary blob to it.

Reviewed By: ftynse

Differential Revision: https://reviews.llvm.org/D133210
2022-09-05 12:02:06 +00:00
Christian Sigg 69778121e4 [bazel] NFC: Move licenses declaration from package to function.
The `licences` attribute is deprecated, see https://docs.bazel.build/versions/4.0.0/be/common-definitions.html#common-attributes.
2022-09-05 10:47:06 +02:00
Christian Sigg 725cdc451a [mlir:vscode] Fix bazel build after commit f7b8a70 2022-09-04 11:37:06 +02:00
Benjamin Kramer 278de327d9 [bazel] Port f7b8a70e7a 2022-09-03 09:55:37 +02:00
Mikhail Goncharov 5856576202 [bazel] fix libc build
For a4d48e3b0b
2022-09-02 18:33:28 +02:00
Matthias Springer f7f0c7f7e3 [mlir][bufferize] Add isRepetitiveRegion to BufferizableOpInterface
This method allows to declare regions as "repetitive" even if the parent op does not implement the RegionBranchOpInterface.

This is needed to support loop-like ops that have parallel semantics but do not branch between regions.

Differential Revision: https://reviews.llvm.org/D133113
2022-09-02 14:47:20 +02:00