| 11 | |
| 12 | |
| 13 | def example_loop(): |
| 14 | with Task(): |
| 15 | total = ops.Const(0) |
| 16 | total_large = ops.Const(0) |
| 17 | total_small = ops.Const(0) |
| 18 | total_tiny = ops.Const(0) |
| 19 | with ops.loop(10) as loop: |
| 20 | outer = ops.Mul([loop.iter(), ops.Const(10)]) |
| 21 | with ops.loop(loop.iter()) as inner: |
| 22 | val = ops.Add([outer, inner.iter()]) |
| 23 | with ops.If(ops.GE([val, ops.Const(80)])) as c: |
| 24 | ops.Add([total_large, val], [total_large]) |
| 25 | with c.Elif(ops.GE([val, ops.Const(50)])) as c: |
| 26 | ops.Add([total_small, val], [total_small]) |
| 27 | with c.Else(): |
| 28 | ops.Add([total_tiny, val], [total_tiny]) |
| 29 | ops.Add([total, val], total) |
| 30 | |
| 31 | |
| 32 | def example_task(): |