EnzymeAD / EnzymeAD/Enzyme-JAX
Cannot raise while with bounds checks
- Dominant language
- MLIR
- Stars
- 131
- Forks
- 53
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 193
Description
failed to raise func:
```mlir
module {
func.func private @"##call__Z18gpu_matmul_kernel_16CompilerMetadataI11DynamicSize12DynamicCheckv16CartesianIndicesILi2E5TupleI5OneToI5Int64ES6_EE7NDRangeILi2ES0_S0_S8_S8_EE13CuTracedArrayI7Float64Li2ELi1E10_100__100_ESE_#439$par12"(%arg0: memref<100x100xf64, 1>, %arg1: memref<100x100xf64, 1>) {
%c100 = arith.constant 100 : index
%false = arith.constant false
%c-1_i64 = arith.constant -1 : i64
%c1 = arith.constant 1 : index
%0 = ub.poison : i64
%1 = ub.poison : f64
%c2_i32 = arith.constant 2 : i32
%c1_i64 = arith.constant 1 : i64
%c10000_i64 = arith.constant 10000 : i64
%c100_i64 = arith.constant 100 : i64
%cst = arith.constant 0.000000e+00 : f64
%c101_i64 = arith.constant 101 : i64
affine.parallel (%arg2) = (0) to (10000) {
%2 = arith.index_castui %arg2 : index to i64
%3 = arith.divui %arg2, %c100 : index
%4 = arith.muli %3, %c100 : index
%5 = arith.index_castui %4 : index to i64
%6 = arith.subi %2, %5 : i64
%7 = arith.muli %3, %c100 : index
%8 = arith.index_castui %7 : index to i64
%9:4 = scf.while (%arg3 = %c1_i64, %arg4 = %cst) : (i64, f64) -> (i64, f64, f64, i32) {
%12 = arith.addi %arg3, %c-1_i64 : i64
%13 = arith.muli %12, %c100_i64 : i64
%14 = arith.addi %13, %6 : i64
%15 = arith.index_cast %13 : i64 to index
%16 = arith.cmpi uge, %14, %c10000_i64 : i64
%17:5 = scf.if %16 -> (i64, f64, i32, f64, i1) {
scf.yield %0, %1, %c2_i32, %1, %false : i64, f64, i32, f64, i1
} else {
%18 = affine.apply affine_map<(d0) -> (d0 mod 100)>(%arg2)
%19 = arith.addi %18, %15 : index
%20 = arith.remui %19, %c100 : index
%21 = arith.divui %19, %c100 : index
%22 = memref.load %arg1[%21, %20] : memref<100x100xf64, 1>
%23 = arith.addi %arg3, %8 : i64
%24 = arith.addi %23, %c-1_i64 : i64
%25 = arith.index_cast %arg3 : i64 to index
%26 = arith.cmpi uge, %24, %c10000_i64 : i64
%27:5 = scf.if %26 -> (i64, f64, i32, f64, i1) {
scf.yield %0, %1, %c2_i32, %1, %false : i64, f64, i32, f64, i1
} else {
%28 = affine.apply affine_map<(d0) -> ((d0 floordiv 100) * 100 - 1)>(%arg2)
%29 = arith.addi %28, %25 : index
%30 = arith.remui %29, %c100 : index
%31 = arith.divui %29, %c100 : index
%32 = memref.load %arg1[%31, %30] : memref<100x100xf64, 1>
%33 = arith.mulf %22, %32 {fastmathFlags = #llvm.fastmath} : f64
%34 = arith.addf %arg4, %33 {fastmathFlags = #llvm.fastmath} : f64
%35 = arith.addi %arg3, %c1_i64 : i64
%36 = arith.cmpi eq, %35, %c101_i64 : i64
%37 = arith.extui %36 : i1 to i32
%38 = arith.cmpi ne, %35, %c101_i64 : i64
scf.yield %35, %34, %37, %34, %38 : i64, f64, i32, f64, i1
}
scf.yield %27#0, %27#1, %27#2, %27#3, %27#4 : i64, f64, i32, f64, i1
}
scf.condition(%17#4) %17#0, %17#1, %17#3, %17#2 : i64, f64, f64, i32
} do {
^bb0(%arg3: i64, %arg4: f64, %arg5: f64, %arg6: i32):
scf.yield %arg3, %arg4 : i64, f64
}
%10 = arith.index_castui %9#3 : i32 to index
%11 = arith.cmpi eq, %10, %c1 : index
scf.if %11 {
affine.store %9#2, %arg0[%arg2 floordiv 100, %arg2 mod 100] : memref<100x100xf64, 1>
}
}
return
}
}
```
```
cannot raise op to stablehlo: %9:4 = scf.while (%arg3 = %c1_i64, %arg4 = %cst) : (i64, f64) -> (i64, f64, f64, i32) {
%12 = arith.addi %arg3, %c-1_i64 : i64
%13 = arith.muli %12, %c100_i64 : i64
%14 = arith.addi %13, %6 : i64
%15 = arith.index_cast %13 : i64 to index
%16 = arith.cmpi uge, %14, %c10000_i64 : i64
%17:5 = scf.if %16 -> (i64, f64, i32, f64, i1) {
scf.yield %0, %1, %c2_i32, %1, %false : i64, f64, i32, f64, i1
} else {
%18 = affine.apply affine_map<(d0) -> (d0 mod 100)>(%arg2)
%19 = arith.addi %18, %15 : index
%20 = arith.remui %19, %c100 : index
%21 = arith.divui %19, %c100 : index
%22 = memref.load %arg1[%21, %20] : memref<100x100xf64, 1>
%23 = arith.addi %arg3, %8 : i64
%24 = arith.addi %23, %c-1_i64 : i64
%25 = arith.index_cast %arg3 : i64 to index
%26 = arith.cmpi uge, %24, %c10000_i64 : i64
%27:5 = scf.if %26 -> (i64, f64, i32, f64, i1) {
scf.yield %0, %1, %c2_i32, %1, %false : i64, f64, i32, f64, i1
} else {
%28 = affine.apply affine_map<(d0) -> ((d0 floordiv 100) * 100 - 1)>(%arg2)
%29 = arith.addi %28, %25 : index
%30 = arith.remui %29, %c100 : index
%31 = arith.divui %29, %c100 : index
%32 = memref.load %arg1[%31, %30] : memref<100x100xf64, 1>
%33 = arith.mulf %22, %32 {fastmathFlags = #llvm.fastmath} : f64
%34 = arith.addf %arg4, %33 {fastmathFlags = #llvm.fastmath} : f64
%35 = arith.addi %arg3, %c1_i64 : i64
%36 = arith.cmpi eq, %35, %c101_i64 : i64
%37 = arith.extui %36 : i1 to i32
%38 = arith.cmpi ne, %35, %c101_i64 : i64
scf.yield %35, %34, %37, %34, %38 : i64, f64, i32, f64, i1
}
scf.yield %27#0, %27#1, %27#2, %27#3, %27#4 : i64, f64, i32, f64, i1
}
scf.condition(%17#4) %17#0, %17#1, %17#3, %17#2 : i64, f64, f64, i32
} do {
^bb0(%arg3: i64, %arg4: f64, %arg5: f64, %arg6: i32):
scf.yield %arg3, %arg4 : i64, f64
}
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.