[Op] Support of multiple if conditions
Closed this issue · 1 comments
chhzh123 commented
We need to support the following imperative program with multiple conditions in a if statement, which is also useful to support general SelectOp
.
with hcl.if_(hcl.all(i > j, j >= i + 1)): # affine.if
A[i, j] += 1
chhzh123 commented
To capture the high-level information, we can do the following steps:
- Create an
hcl.logical_and
op that can take in variadic arguments, each of which is a condition expression. - Create a Python binding interface
LogicalAndOp
. - Map the frontend
hcl.all
op tohcl_mlir.LogicalAndOp
. - In
build_ir.py/make_if
we allow the input of expression to be anLogicalAndOp
, and take each of its arguments to individually traverse the expression tree and construct the affine expressions.
In this way, hcl.logical_and
is actually not built as an IR node, but is directly lowered when building the MLIR code.