|
| 1 | +// RUN: graphalg-opt --graphalg-verify-loop-bounds --split-input-file --verify-diagnostics < %s |
| 2 | +#dim = #graphalg.dim<distinct[0]<>> |
| 3 | + |
| 4 | +func.func @OkDim(%arg0: !graphalg.mat<#dim x 1 x i64>) -> !graphalg.mat<1 x 1 x i64> { |
| 5 | + %0 = graphalg.const_mat 0 : i64 -> <1 x 1 x i64> |
| 6 | + %1 = graphalg.for begin=0 iters=#dim init(%0) : !graphalg.mat<1 x 1 x i64> -> !graphalg.mat<1 x 1 x i64> body { |
| 7 | + ^bb0(%arg1: !graphalg.mat<1 x 1 x i64>, %arg2: !graphalg.mat<1 x 1 x i64>): |
| 8 | + graphalg.yield %arg2 : !graphalg.mat<1 x 1 x i64> |
| 9 | + } until { |
| 10 | + } |
| 11 | + return %1 : !graphalg.mat<1 x 1 x i64> |
| 12 | +} |
| 13 | + |
| 14 | +func.func @OkConst(%arg0: !graphalg.mat<#dim x 1 x i64>) -> !graphalg.mat<1 x 1 x i64> { |
| 15 | + %0 = graphalg.const_mat 0 : i64 -> <1 x 1 x i64> |
| 16 | + %1 = graphalg.for begin=0 iters=<42> init(%0) : !graphalg.mat<1 x 1 x i64> -> !graphalg.mat<1 x 1 x i64> body { |
| 17 | + ^bb0(%arg1: !graphalg.mat<1 x 1 x i64>, %arg2: !graphalg.mat<1 x 1 x i64>): |
| 18 | + graphalg.yield %arg2 : !graphalg.mat<1 x 1 x i64> |
| 19 | + } until { |
| 20 | + } |
| 21 | + return %1 : !graphalg.mat<1 x 1 x i64> |
| 22 | +} |
| 23 | + |
| 24 | +// ----- |
| 25 | +#dim = #graphalg.dim<distinct[0]<>> |
| 26 | + |
| 27 | +func.func @DynDim(%arg0 : !graphalg.mat<1 x 1 x i64>) -> !graphalg.mat<1 x 1 x i64> { |
| 28 | + %0 = graphalg.const_mat 0 : i64 -> <1 x 1 x i64> |
| 29 | + // expected-error@below{{'graphalg.for' op loop bound is not a constant or matrix dimension}} |
| 30 | + %1 = graphalg.for dyn_end=%arg0 begin=0 init(%0) : !graphalg.mat<1 x 1 x i64> -> !graphalg.mat<1 x 1 x i64> body { |
| 31 | + ^bb0(%arg1: !graphalg.mat<1 x 1 x i64>, %arg2: !graphalg.mat<1 x 1 x i64>): |
| 32 | + graphalg.yield %arg2 : !graphalg.mat<1 x 1 x i64> |
| 33 | + } until { |
| 34 | + } |
| 35 | + return %1 : !graphalg.mat<1 x 1 x i64> |
| 36 | +} |
0 commit comments