Commit Graph

982 Commits

Author SHA1 Message Date
A. Unique TensorFlower cc1b22e618 [HLO][Linalg] Support scalar broadcasts in point-wise converter
This is needed for operations that support this limited form of broadcasting,
namely `mhlo.select`.

PiperOrigin-RevId: 376655844
2021-05-31 03:50:23 -07:00
A. Unique TensorFlower 832f39b871 Integrate LLVM at llvm/llvm-project@577fea4e1a
Updates LLVM usage to match
[577fea4e1a13](https://github.com/llvm/llvm-project/commit/577fea4e1a13)

PiperOrigin-RevId: 376640971
2021-05-31 01:54:46 -07:00
A. Unique TensorFlower 8110683c0b Integrate LLVM at llvm/llvm-project@9968896cd6
Updates LLVM usage to match
[9968896cd62a](https://github.com/llvm/llvm-project/commit/9968896cd62a)

PiperOrigin-RevId: 376382711
2021-05-28 12:09:55 -07:00
A. Unique TensorFlower e422ce5a9a Integrate LLVM at llvm/llvm-project@8086f9d87e
Updates LLVM usage to match
[8086f9d87ee8](https://github.com/llvm/llvm-project/commit/8086f9d87ee8)

PiperOrigin-RevId: 376289371
2021-05-27 18:20:22 -07:00
Hanhan Wang 402b74ed7f Fix type bug in mhlo.dynamic-update-slice lowering.
The operand type can be f32. We should not use operand type to do clamp
operations.

PiperOrigin-RevId: 376286524
2021-05-27 17:53:49 -07:00
A. Unique TensorFlower b5f444232f Integrate LLVM at llvm/llvm-project@d47dd11071
Updates LLVM usage to match
[d47dd1107132](https://github.com/llvm/llvm-project/commit/d47dd1107132)

PiperOrigin-RevId: 376269354
2021-05-27 16:06:54 -07:00
Benjamin Kramer 6ea8f1ddf8 Integrate LLVM at llvm/llvm-project@eba69b59d1
Updates LLVM usage to match
[eba69b59d1a3](https://github.com/llvm/llvm-project/commit/eba69b59d1a3)

PiperOrigin-RevId: 376175310
2021-05-27 08:37:41 -07:00
Benjamin Kramer e319f87857 Integrate LLVM at llvm/llvm-project@c467585682
Updates LLVM usage to match
[c467585682dc](https://github.com/llvm/llvm-project/commit/c467585682dc)

PiperOrigin-RevId: 376155243
2021-05-27 06:25:17 -07:00
Benjamin Kramer 5deed55dc3 Integrate LLVM at llvm/llvm-project@d82f2a123f
Updates LLVM usage to match
[d82f2a123f9c](https://github.com/llvm/llvm-project/commit/d82f2a123f9c)

PiperOrigin-RevId: 376140722
2021-05-27 04:25:36 -07:00
A. Unique TensorFlower b32f885ad7 [MLIR][KernelGen] Enable cluster rank specialization
Replace the previously used `TransformUnrankedHloPass` which rank-specializes
only one operation at a time. The new generalized rank specialization clusters
compatible operations and rank-specializes them collectively.

PiperOrigin-RevId: 376127752
2021-05-27 02:44:31 -07:00
Adrian Kuegel a4fa6afa07 [mlir][hlo] Avoid dyn_cast_or_null when called with getDefiningOp result (NFC)
PiperOrigin-RevId: 376110457
2021-05-27 00:20:42 -07:00
A. Unique TensorFlower d939a156d8 Integrate LLVM at llvm/llvm-project@5852582532
Updates LLVM usage to match
[5852582532b3](https://github.com/llvm/llvm-project/commit/5852582532b3)

PiperOrigin-RevId: 376059531
2021-05-26 17:01:04 -07:00
Hanhan Wang 28c411606f Add support for lowering mhlo.dynamic-update-slice ops to Linalg and std ops.
PiperOrigin-RevId: 376042810
2021-05-26 15:31:05 -07:00
A. Unique TensorFlower 1c7415ba0b Integrate LLVM at llvm/llvm-project@c5c1ec7945
Updates LLVM usage to match
[c5c1ec7945ff](https://github.com/llvm/llvm-project/commit/c5c1ec7945ff)

PiperOrigin-RevId: 376014620
2021-05-26 13:21:07 -07:00
Mehdi Amini af01c08ce6 Allow tuple as results of mhlo.custom_call op (NFC)
PiperOrigin-RevId: 376009518
2021-05-26 12:56:10 -07:00
Robert Suderman 26a0053d7d Remove linalg.indexed_generic from mhlo lowerings to linalg
IndexedGeneric is going away. Transition to using linalg.Index instead.

PiperOrigin-RevId: 376002501
2021-05-26 12:24:23 -07:00
Benjamin Kramer ca09dabf1a Integrate LLVM at llvm/llvm-project@ea91a8cbab
Updates LLVM usage to match
[ea91a8cbab93](https://github.com/llvm/llvm-project/commit/ea91a8cbab93)

PiperOrigin-RevId: 375987155
2021-05-26 11:15:30 -07:00
A. Unique TensorFlower 4ebcebf31c [MLIR][HLO] Exploit scalar properties in rank specialization lowering
Take advantage of the fact that scalars are already ranked and that they are
neutral elements to broadcasting. Do not reshape scalars, do not consider them
for broadcasting, and materialize ranked operations on scalars accordingly.

PiperOrigin-RevId: 375968371
2021-05-26 09:59:13 -07:00
Benjamin Kramer 2f8f3d692c Integrate LLVM at llvm/llvm-project@01120fe5b3
Updates LLVM usage to match
[01120fe5b398](https://github.com/llvm/llvm-project/commit/01120fe5b398)

PiperOrigin-RevId: 375937201
2021-05-26 07:23:01 -07:00
Benjamin Kramer edf5ec8084 Integrate LLVM at llvm/llvm-project@cb65419b1a
Updates LLVM usage to match
[cb65419b1ac0](https://github.com/llvm/llvm-project/commit/cb65419b1ac0)

PiperOrigin-RevId: 375915516
2021-05-26 04:47:24 -07:00
A. Unique TensorFlower 4b3e9373e6 Integrate LLVM at llvm/llvm-project@bc56620b8b
Updates LLVM usage to match
[bc56620b8b76](https://github.com/llvm/llvm-project/commit/bc56620b8b76)

PiperOrigin-RevId: 375829158
2021-05-25 17:17:28 -07:00
A. Unique TensorFlower 1439ec7cae Integrate LLVM at llvm/llvm-project@0bbb502daa
Updates LLVM usage to match
[0bbb502daa90](https://github.com/llvm/llvm-project/commit/0bbb502daa90)

PiperOrigin-RevId: 375778977
2021-05-25 13:13:08 -07:00
A. Unique TensorFlower cb46298a07 [MLIR][HLO] Support all smaller ranks in rank specialization cases
Rank specialization cases can be applied to all argument tensors of smaller
ranks than the expected maximum rank. This is crucial if all operands are
effectively scalars and the maximum reduced rank is 0.

PiperOrigin-RevId: 375712020
2021-05-25 08:38:53 -07:00
Benjamin Kramer c5af02fd8d Integrate LLVM at llvm/llvm-project@f3c577ed38
Updates LLVM usage to match
[f3c577ed38e5](https://github.com/llvm/llvm-project/commit/f3c577ed38e5)

PiperOrigin-RevId: 375703642
2021-05-25 07:53:35 -07:00
Adrian Kuegel a847109ac7 Support complex types when converting HLO multiply op.
We can lower it to the MulOp in the complex dialect.

PiperOrigin-RevId: 375675079
2021-05-25 04:35:34 -07:00
Adrian Kuegel 5816920258 Support complex types when converting HLO divide op.
We can lower it to the DivOp in the complex dialect.
Also add tests to hlo-legalize-to-linalg.mlir for CompareOp lowering of complex
types. These were forgotten in a previous commit.

PiperOrigin-RevId: 375669125
2021-05-25 03:43:46 -07:00
Benjamin Kramer 8e28008e38 Integrate LLVM at llvm/llvm-project@6359842bc0
Updates LLVM usage to match
[6359842bc088](https://github.com/llvm/llvm-project/commit/6359842bc088)

PiperOrigin-RevId: 375667591
2021-05-25 03:30:27 -07:00
Adrian Kuegel 758ae7da6b Support complex types when converting HLO compare op (EQ/NE).
We can lower it to the EqualOp / NotEqualOp in the complex dialect.

PiperOrigin-RevId: 375655092
2021-05-25 01:54:27 -07:00
A. Unique TensorFlower 5504f82f11 Integrate LLVM at llvm/llvm-project@c2f819af73
Updates LLVM usage to match
[c2f819af73c5](https://github.com/llvm/llvm-project/commit/c2f819af73c5)

PiperOrigin-RevId: 375598055
2021-05-24 17:52:41 -07:00
A. Unique TensorFlower af6092ef13 Integrate LLVM at llvm/llvm-project@d65c32fb41
Updates LLVM usage to match
[d65c32fb41b0](https://github.com/llvm/llvm-project/commit/d65c32fb41b0)

PiperOrigin-RevId: 375537865
2021-05-24 12:57:30 -07:00
wyzhao b93e54d8a4 PR #49454: [MLIR][DISC] Upgrade to use the new `reifyReturnTypeShapes` interface.
Imported from GitHub PR https://github.com/tensorflow/tensorflow/pull/49454

The new interface is more safe to be used during dialect conversion
(e.g. converting from tensor world to buffer world).
Copybara import of the project:

--
a6968072d59bec3c3bbaef0121d297e807c37c91 by Wenyi Zhao <reyizero@gmail.com>:

[MLIR][DISC] Upgrade to use the new `reifyReturnTypeShapes` interface.

The new interface is more safe to be used during dialect conversion
(e.g. converting from tensor world to buffer world).

--
55e7c6b7f2f99b99e226645a57e2433fae3e90ed by Wenyi Zhao <reyizero@gmail.com>:

minor fix

PiperOrigin-RevId: 375500273
2021-05-24 10:11:55 -07:00
Stella Laurenzo 28c4112f35 Downgrade some emitErrors in patterns to notifyMatchFailure.
PiperOrigin-RevId: 375160543
2021-05-21 14:09:23 -07:00
Hanhan Wang 1ba4c714c9 Add support for lowering mhlo.scatter ops to Linalg.
This only works for updating tensors, not add/min/max computations. It requires
the index depth to be 1 because of the limitation in Linalg. We can not compare
multiple indices without packing indices.

PiperOrigin-RevId: 375137721
2021-05-21 12:17:14 -07:00
A. Unique TensorFlower f5dc73ab60 Integrate LLVM at llvm/llvm-project@eb6429d0fb
Updates LLVM usage to match
[eb6429d0fb94](https://github.com/llvm/llvm-project/commit/eb6429d0fb94)

PiperOrigin-RevId: 375071389
2021-05-21 06:31:13 -07:00
A. Unique TensorFlower 1f996ab796 Integrate LLVM at llvm/llvm-project@b9076d119a
Updates LLVM usage to match
[b9076d119a5b](https://github.com/llvm/llvm-project/commit/b9076d119a5b)

PiperOrigin-RevId: 375055490
2021-05-21 04:09:26 -07:00
A. Unique TensorFlower 97e6103933 [MLIR][HLO] Reshape to scalars in rank specialization
Scalars were incorrectly casted to scalar tensors when they have to be reshaped.

PiperOrigin-RevId: 375049088
2021-05-21 03:12:16 -07:00
A. Unique TensorFlower c3147d76d5 Integrate LLVM at llvm/llvm-project@e3cf7c88c4
Updates LLVM usage to match
[e3cf7c88c472](https://github.com/llvm/llvm-project/commit/e3cf7c88c472)

PiperOrigin-RevId: 375041162
2021-05-21 02:10:15 -07:00
A. Unique TensorFlower 3daf65578a [MLIR][HLO] Add scalar cases for binary rank specialization
For rank specialization clusters that have only two operands, we can materialize
two extra cases in which either of them is a scalar. This avoids redundant index
computations in these cases.

PiperOrigin-RevId: 375037390
2021-05-21 01:35:44 -07:00
Feiwen a7884196f5 PR #49228: [MLIR][DISC] porting dynamic shape related OPs to mhlo and lmhlo dialect
Imported from GitHub PR https://github.com/tensorflow/tensorflow/pull/49228

We are porting our MLIR-based dynamic shape compiler to tf community (From OP def, Patttern, to Optimization pass, etc).
This is the first PR, which including some dynamic shape OPs def in mhlo and lmhlo dialect.
For mhlo dialect, we add:
- HLO_RealDynamicSliceOp
- HLO_DynamicPadOp
- HLO_DynamicGatherOp
- HLO_DynamicConvOp

For lmhlo dialect, we add:
- LHLO_RealDynamicSliceOp
- LHLO_DynamicBroadcastInDimOp
- LHLO_DynamicGatherOp
- LHLO_DynamicPadOp
- LHLO_DynamicBitcastOp
- LHLO_DynamicConvOp
- LHLO_DynamicIotaOp
- LHLO_DynamicReshapeOp
- LHLO_DotGeneralOp
- LHLO_BitcastOp

Rest Ops to add:
* We will send a separate PR containing LHLO_DynamicWhileOp and LHLO_DynamicCaseOp for control flow.
* We will add a separate dedicated dialect like mhlo_ral, which including D2HOp/H2DOp/DebugPrintOp/TopKOp, etc.

Previous discussions:[RFC](https://groups.google.com/a/tensorflow.org/g/mlir/c/_X48poNcbDI/m/jCC8BWIICQAJ), [discussion_1](https://llvm.discourse.group/t/updates-on-mlir-based-dynamic-shape-compiler/2384), [Recording of meeting](https://drive.google.com/file/d/1_uEISlV5MUWdG9faKAdKlCWnPtGjRC-D/view?usp=sharing).
Copybara import of the project:

--
e22d9e61106e00a1a1c6f368cc4a03e3bd1f414c by azazhu <azazhu@gmail.com>:

[DISC]fea: porting mhlo and lmhlo OPs

--
9ec3e76290da07cbd53d7da5fa86ff67179441a1 by azazhu <azazhu@gmail.com>:

[DISC][MLIR] 1. add summary and description for dynamic OPs in mhlo and lmhlo; 2. rm InferOutputTypes; 3. add verify for RealDynamicSliceOp and DynamicPadOp

--
0d68cd135555fd935991c12456b21329e628f23f by azazhu <azazhu@gmail.com>:

[DISC][MLIR] 1.remove D2H,H2D and DebugPrint Ops from mhlo/lmhlo dialect; 2. add type constraint to DynamicPadOp and RealDynamicSliceOp; 3.refine lmhlo type constraint; 4.rename RealDynamicSliceOp as name conflict.

--
698762a77d60f6a844cb1ab3f32740d4ef3c5843 by azazhu <azazhu@gmail.com>:

[DISC][MLIR] 1. replace dyn_cast to cast 2. refine code

PiperOrigin-RevId: 375022260
2021-05-20 23:16:47 -07:00
Hanhan Wang cd8f585cf7 [MHLO:Linalg] Add support for lowering torch_index_select of unsigned tensors
Also fixes typos in tests.

PiperOrigin-RevId: 374979460
2021-05-20 17:03:05 -07:00
A. Unique TensorFlower a1445aa0fa Integrate LLVM at llvm/llvm-project@cb82e8ea33
Updates LLVM usage to match
[cb82e8ea33e3](https://github.com/llvm/llvm-project/commit/cb82e8ea33e3)

PiperOrigin-RevId: 374977251
2021-05-20 16:50:30 -07:00
Rahul Joshi 41f663ce47 [HLO] Adopt custom syntax for convolution dimensions and window attributes (HLO)
PiperOrigin-RevId: 374923250
2021-05-20 12:13:50 -07:00
Rahul Joshi fc88cf1ff4 [HLO] Adopt custom syntax for convolution dims and window attributes for LMHLO_GPU
PiperOrigin-RevId: 374889917
2021-05-20 09:41:48 -07:00
A. Unique TensorFlower 57aeb5ab16 Integrate LLVM at llvm/llvm-project@0316f3e649
Updates LLVM usage to match
[0316f3e64972](https://github.com/llvm/llvm-project/commit/0316f3e64972)

PiperOrigin-RevId: 374855085
2021-05-20 06:09:40 -07:00
A. Unique TensorFlower c62fd89663 [MLIR][HLO] Add equal shapes case to rank specialization
Also restructure lowering implementation to facilitate the addition or removal
of special cases.

PiperOrigin-RevId: 374626365
2021-05-19 05:38:42 -07:00
Stella Laurenzo 71394fb301 Properly handle if DynamicBroadcastInDimOp shape is not of index type.
* The op defines this to be index, any integer, or pred (i1).
* Many TensorFlow legalizations produce integers for the shape.

PiperOrigin-RevId: 374566113
2021-05-18 21:12:11 -07:00
Stella Laurenzo 0fe07e3814 Separate CHLO transforms for expanding compositions and lowering broadcasts.
* The former is typically invariant regardless of backend.
* The latter may need to be done differently depending on capabilities of the lowering target.

PiperOrigin-RevId: 374492924
2021-05-18 13:33:59 -07:00
A. Unique TensorFlower e0d9e9bffd Integrate LLVM at llvm/llvm-project@6381664580
Updates LLVM usage to match
[638166458008](https://github.com/llvm/llvm-project/commit/638166458008)

PiperOrigin-RevId: 374437050
2021-05-18 09:30:58 -07:00
A. Unique TensorFlower 1aa6eb24b0 Integrate LLVM at llvm/llvm-project@560b709abe
Updates LLVM usage to match
[560b709abedc](https://github.com/llvm/llvm-project/commit/560b709abedc)

PiperOrigin-RevId: 374420543
2021-05-18 08:12:11 -07:00
A. Unique TensorFlower dedc129c8c Integrate LLVM at llvm/llvm-project@f8dbd61074
Updates LLVM usage to match
[f8dbd6107417](https://github.com/llvm/llvm-project/commit/f8dbd6107417)

PiperOrigin-RevId: 374391426
2021-05-18 04:58:00 -07:00