EnzymeAD / EnzymeAD/Enzyme-JAX
Unsupported reduce init for batched reduce
- Dominant language
- MLIR
- Stars
- 131
- Forks
- 53
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 193
Description
The following batch of `reduce`
```
module @root {
func.func @func1(%arg0: tensor<1xf64>) -> tensor {
%cst = stablehlo.constant dense<0.000000e+00> : tensor
%0 = stablehlo.broadcast_in_dim %cst, dims = [] : (tensor) -> tensor
%1 = stablehlo.reduce(%arg0 init: %0) applies stablehlo.add across dimensions = [0] : (tensor<1xf64>, tensor) -> tensor
return %1 : tensor
}
func.func @main() -> tensor<2xf64> {
%cst = stablehlo.constant dense<0.000000e+00> : tensor<2x1xf64>
%0 = enzyme.batch @func1(%cst) {batch_shape = array} : (tensor<2x1xf64>) -> tensor<2xf64>
return %0 : tensor<2xf64>
}
}
```
produces
```
test.mlir:5:26: error: Unsupported reduce init for batched reduce
%1 = stablehlo.reduce(%arg0 init: %0) applies stablehlo.add across dimensions = [0] : (tensor<1xf64>, tensor) -> tensor
^
test.mlir:5:26: note: see current operation:
%2 = "stablehlo.reduce"(%arg0, %1) <{dimensions = array}> ({
^bb0(%arg1: tensor, %arg2: tensor):
%3 = "stablehlo.add"(%arg1, %arg2) : (tensor, tensor) -> tensor
"stablehlo.return"(%3) : (tensor) -> ()
}) : (tensor<1xf64>, tensor) -> tensor
test.mlir:5:26: error: The shape of reduction-region's argument at index 1 is not compatible with that of reduce-op's input-parameter at index 0
%1 = stablehlo.reduce(%arg0 init: %0) applies stablehlo.add across dimensions = [0] : (tensor<1xf64>, tensor) -> tensor
^
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by running the provided reproducer in test.mlir and trace handling of the batched stablehlo.reduce operation that emits “Unsupported reduce init for batched reduce.” Compare the reduction input and init shapes shown in the diagnostic. Done means this example no longer produces the reported errors and batched reduce behavior is supported as intended.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 58/100