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

Function _check_base_py_module_inheritance

python/tvm/script/parser/ir/parser.py:180–212  ·  view source on GitHub ↗

Check if a class inherits from BasePyModule. Parameters ---------- node : doc.ClassDef The class definition node to check. Returns ------- bool True if the class inherits from BasePyModule, False otherwise.

(node: doc.ClassDef)

Source from the content-addressed store, hash-verified

178
179
180def _check_base_py_module_inheritance(node: doc.ClassDef) -> bool:
181 """Check if a class inherits from BasePyModule.
182
183 Parameters
184 ----------
185 node : doc.ClassDef
186 The class definition node to check.
187
188 Returns
189 -------
190 bool
191 True if the class inherits from BasePyModule, False otherwise.
192 """
193 if not node.bases:
194 return False
195
196 # Check each base class
197 for base in node.bases:
198 if hasattr(base, "id"):
199 if base.id == "BasePyModule":
200 return True
201 elif hasattr(base, "attr"):
202 if base.attr == "BasePyModule":
203 return True
204 elif hasattr(base, "value") and hasattr(base.value, "id"):
205 if (
206 base.value.id in ["BasePyModule", "tvm", "relax"]
207 and hasattr(base, "attr")
208 and base.attr == "BasePyModule"
209 ):
210 return True
211
212 return False

Callers 1

_visit_class_defFunction · 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…