[Mlir-commits] [mlir] [MLIR][Python] Python binding support for AffineIfOp (PR #108323)
Amy Wang
llvmlistbot at llvm.org
Wed Nov 13 13:21:39 PST 2024
================
@@ -156,3 +156,61 @@ def for_(
yield iv, iter_args[0]
else:
yield iv
+
+
+ at _ods_cext.register_operation(_Dialect, replace=True)
+class AffineIfOp(AffineIfOp):
+ """Specialization for the Affine if op class."""
+
+ def __init__(
+ self,
+ cond: IntegerSet,
+ results_: Optional[Type] = None,
+ *,
+ cond_operands: Optional[_VariadicResultValueT] = None,
+ hasElse: bool = False,
+ loc=None,
+ ip=None,
+ ):
+ """Creates an Affine `if` operation.
+
+ - `cond` is the integer set used to determine which regions of code
+ will be executed.
+ - `results` are the list of types to be yielded by the operand.
+ - `cond_operands` is the list of arguments to substitute the
+ dimensions, then symbols in the `cond` integer set expression to
+ determine whether they are in the set.
+ - `hasElse` determines whether the affine if operation has the else
+ branch.
+ """
+ if results_ is None:
+ results_ = []
+ if cond_operands is None:
+ cond_operands = []
+
+ if not (actual_n_inputs := len(cond_operands)) == (
+ exp_n_inputs := cond.n_inputs
+ ):
----------------
kaitingwang wrote:
Got rid of the walrus assignment for readability.
https://github.com/llvm/llvm-project/pull/108323
More information about the Mlir-commits
mailing list