Commit Graph

226 Commits

Author SHA1 Message Date
Denys Shabalin a8a2ee6331 [mlir] Introduce C API for PDL dialect types
This change introduces C API helper functions to work with PDL types.
Modification closely follow the format of the https://reviews.llvm.org/D116546.

Reviewed By: ftynse

Differential Revision: https://reviews.llvm.org/D117221
2022-01-13 15:29:01 +01:00
natashaknk 310e9636ca [tosa][mlir] Support dynamic batch dimension for ops where the batch dim is explicit
Dynamic batch for rescale, gather, max_pool, avg_pool, conv2D and depthwise_conv2D. Split helper functions into a separate header file.

Reviewed By: rsuderman

Differential Revision: https://reviews.llvm.org/D117031
2022-01-12 14:16:50 -08:00
Chia-hung Duan c025fd8b0b [mlir] Update BUILD rule for MathDialect.
1773dddadf adds the dependency to
ArithmeticDialect.

Reviewed By: rdzhabarov, ftynse

Differential Revision: https://reviews.llvm.org/D117127
2022-01-12 18:11:31 +00:00
Matthias Springer 6c654b5198 [mlir][linalg][bufferize] Support std.select bufferization
This op is an example for how to deal with ops who's OpResult may aliasing with one of multiple OpOperands.

Differential Revision: https://reviews.llvm.org/D116868
2022-01-12 17:46:44 +09:00
James Y Knight 228dfc0927 Fix bazel build after f77d115cc1. 2022-01-11 19:32:29 +00:00
James Y Knight 0a6f1c5f97 Fix bazel build after 8503c688d5. 2022-01-11 17:42:49 +00:00
Matthias Springer 15c7e3ee15 [mlir][linalg][bufferize][NFC] Use RewritePatterns instead of custom traversal
This change simplifies BufferizableOpInterface and other functions. Overall, the API will get smaller: Functions related to custom IR traversal are deleted entirely. This will makes it easier to write BufferizableOpInterface implementations.

This is also in preparation of unifying Comprehensive Bufferize and core bufferization. While Comprehensive Bufferize could theoretically maintain its own IR traversal, there is no reason to do so, because all bufferize implementations in BufferizableOpInterface have to support partial bufferization anyway. And we can share a larger part of the code base between the two bufferizations.

Differential Revision: https://reviews.llvm.org/D116448
2022-01-07 00:56:54 +09:00
Chuanqi Xu bbce75e352 Update Bug report URL to Github Issues
Although we moved to Github Issues. The bug report message refers to
Bugzilla still. This patch tries to update these URLs.

Reviewed By: MaskRay, Quuxplusone, jhenderson, libunwind, libc++

Differential Revision: https://reviews.llvm.org/D116351
2022-01-06 17:33:25 +08:00
Alex Zinenko 95ddbed9b7 [mlir] Split out Python bindings for dialects into separate libs
Historically, the bindings for the Linalg dialect were included into the
"core" bindings library because they depended on the C++ implementation
of the "core" bindings. The other dialects followed the pattern. Now
that this dependency is gone, split out each dialect into a separate
Python extension library.

Depends On D116649, D116605

Reviewed By: stellaraccident

Differential Revision: https://reviews.llvm.org/D116662
2022-01-06 10:31:14 +01:00
Alex Zinenko 66d4090d9b [mlir] Introduce Python bindings for the quantization dialect
So far, only the custom dialect types are exposed.

The build and packaging is same as for Linalg and SparseTensor, and in
need of refactoring that is beyond the scope of this patch.

Reviewed By: stellaraccident

Differential Revision: https://reviews.llvm.org/D116605
2022-01-05 16:26:31 +01:00
Alex Zinenko 9bcf13bf3e [mlir] Introduce C API for the Quantization dialect types
Reviewed By: nicolasvasilache

Differential Revision: https://reviews.llvm.org/D116546
2022-01-05 16:20:29 +01:00
wren romano 85b8d03e12 [mlir][sparse] Factoring out Transforms/CodegenUtils.{cpp,h}
This moves a bunch of helper functions from `Transforms/SparseTensorConversion.cpp` into `Transforms/CodegenUtils.{cpp,h}` so that they can be reused by `Transforms/Sparsification.cpp`, etc.

See also the dependent D115010 which cleans up some corner cases in this change.

Reviewed By: aartbik, rriddle

Differential Revision: https://reviews.llvm.org/D115008
2022-01-04 16:11:47 -08:00
Alexander Belyaev c8e988fa78 [mlir] Fix bazel build after b4130e9ead.
b4130e9ead
2022-01-04 07:59:51 +01:00
Mogball 4943cda398 [mlir][arith] fixing dependencies on memref/arith 2021-12-30 20:39:22 +00:00
Fangrui Song 95c25fd52a [Bazel] Make mlir:MemRefOpsTdFiles depend on :ArithmeticOpsTdFiles 2021-12-30 11:47:54 -08:00
Jakub Kuderski 5410152827 [Bazel] Add target for llvm-tli-checker
Reviewed By: vettoreldaniele, GMNGeoffrey

Differential Revision: https://reviews.llvm.org/D116222
2021-12-23 13:14:12 -05:00
Mogball 32e8b30d6e [mlir] Add unit test for disabling canonicalizer patterns (NFC) 2021-12-22 21:07:06 +00:00
Mogball 7347c28def [mlir] Add missing unit tests to BUILD.bazel
Several unit test folders were missing from the bazel build, including: Transforms, Conversion, Rewrite
2021-12-22 20:00:27 +00:00
Mogball ad761f0c39 [mlir] Update BUILD.bazel to include `scf_tests` 2021-12-22 19:46:37 +00:00
Mogball 07b073c1bb [mlir] Add `mlir/unittests/BUILD.bazel`
Unit tests are not getting built as part of bazel runs.

Reviewed By: mehdi_amini, GMNGeoffrey

Differential Revision: https://reviews.llvm.org/D116046
2021-12-20 21:41:31 +00:00
Fangrui Song 98e0b2cf70 [Support] Revert posix_fallocate in resize_file
This reverts 3816c53f04 and removes follow-up
fixups.

The original intention was to show error earlier (posix_fallocate time) than
later for ld.lld but it appears to cause some problems which make it not free.

* FreeBSD ZFS: EINVAL, not too bad.
* FreeBSD UFS: according to khng "devastatingly slow on freebsd because UFS on freebsd does not have preallocation support like illumos. It zero-fills."
* NetBSD: maybe EOPNOTSUPP
* Linux tmpfs: unless tmpfs is set up to use huge pages (requires CONFIG_TRANSPARENT_HUGE_PAGECACHE=y), I can consistently demonstrate ~300ms delay for a 1.4GiB output.
* Linux ext4: I don't measure any benefit, either backed by a hard disk or by a file in tmpfs.
* The current code organization of `defined(HAVE_POSIX_FALLOCATE)` costs us a macro dispatch for AIX.

I think we should just remove it. I think if posix_fallocate ever finds demonstrable benefit,
it is likely Linux specific and will not need HAVE_POSIX_FALLOCATE, and possibly opt-in by some specific programs.

In a filesystem with CoW and compression, the ENOSPC benefit may be lost as well.

Reviewed By: khng300

Differential Revision: https://reviews.llvm.org/D115957
2021-12-20 11:16:03 -08:00
bakhtiyar ec0e4545ca Make AsyncParallelForRewrite parameterizable with a cost model which drives deciding the parallelization granularity.
Reviewed By: ezhulenev, mehdi_amini

Differential Revision: https://reviews.llvm.org/D115423
2021-12-19 08:41:01 -08:00
Krasimir Georgiev eeed24e766 [Bazel] update build files for
65d7fd0239
2021-12-19 14:37:05 +01:00
Mogball 319d8cf685 [mlir][ods] Added EnumAttr, an AttrDef implementation of enum attributes
`EnumAttr` is a pure TableGen implementation of enum attributes using `AttrDef`. This is meant as a drop-in replacement for `StrEnumAttr`, which is soon to be deprecated. `StrEnumAttr` is often used over `IntEnumAttr` because its more readable in MLIR assembly formats. However, storing and manipulating strings is not efficient. Defining `StrEnumAttr` can also be awkward and relies on a lot of special logic in `EnumsGen`, and has some hidden sharp edges.

Also, `EnumAttr` stores the enum directly,  removing the need to convert to/from integers when calling attribute getters on ops.

Reviewed By: mehdi_amini

Differential Revision: https://reviews.llvm.org/D115181
2021-12-17 02:55:28 +00:00
Dmitri Gribenko fac18d7377 [Bazel] Add LLVM_BUILD_* variables to llvm-config.h to mirror ec37e0bbaf 2021-12-16 20:56:16 +01:00
Diego Caballero e0514fc200 [mlir] Fix Bazel build after 32fe1a8a25
Adding missing dependences.
2021-12-16 12:13:56 +00:00
Diego Caballero 32fe1a8a25 [mlir][GPU] Extend GPU kernel outlining to generate DL specification
This patch extends the GPU kernel outlining pass so that it can take in
an optional data layout specification that will be attached to the GPU
module operation generated. If the data layout specification is not provided
the default data layout is used instead.

Reviewed By: herhut, mehdi_amini

Differential Revision: https://reviews.llvm.org/D115722
2021-12-16 11:35:53 +00:00
River Riddle 11d26bd143 [mlir][PDLL] Add an initial frontend for PDLL
This is a new pattern rewrite frontend designed from the ground
up to support MLIR constructs, and to target PDL. This frontend
language was proposed in https://llvm.discourse.group/t/rfc-pdll-a-new-declarative-rewrite-frontend-for-mlir/4798

This commit starts sketching out the base structure of the
frontend, and is intended to be a minimal starting point for
building up the language. It essentially contains support for
defining a pattern, variables, and erasing an operation. The
features mentioned in the proposal RFC (including IDE support)
will be added incrementally in followup commits.

I intend to upstream the documentation for the language in a
followup when a bit more of the pieces have been landed.

Differential Revision: https://reviews.llvm.org/D115093
2021-12-16 02:08:12 +00:00
Richard Smith f2af453263 Update bazel build rules to match 169ebf03ab. 2021-12-15 17:47:32 -08:00
Guillaume Chatelet 0dc339c870 [libc][NFC][bazel] remove unneeded bzl_library 2021-12-15 17:50:32 +00:00
Guillaume Chatelet 354e5cf776
Embed licence into package 2021-12-15 15:17:24 +01:00
gysit b7f2c108eb [mlir][linalg] Replace LinalgOps.h and LinalgTypes.h by a single header.
After removing the range type, Linalg does not define any type. The revision thus consolidates the LinalgOps.h and LinalgTypes.h into a single Linalg.h header. Additionally, LinalgTypes.cpp is renamed to LinalgDialect.cpp to follow the convention adopted by other dialects such as the tensor dialect.

Depends On D115727

Reviewed By: nicolasvasilache

Differential Revision: https://reviews.llvm.org/D115728
2021-12-15 12:15:03 +00:00
Alex Zinenko 0e558faf6a [bazel] drop some unnecessary dependencies in mlir 2021-12-15 11:31:39 +01:00
Dmitri Gribenko a908ca6603 [bazel] Adjust Bazel BUILD files for a4830d14ed 2021-12-15 10:58:00 +01:00
Matthias Springer 1652871473 [mlir][linalg][bufferize] Reimplementation of TiledLoopOp bufferization
Instead of modifying the existing linalg.tiled_loop op, create a new op with memref input/outputs and delete the old op.

Differential Revision: https://reviews.llvm.org/D115493
2021-12-15 18:45:29 +09:00
Matthias Springer 7161aa06ef [mlir][linalg][bufferize] Reimplementation of scf.for bufferization
Instead of modifying the existing scf.for op, create a new op with memref OpOperands/OpResults and delete the old op.

New allocations / other memrefs can now be yielded from the loop. This functionality is deactivated by default and guarded against by AssertDestinationPassingStyle.

This change also introduces `replaceOp`, which will be utilized by all other `bufferize` implementations in future commits. Bufferization will then no longer rely on old (pre-bufferize) ops to DCE away. Instead old ops are deleted on the spot. This improves debuggability because there won't be any duplicate ops anymore (bufferized + not-yet-bufferized) when dumping IR during bufferization. It is also less fragile because unbufferized IR can no longer silently "hang around" due to an implementation bug.

Differential Revision: https://reviews.llvm.org/D114926
2021-12-15 18:29:22 +09:00
Fangrui Song 1042de9058 [Driver] Add CLANG_DEFAULT_PIE_ON_LINUX to emulate GCC --enable-default-pie
In 2015-05, GCC added the configure option `--enable-default-pie`. When enabled,

* in the absence of -fno-pic/-fpie/-fpic (and their upper-case variants), -fPIE is the default.
* in the absence of -no-pie/-pie/-shared/-static/-static-pie, -pie is the default.

This has been adopted by all(?) major distros.

I think default PIE is the majority in the Linux world, but
--disable-default-pie users is not that uncommon because GCC upstream hasn't
switched the default yet (https://gcc.gnu.org/PR103398).

This patch add CLANG_DEFAULT_PIE_ON_LINUX which allows distros to use default PIE.
The option is justified as its adoption can be very high among Linux distros
to make Clang default match GCC, and is likely a future-new-default, at which
point we will remove CLANG_DEFAULT_PIE_ON_LINUX.
The lit feature `default-pie-on-linux` can be handy to exclude default PIE sensitive tests.

Reviewed By: foutrelis, sylvestre.ledru, thesamesam

Differential Revision: https://reviews.llvm.org/D113372
2021-12-14 10:09:00 -08:00
Benjamin Kramer 12d42653b3 [bazel] Port debuginfod rules
Needed after 34491ca729
2021-12-14 13:14:30 +01:00
Guillaume Chatelet 8ed70d0189 [libc] Bazel overlay for libc
This patch provides a draft overlay to support compilation of llvm libc with Bazel.

Tested on linux x86-64 with
```
cd git/llvm-project/utils/bazel
bazelisk-linux-amd64 build --sandbox_base=/dev/shm --config=generic_clang @llvm-project//libc:all
```

Differential Revision: https://reviews.llvm.org/D114712
2021-12-13 19:14:22 +00:00
Chia-hung Duan 8cbd9c4c0e [mlir] Update BUILD rule for AffineUtils
bc657b2eef adds the dependency to
MemRefDialect.

Reviewed By: GMNGeoffrey, mehdi_amini

Differential Revision: https://reviews.llvm.org/D115558
2021-12-10 23:50:28 +00:00
Alexander Belyaev b618880e7b [mlir] Move `linalg.tensor_expand/collapse_shape` to TensorDialect.
RFC: https://llvm.discourse.group/t/rfc-reshape-ops-restructuring/3310

linalg.fill gets a canonicalizer, because `FoldFillWithTensorReshape` cannot be moved to tensorops (it uses linalg::FillOp inside). Before it was listed as a canonicalization pattern for the reshape operations, now it became a canonicalization for FillOp.

Differential Revision: https://reviews.llvm.org/D115502
2021-12-10 12:11:48 +01:00
Chia-hung Duan e9ab29b8fa [mlir] Add filegroup for Conversion/PassDetail
Reviewed By: mehdi_amini

Differential Revision: https://reviews.llvm.org/D115487
2021-12-10 02:04:00 +00:00
Mircea Trofin ce2a345265 [bazel] Exclude MLModelRunnerTest.cpp
Until we figure MLGO + bazel, exclude this unittest (same as
TFUtilsTest.cpp)

Differential Revision: https://reviews.llvm.org/D115472
2021-12-09 14:56:10 -08:00
Matthias Springer 8a232632c5 [mlir][linalg][bufferize] Add FuncOp bufferization pass
This passes bufferizes FuncOp bodies, but not FuncOp boundaries.

Differential Revision: https://reviews.llvm.org/D114671
2021-12-07 21:44:26 +09:00
David Blaikie 097a1cb1d5 Bazel: add new llvm-c/Deprecated.h header 2021-12-06 12:18:02 -08:00
Matthias Springer d30fcadf07 [mlir][linalg][bufferize] Op interface implementation for Bufferization dialect ops
This change provides `BufferizableOpInterface` implementations for ops from the Bufferization dialects. These ops are needed at the bufferization boundaries for partial bufferization.

Differential Revision: https://reviews.llvm.org/D114618
2021-12-03 16:25:44 +09:00
Geoffrey Martin-Noble dc5e1d06b9 [Bazel] Set the right default for LLVM_WINDOWS_PREFER_FORWARD_SLASH on Windows
This cmake configure option was added in
df0ba47c36, and was ported to
Bazel in 7d323dc773.

However, the setting chosen in Bazel seems accidental, not necessarily
intentional.

LLVM_WINDOWS_PREFER_FORWARD_SLASH has no effect on Unix, and on
Windows, setting it to 0 is the default, which gets the same behaviour
as before. Setting it to 1 enables new experimental behaviours
(which is enabled by default on MinGW targets only).

As I don't see any explicit intent to opt in to the new experimental
behaviour, I believe the current configuration in bazel was a
mistake.

Differential Revision: https://reviews.llvm.org/D114065
2021-12-02 17:44:54 -08:00
Reid Kleckner a8c7e56ac1 [bazel] Update static analyzer unit test deps for clangTesting 2021-12-02 16:27:56 -08:00
Reid Kleckner c6cfd385b1 [Bazel] Add LLVM_ENABLE_CURL to Bazel llvm-config.h.cmake for e0b259f2 2021-12-02 16:15:48 -08:00
Keith Smiley be4e789d21 [Bazel] Remove old macho lld port
This code and cmake was removed in https://reviews.llvm.org/D114842

Differential Revision: https://reviews.llvm.org/D114976
2021-12-02 11:44:48 -08:00