slyubomirsky opened a new pull request, #15109: URL: https://github.com/apache/tvm/pull/15109
This PR implements the suggestion proposed in #14899 and allows function purity to be annotated in the `@R.function` decorator instead of using a fake method call (`R.is_pure()` or `R.is_impure()`). This required various changes to the parser to support, but can be used as a template for adding further optional parameters to `@R.function`. For example, this is how an impure function can be declared: ```python @R.function(pure=False) def f(...): ... ``` The default value of `pure` is `True`, so there is no need to include an annotation for a function that is already pure (which will usually be the case in Relax). Note that it will also still be valid to use the decorator without any arguments, as here: ```python @R.function def f(...): ... # f will be treated as pure ``` See `entry.py` for how the `function` decorator has been modified to support this. Many thanks to @junrushao for guiding me through some of the moving parts in the parser. Further thanks is due to @tqchen, as he showed how the convenient decorator interface in the discussion for #14899. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
