836 Commits

Author SHA1 Message Date
Haojian Wu
1651bc60ad Update the bazel's llvm-config.h.cmake file
Reflect the change 7d2c1150d31bb3692c81f6ecb0dbe61170e31212, fix the bazel test
breakage.
2022-12-17 18:17:30 +01:00
Hanhan Wang
83396d8549 [mlir][tensor] Implement TilingInterface for unpack op
The main issue of tiling unpack op is about incomplete tile. Since all
the dimensions are orthogonal, discussing 1-d unpack case is enough. The
core idea is to make the input slice have complete tiles. In this case,
a larger unpacked tile will be created. We'll need an extract_slice op
to shift and truncate the output.

Take Nn_to_N as an example. Say that N=32, n=8, and tiling_size=15. The
coordinates of second tile (i.e., result[15..31]) are [(1, 7), (2, 0,),
(2, 1) ... (3, 6), (3, 7)]. The first row and the last row are
incomplete in terms of inputs. It's impossible to represent an unpack op
using the coordinates. Because the input has higher rank and the math
computation of coordinate is using mod and ceilDiv. That's very tricky.

To represent the unpack op, we have to complete the rows. I.e., the
input coordinates would start with (1, 0); end with (3, 7). In this
context, the tiled unpack produces a (3 * n) elements because there are
3 rows in total. Follow by a tensor.extract_slice op, we can get the
actual result.

If the tiling sizes are multiple of inner tile sizes, it is a perfect
tiling case. In this context, the larger input and output is not needed.

Reviewed By: chelini

Differential Revision: https://reviews.llvm.org/D139362
2022-12-16 13:06:52 -08:00
Jordan Rupprecht
58c38e4536 [NFC][bazel] Update comment in llvm-config.h.cmake so headers match 2022-12-15 17:41:48 -08:00
Kazu Hirata
ee0c631716 [mlgo] Retire LLVM_HAVE_TF_API
I've eliminated all uses of LLVM_HAVE_TF_API except a couple of them
being removed in llvm/lib/CodeGen/CMakeLists.txt.  This patch removes
remaining definitions and uses of LLVM_HAVE_TF_API.

Differential Revision: https://reviews.llvm.org/D140169
2022-12-15 14:40:16 -08:00
Alex Brachet
d07c54c2a5 [libc] Templatize ato* tests
This catches missing corner cases from atol tests.

Differential Revision: https://reviews.llvm.org/D140076
2022-12-15 17:30:00 +00:00
Matthias Springer
325b58d59f [mlir][cf] Print message in cf.assert to LLVM lowering
The assert message was previously ignored. The lowered IR now calls `puts` it in case of a failed assertion.

Differential Revision: https://reviews.llvm.org/D138647
2022-12-15 17:45:34 +01:00
Quentin Colombet
2d0ca6b68c [mlir][test] Add expand-strided-metadata to lower-to-llvm
This patch adds the `ExpandStridedMetadataPass` to the LowerToLLVM named
pipeline.
This is required now that "complex" memref operations, like subviews,
need to be expanded before being lowered.

Differential Revision: https://reviews.llvm.org/D139841
2022-12-15 09:07:21 +00:00
Peiming Liu
71cc0f1c04 [mlir][sparse] introduce sparse_tensor::StorageSpecifierType and related operations on it
Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D139961
2022-12-14 22:27:22 +00:00
Oleg Shyshkov
07335f9460 [mlir] Fix bazel build for https://reviews.llvm.org/D139187. 2022-12-14 17:05:48 +01:00
Krasimir Georgiev
afcf8fa5ad [bazel] add some more deps to libc BUILD files 2022-12-14 10:27:45 +00:00
Krasimir Georgiev
5c8bf9de93 [bazel] Add __support_common dep 2022-12-14 10:16:17 +00:00
Jordan Rupprecht
9144ee6edf [bazel] Add __support_compiler_features dep in more places 2022-12-13 12:20:21 -08:00
Jordan Rupprecht
caee219320 [bazel] Add extract_api after 7a85192166b551929d413e8a38549375503371db 2022-12-13 10:57:37 -08:00
Guillaume Chatelet
6ce5e53cc7 [libc][bazel] Add missing dependency in string_memory_utils 2022-12-13 16:05:47 +00:00
Guillaume Chatelet
f52ca0926c [libc] Add compiler, builtin and feature detection
This is a first step to support GCC. This patch adds support for builtin and feature detection.

Differential Revision: https://reviews.llvm.org/D139712
2022-12-13 13:01:11 +00:00
Diego Caballero
72fd36448d [mlir][Vector] Initial masking support in Linalg vectorizer
This patch introduces the initial bits to support vector masking
using the `vector.mask` operation. Vectorization changes should be
NFC for non-masked cases. We can't test masked cases directly until
we extend the Transform dialect to support masking.

Reviewed By: nicolasvasilache

Differential Revision: https://reviews.llvm.org/D137690
2022-12-13 01:33:06 +00:00
Jordan Rupprecht
a98bdaa9c9 [NFC][bazel] Run buildifier on all bzl/BUILD.bazel files 2022-12-12 16:30:51 -08:00
Siva Chandra Reddy
ce932556af [libc][bazel] Mark all libc public functions to have "default" visibility.
For the bazel build, we also build all source files with
-fvisibility=hidden.

Reviewed By: gchatelet

Differential Revision: https://reviews.llvm.org/D139678
2022-12-12 17:22:35 +00:00
Michael Jones
74da5e6c08 [libc] add result class to strtointeger
This is a class intended to improve errno handling for internal
functions by allowing functions to return their result and error status
instead of setting errno. This specific class will be used for
strtointeger and (in a followup patch) strtofloat.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D133163
2022-12-09 14:35:47 -08:00
NAKAMURA Takumi
93896029cf [Bazel] Set HAVE_DLADDR in config.h
Corresponding to CMake change in llvmorg-16-init-13673-g138d53895734
2022-12-09 11:41:14 +09:00
Haojian Wu
3661458b4c Update the bazel BUILD for dsymutil binary.
Reflect the change eeee51e4bb9998c70737a8b771fc1a7884cfedd1
2022-12-08 09:52:17 +01:00
Keith Smiley
a72883b761
[bazel] Add fenv_darwin_impl.h to target
Fixes https://github.com/llvm/llvm-project/issues/59378

Differential Revision: https://reviews.llvm.org/D139563
2022-12-07 15:43:47 -08:00
Hanhan Wang
0d03ba62c5 [mlir][tensor] Implement TilingInterface for tensor.pack op.
We can compute the offsets and sizes for the slice of input because the
iteration domain is defined over outer loops. If the dimension is tiled,
the i-th index is the product of offset_i and inner_tile_i.

Different from tiling a pad op, we do not have to deal with reading zero
data from input. Because the tiling sizes are indicated to packed outer
dimensions. We will read either the entire tile or partial tile for each
packed tile. The scf.if and tensor.generate ops are not needed in this
context.

Co-authored-by: Lorenzo Chelini <l.chelini@icloud.com>

Reviewed By: rengolin, mravishankar

Differential Revision: https://reviews.llvm.org/D138631
2022-12-05 14:00:10 -08:00
Benjamin Kramer
35b6faff86 [bazel] Add a missing dependency after 786cbb09ed 2022-12-02 16:56:05 +01:00
Matthias Springer
c1fef4e88a [mlir][bufferization] Make TensorCopyInsertionPass a test pass
TensorCopyInsertion should not have been exposed as a pass. This was a flaw in the original design. It is a preparation step for bufferization and certain transforms (that would otherwise be legal) are illegal between TensorCopyInsertion and actual rewrite to MemRef ops. Therefore, even if broken down as two separate steps internally, they should be exposed as a single pass.

This change affects the sparse compiler, which uses `TensorCopyInsertionPass`. A new `SparsificationAndBufferizationPass` is added to replace all passes in the sparse tensor pipeline from `TensorCopyInsertionPass` until the actual bufferization (rewrite to memref/non-tensor). It is generally unsafe to run arbitrary passes in-between, in particular passes that hoist tensor ops out of loops or change SSA use-def chains along tensor ops.

Differential Revision: https://reviews.llvm.org/D138915
2022-12-02 15:38:02 +01:00
Guillaume Chatelet
5bdada9c69 [libc] Make libc memory functions weak by default for bazel
This helps override llvm libc functions for experiment purposes.

Differential Revision: https://reviews.llvm.org/D138999
2022-12-02 08:41:57 +00:00
Guillaume Chatelet
436c8f4420 [reland][libc] Add bcopy
Differential Revision: https://reviews.llvm.org/D138994
2022-12-01 10:07:04 +00:00
Guillaume Chatelet
c5fe7eb216 Revert D138994 "[libc] Add bcopy"
Broke build bot

This reverts commit 186a15f7a9311a75f3c5e90243ea5d6d20878de1.
2022-12-01 09:55:36 +00:00
Guillaume Chatelet
186a15f7a9 [libc] Add bcopy
Differential Revision: https://reviews.llvm.org/D138994
2022-12-01 09:52:10 +00:00
Jakub Kuderski
9ad215bb3d [mlir][spirv] Drop experimental LinalgToSPIRV pass
This experimental pass is unused and obsolete.

Reviewed By: antiagainst

Differential Revision: https://reviews.llvm.org/D139056
2022-11-30 19:25:40 -05:00
Sterling Augustine
6db9c34f56 Fix bazel build for https://reviews.llvm.org/D138980 2022-11-30 10:17:20 -08:00
Hanhan Wang
9b16d9d271 [mlir][linalg] Add a new pattern to handle folding unit reduction dims.
The output operands will be added to input operands if the generic op (on tensors)
becomes an elementwise operation. The outputs of the generic op is still the same.
They will be cleaned up by ReplaceWithEmptyTensorIfUnused pattern.

This is https://reviews.llvm.org/D138251, plus a cmake dep fix.

Reviewed By: mravishankar

Differential Revision: https://reviews.llvm.org/D138843
2022-11-28 14:14:43 -08:00
Nicolas Vasilache
6e92d3fead [mlir][Test] Add a test pass to act as a sink towards LLVM conversion
This allows writing simple e2e tests where we can check for the proper materialization
of specific LLVM IR (e.g. `llvm.intr.fmuladd`).

Differential Revision: https://reviews.llvm.org/D138776
2022-11-28 00:59:55 -08:00
Nicolas Vasilache
6ff1233304 [mlir][Vector] Add a LowerVectorsOp to VectorTransformOps
This op significantly improves transfor dialect usage when using vector abstractions.
It also brings us closer to writing simple end-to-end unit tests that guard against subtle regressions in how patterns combine.

Differential Revision: https://reviews.llvm.org/D138723
2022-11-25 08:27:36 -08:00
Nicolas Vasilache
c4ce8a40fa [mlir][Vector] Vector transform skeleton
Differential Revision: https://reviews.llvm.org/D134722
2022-11-25 04:51:50 -08:00
Benjamin Kramer
9e1650951b [bazel] Add copts attribute to gentbl_cc_library macro. 2022-11-24 20:16:24 +01:00
Hanhan Wang
a827c5c7ab Revert "[mlir][linalg] Add a new pattern to handle folding unit reduction dims."
This reverts commit 6eee66d12ab33f35a37a1514342b51ae93d175e8.

It breaks builds, see https://lab.llvm.org/buildbot/#/builders/61/builds/35742

Differential Revision: https://reviews.llvm.org/D138633
2022-11-23 19:07:01 -08:00
Hanhan Wang
6eee66d12a [mlir][linalg] Add a new pattern to handle folding unit reduction dims.
The output operands will be added to input operands if the generic op (on tensors)
becomes an elementwise operation. The outputs of the generic op is still the same.
They will be cleaned up by ReplaceWithEmptyTensorIfUnused pattern.

Reviewed By: mravishankar

Differential Revision: https://reviews.llvm.org/D138251
2022-11-23 10:47:10 -08:00
Benjamin Kramer
021e2ad247 [bazel] Add missing dependencies after 7a69a9d7ae 2022-11-23 10:45:15 +01:00
Benjamin Kramer
65644125be [bazel] Add missing dependency after 9aa505a28d 2022-11-22 10:46:52 +01:00
Aart Bik
99b3849d89 [mlir][sparse] introduce vectorization pass for sparse loops
This brings back previous SIMD functionality, but in a separate pass.
The idea is to improve this new pass incrementally, going beyond for-loops
to while-loops for co-iteration as welll (masking), while introducing new
abstractions to make the lowering more progressive. The separation of
sparsification and vectorization is a very good first step on this journey.

Also brings back ArmSVE support

Still to be fine-tuned:
  + use of "index" in SIMD loop (viz. a[i] = i)
  + check that all ops really have SIMD support
  + check all forms of reductions
  + chain reduction SIMD values

Reviewed By: dcaballe

Differential Revision: https://reviews.llvm.org/D138236
2022-11-21 16:12:12 -08:00
Benjamin Kramer
7f9e89962b [bazel] Port d6abdf46bc 2022-11-21 18:18:25 +01:00
Guillaume Chatelet
e7fb6c394f [libc][test][NFC] bump mpfr version to 4.1.1 2022-11-21 09:38:42 +00:00
Alex Zinenko
13b8362f02 [mlir] bazel for D137997 2022-11-21 10:21:02 +01:00
Tue Ly
e205fc1836 [libc] Add sub_with_borrow to builtin_wrapper.h
Add sub_with_borrow to builtin_wrapper.h to be used in UInt.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D138182
2022-11-19 16:12:26 -05:00
Guillaume Chatelet
d856e5feac [reland][libc][bazel] Add tests to the bazel build
This patch adds bazel tests for llvm-libc.

Some math tests rely on the `mpfr` library. This is controlled via the `--@llvm-project//libc:libc_math_mpfr` flag. It can take three values:
 - `external` (default) will build `mpfr` and `gmp` from source.
 - `system` will use the system installed `mpfr` library.
 - `disable` will skip tests relying on `mpfr`.

Reviewed By: sivachandra, GMNGeoffrey

Differential Revision: https://reviews.llvm.org/D119547
2022-11-18 13:20:52 +00:00
Adrian Kuegel
9e088effae [mlir][Bazel] Add DebugImporter sources to build target. 2022-11-18 10:19:30 +01:00
Alexander Shaposhnikov
f102fe7304 Revert "Revert "[opt][clang] Enable using -module-summary/-flto=thin with -S/-emit-llvm""
This reverts commit 7f608a2497c7578b9f3ca98014176ab95cffe3c0
and removes the dependency of Object on IRPrinter.
2022-11-18 08:58:31 +00:00
Adrian Kuegel
52301a188f [llvm][Bazel] Remove dependency to avoid cycyle.
Differential Revision: https://reviews.llvm.org/D138266
2022-11-18 08:47:35 +01:00
Alexander Shaposhnikov
34ab474348 [opt][clang] Enable using -module-summary/-flto=thin with -S/-emit-llvm
Enable using -module-summary with -S
(similarly to what currently can be achieved with opt <input> -o - | llvm-dis).
This is a recommit of ef9e62469.

Test plan: ninja check-all

Differential revision: https://reviews.llvm.org/D137768
2022-11-18 05:04:07 +00:00