EnzymeAD / EnzymeAD/Enzyme-JAX

Push reshapes up

Open
#575 29 comments 0 reactions 0 assignees View on GitHub
Dominant language
MLIR
Stars
131
Forks
53
Avg merge
1d 10h
Merged PRs (30d)
193

Description

- [ ] reshape( slice ) -> slice ( reshape ) ~(@jumerckx, https://github.com/EnzymeAD/Enzyme-JAX/pull/581)~

```
%3250 = stablehlo.reshape %125 {mhlo.sharding = "{devices=[2,1,2,2]<=[2,2,2]T(1,0,2) last_tile_dim_replicate}"} : (tensor<268x2060xf64>) -> tensor<268x1x2060xf64>
%3377 = stablehlo.slice %3250 [6:262, 0:1, 5:2053] {mhlo.sharding = "{devices=[2,1,2,2]<=[2,2,2]T(1,0,2) last_tile_dim_replicate}"} : (tensor<268x1x2060xf64>) -> tensor<256x1x2048xf64>
%3794 = stablehlo.reshape %3377 {mhlo.sharding = "{devices=[1,2,2,2]<=[2,2,2]T(1,0,2) last_tile_dim_replicate}"} : (tensor<256x1x2048xf64>) -> tensor<1x256x2048xf64>
```

- [x] reshape ( elementwise ) -> elementwise (reshape)
- [x] reshape ( concat ) -> concat (reshape) @chelini (https://github.com/EnzymeAD/Enzyme-JAX/pull/577/)

we just need to do where reshape adds a singleton dim

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by locating the reshape and slice transformation handling in Enzyme-JAX, then compare it with the StableHLO example in the issue. Implement the remaining case where reshape adds a singleton dimension and verify that reshape is pushed before slice without changing the resulting shapes or sharding.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.