catalyst.disable_autograph¶
- disable_autograph = DisableAutograph[status=Status.DISABLED, options=None]¶
Context decorator that disables AutoGraph for the given function/context.
Note
A singleton instance is used for discarding parentheses usage:
@disable_autograph instead of @DisableAutograph()
with disable_autograph: instead of with DisableAutograph()
Example 1: as a function decorator
@disable_autograph def f(): x = 6 if x > 5: y = x ** 2 else: y = x ** 3 return y @qjit(autograph=True) def g(x: float, n: int): for _ in range(n): x = x + f() return x
>>> print(g(0.4, 6)) 216.4
Example 2: as a context manager
def f(): x = 6 if x > 5: y = x ** 2 else: y = x ** 3 return y @qjit(autograph=True) def g(): x = 0.4 with disable_autograph: x += f() return x
>>> print(g()) 36.4
code/api/catalyst.disable_autograph
Download Python script
Download Notebook
View on GitHub