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

Function is_called

python/tvm/relax/script/parser/parser.py:124–145  ·  view source on GitHub ↗
(node: Any, func_name: str)

Source from the content-addressed store, hash-verified

122
123
124def is_called(node: Any, func_name: str) -> bool:
125 # Check if it calls into a func
126 if isinstance(node, doc.Call):
127 # Recursive call was found
128 if isinstance(node.func, doc.Name) and node.func.id == func_name:
129 return True
130 elif isinstance(node, list | tuple):
131 for stmt in node:
132 if is_called(stmt, func_name):
133 return True
134 elif isinstance(node, doc.AnnAssign | doc.Assign | doc.Return | doc.Expr):
135 return is_called(node.value, func_name)
136 elif isinstance(node, doc.With):
137 return is_called(node.body, func_name)
138 elif isinstance(node, doc.If):
139 smts = []
140 if node.body is not None:
141 smts = smts + list(node.body)
142 if node.orelse is not None:
143 smts = smts + list(node.orelse)
144 return is_called(smts, func_name)
145 return False
146
147
148def is_recursive(node: doc.FunctionDef) -> bool:

Callers 1

is_recursiveFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…