MCPcopy Create free account
hub / github.com/apache/tvm / ASTPrinter

Class ASTPrinter

tests/python/tirx/transform/test_stmt_functor.py:58–224  ·  view source on GitHub ↗

Print TIR AST in structured format.

Source from the content-addressed store, hash-verified

56
57
58class ASTPrinter(StmtVisitor):
59 """Print TIR AST in structured format."""
60
61 def __init__(self) -> None:
62 super().__init__()
63 self.log = ASTLog()
64
65 def visit_bind_(self, op):
66 self.log.add("Bind")
67 self.log.push_scope()
68 self.visit_expr(op.value)
69 self.log.pop_scope()
70
71 def visit_attr_(self, op):
72 self.log.add("AttrStmt")
73 self.log.push_scope()
74 self.visit_expr(op.value)
75 self.visit_stmt(op.body)
76 self.log.pop_scope()
77
78 def visit_assert_(self, op):
79 self.log.add("AssertStmt")
80 self.log.push_scope()
81 self.visit_expr(op.condition)
82 self.visit_expr(op.message)
83 self.visit_stmt(op.body)
84 self.log.pop_scope()
85
86 def visit_for_(self, op):
87 self.log.add("For")
88 self.log.push_scope()
89 self.visit_expr(op.min)
90 self.visit_expr(op.extent)
91 self.visit_stmt(op.body)
92 self.log.pop_scope()
93
94 def visit_while_(self, op):
95 self.log.add("While")
96 self.log.push_scope()
97 self.visit_expr(op.condition)
98 self.visit_stmt(op.body)
99 self.log.pop_scope()
100
101 def visit_buffer_store_(self, op):
102 self.log.add("BufferStore")
103 self.log.push_scope()
104 self.visit_expr(op.value)
105 for index in op.indices:
106 self.visit_expr(index)
107 self.log.pop_scope()
108
109 def visit_seqstmt_(self, op):
110 self.log.add("SeqStmt")
111 self.log.push_scope()
112 for stmt in op.seq:
113 self.visit_stmt(stmt)
114 self.log.pop_scope()
115

Callers 1

basic_checkFunction · 0.70

Calls

no outgoing calls

Tested by 1

basic_checkFunction · 0.56

Used in the wild real call sites across dependent graphs

searching dependent graphs…