8 Commits

Author SHA1 Message Date
Benjamin Chetioui
d3bf243342 [Mosaic GPU] Add layout inference for splat arith.ConstantOps and vector.SplatOps.
PiperOrigin-RevId: 716224880
2025-01-16 07:18:35 -08:00
Benjamin Chetioui
3366c92782 [Mosaic GPU][NFC] Simplify and clean up layout inference tests to use FuncOps.
PiperOrigin-RevId: 716216260
2025-01-16 06:48:57 -08:00
Benjamin Chetioui
bc7204f003 [Mosaic GPU] Allow querying layouts from a FuncOp's block arguments if set.
The motivation behind this change is twofold:

1. it simplifies test writing (no need to produce arbitrary, manual, non-splat
   constants to produce arguments with a strided layout);
2. it'll allow running layout inference on different `FuncOp`s in isolation,
   before inlining.

While the primary motivation is to simplify test writing for upcoming changes,
`2.` is useful if we ever intend to call functions whose body's layout we have
inferred from other functions. It's not clear to me that we have a use case for
that, but the theoretical benefit is worth pointing out.

Crucially, layout inference does not set default layouts for `FuncOp`s, since
the caller may choose a different layout for its arguments. As a result, there
is also no layout inference rule for `func.FuncOp`.

PiperOrigin-RevId: 716158516
2025-01-16 03:05:41 -08:00
Benjamin Chetioui
1893881b5f [Mosaic GPU] Add initial layout mismatch resolution for splat/strided layouts.
When it is possible to annotate an operation using both a `strided` and a
`splat` layout, we pick the `strided` layout. This is the correct choice when
propagating layouts down from parameters to the root; e.g.

```
? = add(strided, splat)
```

becomes

```
strided = add(strided, strided)
```

and requires a re-layout for the right-hand side argument.

The logic needs to be reversed to handle propagation in the opposite direction.
For example, code like

```
c : ?
use(c) : strided
use(c) : splat
```

should resolve to

```
c : splat
use(c) : strided
use(c) : splat
```

and incur a relayout in the `strided` use of `c`. This direction of propagation
is left as a `TODO` for now, to limit the amount of changes in a single commit.

PiperOrigin-RevId: 714056648
2025-01-10 08:10:57 -08:00
Benjamin Chetioui
3915f4a147 [Mosaic GPU] Commit to using Vectors everywhere (and no Tensors).
PiperOrigin-RevId: 707912637
2024-12-19 07:51:58 -08:00
Benjamin Chetioui
66ad2082ba [Mosaic GPU] Replace the dialect's layout enum with layouts holding the proper
sub-attributes.

PiperOrigin-RevId: 707846907
2024-12-19 02:59:26 -08:00
Benjamin Chetioui
2386838315 [Mosaic GPU] Fix layout inference traversal to traverse ops recursively.
PiperOrigin-RevId: 706136221
2024-12-13 23:51:20 -08:00
Benjamin Chetioui
4ef7706abb [Mosaic GPU] Split layout inference and dialect lowering files and tests.
PiperOrigin-RevId: 705100503
2024-12-11 07:31:34 -08:00