cornell-zhang/hcl-dialect

[Op][Binding] Support while loops

Closed this issue · 0 comments

See the specification of scf.while. The first region calculates the while condition, and the second region is the loop body.

The implementation is similar to make_if, which requires moving the condition inside the region. Since A[i] < 10 in Python is evaluated first before calling the function hcl.while_, it may be built outside the region. Thus, the correct way is to remove the original A[i] < 10 and rebuild a new one inside the region.

with hcl.while_(A[i] < 10):
    # ...