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

Function function

python/tvm/relax/script/parser/entry.py:53–77  ·  view source on GitHub ↗
(
    f: FType | None = None, pure: bool = True, private: bool = False, check_well_formed=True
)

Source from the content-addressed store, hash-verified

51# appear as a decorator by itself or to have optional arguments
52# like @R.function(pure=False)
53def function(
54 f: FType | None = None, pure: bool = True, private: bool = False, check_well_formed=True
55) -> Function | FType:
56 # pylint: disable=unused-argument
57 # (pure and private aren't used here, but are used later in parsing)
58
59 # need to inspect the stack first because is_defined_in_class expects the outer class
60 # to be in a particular position in the stack
61 orig_stack = inspect.stack()
62
63 def decorator_wrapper(f):
64 if not inspect.isfunction(f):
65 raise TypeError(f"Expect a function, but got: {f}")
66 if utils.is_defined_in_class(orig_stack, f):
67 return f
68 return parse(f, utils.inspect_function_capture(f), check_well_formed=check_well_formed)
69
70 if f is not None:
71 # if there are no optional args given, this will directly invoke the wrapper
72 return decorator_wrapper(f)
73 else:
74 # if there is a optional arg given, it returns the wrapper function
75 # as a new decorator and applies it
76 setattr(decorator_wrapper, "dispatch_token", "relax")
77 return decorator_wrapper
78
79
80setattr(function, "dispatch_token", "relax")

Callers

nothing calls this directly

Calls 1

decorator_wrapperFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…