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

Function find_decorator_annotation

python/tvm/tirx/script/parser/parser.py:240–252  ·  view source on GitHub ↗

Check the value of given annotation (argument name) in the prim_func decorator. Returns the value of the annotation if present, otherwise giving the default value.

(node: doc.FunctionDef, annotation: str, default: bool = True)

Source from the content-addressed store, hash-verified

238
239
240def find_decorator_annotation(node: doc.FunctionDef, annotation: str, default: bool = True) -> bool:
241 """
242 Check the value of given annotation (argument name) in the prim_func decorator.
243 Returns the value of the annotation if present, otherwise giving the default value.
244 """
245 # look for the named argument in the prim_func / jit decorator
246 for dec in node.decorator_list:
247 if not isinstance(dec, doc.Call) or dec.func.attr not in ("prim_func", "jit"):
248 continue
249 for keyword in dec.keywords:
250 if keyword.arg == annotation:
251 return keyword.value.value
252 return default
253
254
255@dispatch.register(token="tirx", type_name="For")

Callers 1

visit_function_defFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…