def concat_list_to_block(lst): """Concatenate a list of Python IR nodes to HalideIR Block""" if not lst: return utils.make_nop() n = len(lst) if n == 1: return lst[0] return _stmt.SeqStmt(lst)
def pop_stmt(self): """Create a statement from the statements within current stage.""" stmts = self.stmt_stack.pop() if not stmts or callable(stmts[-1]): stmts.append(_stmt.Evaluate(0)) stmtwrap = lambda x: x[0] if len(x) == 1 else _stmt.SeqStmt( list(reversed(x))) ret_stmt = [stmts[-1]] for s in reversed(stmts[:-1]): if callable(s): ret_stmt = [s(stmtwrap(ret_stmt))] else: assert isinstance(s, _stmt.Stmt) ret_stmt.append(s) return stmtwrap(ret_stmt)