Commit Graph

997 Commits

Author SHA1 Message Date
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
A. Unique TensorFlower 623b630fee Integrate LLVM at llvm/llvm-project@3bc2b97b34
Updates LLVM usage to match
[3bc2b97b34ff](https://github.com/llvm/llvm-project/commit/3bc2b97b34ff)

PiperOrigin-RevId: 374379055
2021-05-18 03:18:33 -07:00
A. Unique TensorFlower 6af3d2df91 [MLIR][HLO] Add rank specialization with multiple non-scalar operands
Add lowering pattern for rank specialization clusters with more than one
non-scalar operand. The lowering resembles that of the `TransformUnrankedHlo`
pass and switches cases for maximal ranks from 1 through 8.

PiperOrigin-RevId: 374377002
2021-05-18 03:02:45 -07:00
A. Unique TensorFlower 0168484eed Integrate LLVM at llvm/llvm-project@e2e1a78abc
Updates LLVM usage to match
[e2e1a78abcef](https://github.com/llvm/llvm-project/commit/e2e1a78abcef)

PiperOrigin-RevId: 374360199
2021-05-18 00:39:33 -07:00
A. Unique TensorFlower 577ab8bb81 Integrate LLVM at llvm/llvm-project@ab5ff154ab
Updates LLVM usage to match
[ab5ff154abe5](https://github.com/llvm/llvm-project/commit/ab5ff154abe5)

PiperOrigin-RevId: 374247895
2021-05-17 12:04:15 -07:00
A. Unique TensorFlower 3f4e8bc658 Integrate LLVM at llvm/llvm-project@8854b27b19
Updates LLVM usage to match
[8854b27b198c](https://github.com/llvm/llvm-project/commit/8854b27b198c)

PiperOrigin-RevId: 374219034
2021-05-17 09:56:21 -07:00
A. Unique TensorFlower 474e419729 [MLIR][HLO] Generalize rank specialization with single operand
The pattern can be generalized to also rank specialize operations with a single
non-scalar operand. Also extract helper functions that can be reused in
following specializations.

PiperOrigin-RevId: 374198381
2021-05-17 08:12:55 -07:00
A. Unique TensorFlower b86b18489c Integrate LLVM at llvm/llvm-project@50511df32e
Updates LLVM usage to match
[50511df32edf](https://github.com/llvm/llvm-project/commit/50511df32edf)

PiperOrigin-RevId: 374197586
2021-05-17 08:08:48 -07:00
A. Unique TensorFlower c514c73390 [MLIR][HLO] Extend rank specialization clustering pass
Also cluster operations that operate on same shape operands. These implicitly
satisfy the broadcasting semantics requirement. Also, add test cases for some
cases that appear in the current MLIR-generated kernels.

PiperOrigin-RevId: 374191950
2021-05-17 07:31:36 -07:00
A. Unique TensorFlower b82bbf4dd1 Integrate LLVM at llvm/llvm-project@7c16f93c44
Updates LLVM usage to match
[7c16f93c44ca](https://github.com/llvm/llvm-project/commit/7c16f93c44ca)

PiperOrigin-RevId: 374179613
2021-05-17 06:06:00 -07:00
A. Unique TensorFlower ccd70d5717 [MLIR][HLO] Add `rank-specialization-to-scf` pass
Currently the lowering is only implemented for the unary case. The n-ary case
will follow.

PiperOrigin-RevId: 374162772
2021-05-17 03:56:23 -07:00
A. Unique TensorFlower 295ef229d6 Integrate LLVM at llvm/llvm-project@a11117a7c0
Updates LLVM usage to match
[a11117a7c0a2](https://github.com/llvm/llvm-project/commit/a11117a7c0a2)

PiperOrigin-RevId: 374152829
2021-05-17 02:33:42 -07:00
A. Unique TensorFlower 804d1b50d6 Integrate LLVM at llvm/llvm-project@88a8965a7d
Updates LLVM usage to match
[88a8965a7d93](https://github.com/llvm/llvm-project/commit/88a8965a7d93)

PiperOrigin-RevId: 374099490
2021-05-16 17:25:22 -07:00
Ben Vanik b06baae910 Fixing nondeterminism in pattern application.
The ReduceRegion* patterns are matching on the same ops as the PointwiseToLinalg*
patterns and on certain toolchains (MSVC) the order can be wrong. If the pointwise
runs first then it converts the op *within* the reduction before the reduction one
runs, leading to nested linalg op weirdness.

PiperOrigin-RevId: 373848269
2021-05-14 12:57:39 -07:00
Rahul Joshi a361253e4f [HLO] Add custom print/parse for window attributes of convolutions (in LMHLO)
PiperOrigin-RevId: 373807616
2021-05-14 09:47:25 -07:00
Adrian Kuegel e4caaaf921 Integrate LLVM at llvm/llvm-project@e51ef7f070
Updates LLVM usage to match
[e51ef7f0706a](https://github.com/llvm/llvm-project/commit/e51ef7f0706a)

PiperOrigin-RevId: 373772350
2021-05-14 06:12:47 -07:00
A. Unique TensorFlower 76341f3720 [MLIR][HLO] Add mixed test for `rank-specialization-cluster` pass
PiperOrigin-RevId: 373762814
2021-05-14 04:40:40 -07:00
Adrian Kuegel 9248f0a182 Integrate LLVM at llvm/llvm-project@c82a0ae70e
Updates LLVM usage to match
[c82a0ae70e28](https://github.com/llvm/llvm-project/commit/c82a0ae70e28)

PiperOrigin-RevId: 373750063
2021-05-14 02:35:37 -07:00
A. Unique TensorFlower b1b6e81913 Integrate LLVM at llvm/llvm-project@7c57a9bd7d
Updates LLVM usage to match
[7c57a9bd7d4c](https://github.com/llvm/llvm-project/commit/7c57a9bd7d4c)

PiperOrigin-RevId: 373739370
2021-05-14 00:56:40 -07:00
A. Unique TensorFlower d2cc74317c Implement constant folding for mhlo.Sign.
PiperOrigin-RevId: 373550014
2021-05-13 03:54:04 -07:00
Hanhan Wang d764806c1e [MHLO:Linalg] Add support for lowering reshape of unsigned tensors
PiperOrigin-RevId: 373461627
2021-05-12 15:14:29 -07:00
Alex Zinenko a2c9b3c9d7 [mlir] update gentbl() Bazel macro
Rename `gentbl` to `gentbl_cc_library` to make it clearer which kind of rule is
ultimately used.

Update `gentbl_*` macros to take `tbl_outs` options as a list rather a
whitespace-separated string and remove the related string handling.

PiperOrigin-RevId: 373406352
2021-05-12 10:58:58 -07:00
A. Unique TensorFlower 420c42a0a1 [MLIR][HLO] Support CHLO unary operations in rank specialization clustering
PiperOrigin-RevId: 373397321
2021-05-12 10:20:43 -07:00
A. Unique TensorFlower 596918a6f1 [MLIR][HLO] Allow rank specialization clustering with `chlo.broadcast_select` op
PiperOrigin-RevId: 373379990
2021-05-12 08:56:49 -07:00
Rahul Joshi e260aa771c [HLO] Add custom print/parse for convolution dimension numbers (in LMHLO)
PiperOrigin-RevId: 373379227
2021-05-12 08:52:46 -07:00
Itai Zukerman 30779f0c2f Added build rules for HLO and LHLO ops MD.
PiperOrigin-RevId: 373373920
2021-05-12 08:23:40 -07:00
Adrian Kuegel 8895262330 Integrate LLVM at llvm/llvm-project@b7a11274f9
Updates LLVM usage to match
[b7a11274f90f](https://github.com/llvm/llvm-project/commit/b7a11274f90f)

PiperOrigin-RevId: 373353006
2021-05-12 06:04:40 -07:00
A. Unique TensorFlower 875803e5e1 [MLIR][HLO] Add more tests for `rank-specialization-cluster` pass
PiperOrigin-RevId: 373343750
2021-05-12 04:46:30 -07:00
Adrian Kuegel b95162f182 Integrate LLVM at llvm/llvm-project@34c098b780
Updates LLVM usage to match
[34c098b780a2](https://github.com/llvm/llvm-project/commit/34c098b780a2)

PiperOrigin-RevId: 373336846
2021-05-12 03:48:06 -07:00
A. Unique TensorFlower 313d24bc8f [MLIR][HLO] Add `rank-specialization-cluster` pass
Add a pass to cluster unranked C/HLO operations in one
`chlo.rank_specialization_cluster` op. The C/HLO operations are moved to the
body of the operation. Later passes can use this to rank-specialize all these
operations together.

PiperOrigin-RevId: 373336725
2021-05-12 03:46:01 -07:00
Adrian Kuegel 7f84779868 Integrate LLVM at llvm/llvm-project@6351993da7
Updates LLVM usage to match
[6351993da72e](https://github.com/llvm/llvm-project/commit/6351993da72e)

PiperOrigin-RevId: 373327134
2021-05-12 02:34:59 -07:00
A. Unique TensorFlower 5ec03ba8a5 Integrate LLVM at llvm/llvm-project@23596fece0
Updates LLVM usage to match
[23596fece043](https://github.com/llvm/llvm-project/commit/23596fece043)

PiperOrigin-RevId: 373315484
2021-05-12 00:56:04 -07:00
A. Unique TensorFlower b783b3272e Integrate LLVM at llvm/llvm-project@3f8be15f29
Updates LLVM usage to match
[3f8be15f2911](https://github.com/llvm/llvm-project/commit/3f8be15f2911)

PiperOrigin-RevId: 373302768
2021-05-11 22:56:46 -07:00
A. Unique TensorFlower 3ccf3938fa Integrate LLVM at llvm/llvm-project@fec2945998
Updates LLVM usage to match
[fec294599894](https://github.com/llvm/llvm-project/commit/fec294599894)

PiperOrigin-RevId: 373275250
2021-05-11 18:37:01 -07:00
Jacques Pienaar 2ea9470515 Remove BASE_HLO_ConvOp to remove coupling between MHLO and LMHLO conv ops
PiperOrigin-RevId: 373201247
2021-05-11 11:54:44 -07:00
Itai Zukerman a4db6c57aa Removed all (most) BASE_HLO_* ops.
Moved the corresponding `summary` and `description` fields into the subclasses.
Kept BASE_HLO_ConvOp for `hasWindowReversal()'.

PiperOrigin-RevId: 373173025
2021-05-11 09:48:31 -07:00