The expr statement visiting method for tirx. Parameters ---------- self : Parser The visiting parser. node : doc.Expr The doc AST Expr node.
(self: Parser, node: doc.Expr)
| 713 | |
| 714 | @dispatch.register(token="tirx", type_name="Expr") |
| 715 | def visit_expr_stmt(self: Parser, node: doc.Expr) -> None: |
| 716 | """The expr statement visiting method for tirx. |
| 717 | |
| 718 | Parameters |
| 719 | ---------- |
| 720 | self : Parser |
| 721 | The visiting parser. |
| 722 | |
| 723 | node : doc.Expr |
| 724 | The doc AST Expr node. |
| 725 | """ |
| 726 | |
| 727 | res = self.eval_expr(node.value) |
| 728 | if res is None: |
| 729 | pass |
| 730 | elif isinstance(res, Frame): |
| 731 | res.add_callback(partial(res.__exit__, None, None, None)) |
| 732 | res.__enter__() |
| 733 | elif hasattr(res, "frames") and hasattr(res, "__enter__"): |
| 734 | # _FrameScope from T.attr({...}) — enter each inner frame for concise scoping |
| 735 | for f in res.frames: |
| 736 | f.add_callback(partial(f.__exit__, None, None, None)) |
| 737 | f.__enter__() |
| 738 | elif isinstance(res, Var): |
| 739 | # Standalone Var expression (e.g. from T.bind(value, var=v)) -- |
| 740 | # the Bind statement was already emitted to the parent frame by the FFI call, |
| 741 | # so just discard the returned Var. |
| 742 | pass |
| 743 | elif isinstance(res, PrimExpr): |
| 744 | T.evaluate(res) |
| 745 | elif isinstance(res, int | bool): |
| 746 | T.evaluate(tvm.tirx.const(res)) |
| 747 | elif isinstance(res, tvm.relax.Call) and not res.args: |
| 748 | # Using GlobalVar.__call__ with no arguments is ambiguous, as |
| 749 | # each IR has a different function Call representation. If |
| 750 | # this occurs, convert to the TIR representation. |
| 751 | T.evaluate(tvm.tirx.call_tir(res.op)) |
| 752 | elif isinstance(res, str): |
| 753 | # Ignore docstrings |
| 754 | pass |
| 755 | elif isinstance(res, tvm.tirx.stmt.BufferStore): |
| 756 | T.buffer_store(res.buffer, res.value, res.indices, res.predicate) |
| 757 | elif isinstance(res, tvm.tirx.Buffer): |
| 758 | # ``T.match_buffer(...)`` used as a bare statement (no LHS) — the |
| 759 | # buffer object is discarded; the underlying side effect (the |
| 760 | # match_buffer node) has already been emitted into the frame. |
| 761 | pass |
| 762 | else: |
| 763 | self.report_error(node, f"Parsing resulted in unexpected type {type(res)}") |
| 764 | |
| 765 | |
| 766 | @dispatch.register(token="tirx", type_name="If") |
nothing calls this directly
no test coverage detected
searching dependent graphs…