gemini-code-assist[bot] commented on PR #18847: URL: https://github.com/apache/tvm/pull/18847#issuecomment-3977138611
## Summary of Changes Hello, I'm Gemini Code Assist[^1]! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request refactors the argument conversion strategy within the Relax framework. It addresses compatibility issues with Python's PEP 563 for type annotations and transitions from an implicit auto-conversion decorator to explicit conversion calls. This change improves the clarity and maintainability of the code by making argument type handling more direct, while also streamlining the type-checking process. ### Highlights * **PEP 563 Compatibility**: The `type_checked` decorator has been updated to correctly resolve PEP 563 string annotations using `typing.get_type_hints`, ensuring better compatibility with postponed evaluation of type annotations. * **Removal of `args_converter.auto`**: The implicit argument auto-conversion mechanism provided by the `args_converter.auto` decorator has been removed. This includes the deletion of the `type_converter.py` module and its associated test file. * **Explicit Argument Conversion**: All call sites that previously relied on `args_converter.auto` for implicit conversion of Python primitives to Relax `Expr` types now explicitly use `convert_to_expr` or similar logic to perform these conversions, making the conversion process more transparent and controlled. 🧠**New Feature in Public Preview:** You can now enable **Memory** to help **Gemini Code Assist** learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. **Click [here](https://codeassist.google/code-review/login) to enable Memory in your admin console.** <details> <summary><b>Changelog</b></summary> * **python/tvm/relax/__init__.py** * Removed import of `args_converter`. * **python/tvm/relax/op/base.py** * Replaced import of `args_converter` with `convert_to_expr`. * Removed `@args_converter.auto` decorator from `call_tir`, `call_tir_with_grad`, `call_tir_inplace`, `call_dps_packed`, `call_py_func`, `call_builtin_with_ctx`, `make_closure`, `invoke_closure`, `call_inplace_packed`, `call_pure_packed`, and `invoke_pure_closure` functions. * Introduced explicit calls to `_wrap_inline_arg_tuple` and `convert_to_expr` for argument handling in various functions. * **python/tvm/relax/op/builtin/builtin.py** * Replaced import of `args_converter` with `convert_to_expr`. * Removed `@args_converter.auto` decorator from `alloc_tensor`. * Added explicit `convert_to_expr` call for the `shape` argument in `alloc_tensor`. * **python/tvm/relax/op/distributed/distributed.py** * Removed import of `args_converter`. * Removed `@args_converter.auto` decorator from `call_tir_local_view`. * Modified `call_tir_local_view` to explicitly handle `tuple` or `list` arguments by wrapping them in `RxTuple`. * **python/tvm/relax/op/index.py** * Replaced import of `args_converter` with `convert_to_expr`. * Removed `@args_converter.auto` decorator from `strided_slice`. * Added explicit `convert_to_expr` calls for `axes`, `begin`, `end`, and `strides` arguments in `strided_slice`. * **python/tvm/relax/op/memory/memory.py** * Replaced import of `args_converter` with `convert_to_expr`. * Removed `@args_converter.auto` decorator from `alloc_storage`, `alloc_tensor`, `kill_storage`, and `kill_tensor`. * Added explicit `convert_to_expr` calls for `size` in `alloc_storage` and `shape` in `alloc_tensor`. * **python/tvm/relax/op/sampling.py** * Removed import of `args_converter`. * Removed `@args_converter.auto` decorator from `multinomial_from_uniform`. * **python/tvm/relax/op/unary.py** * Replaced import of `args_converter` with `convert_to_expr`. * Removed `@args_converter.auto` decorator from `clip`. * Added explicit `convert_to_expr` calls for `min` and `max` arguments in `clip`. * **python/tvm/relax/op/vm/vm.py** * Replaced import of `args_converter` with `convert_to_expr`. * Removed `@args_converter.auto` decorator from `alloc_storage`, `alloc_tensor`, and `call_tir_dyn`. * Added explicit `convert_to_expr` calls for `shape` in `alloc_storage` and `alloc_tensor`, and for `func` in `call_tir_dyn`. * **python/tvm/relax/type_converter.py** * Removed the entire file, which contained the `_ArgsConverter` class and `args_converter` utility. * **python/tvm/relax/utils.py** * Removed import and re-export of `args_converter`. * **python/tvm/s_tir/schedule/_type_checker.py** * Modified `type_checked` decorator to use `typing.get_type_hints` for resolving type annotations, improving PEP 563 compatibility. * **python/tvm/script/ir_builder/relax/distributed/ir.py** * Removed import of `args_converter`. * Removed `@args_converter.auto` decorator from `call_tir`. * Modified `call_tir` to explicitly handle `tuple` or `list` arguments by wrapping them in `RxTuple`. * **python/tvm/script/ir_builder/relax/ir.py** * Replaced import of `args_converter` with `convert_to_expr`. * Added `_CONVERTIBLE_TYPES` constant for clarity in type checking. * Removed `@args_converter.auto` decorator from `call_packed` and `call_py_func`. * Added explicit `convert_to_expr` calls for `args` in `call_packed` and `call_py_func`. * **tests/python/relax/test_expr_args_converter.py** * Removed the entire test file, as the `args_converter` utility it tested has been removed. </details> <details> <summary><b>Using Gemini Code Assist</b></summary> <br> The full guide for Gemini Code Assist can be found on our [documentation page](https://developers.google.com/gemini-code-assist/docs/review-github-code), here are some quick tips. <b>Invoking Gemini</b> You can request assistance from Gemini at any point by creating a comment using either `/gemini <command>` or `@gemini-code-assist <command>`. Below is a summary of the supported commands on the current page. Feature | Command | Description --- | --- | --- Code Review | `/gemini review` | Performs a code review for the current pull request in its current state. Pull Request Summary | `/gemini summary` | Provides a summary of the current pull request in its current state. Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in pull request comments and review comments. Help | `/gemini help` | Displays a list of available commands. <b>Customization</b> To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a `.gemini/` folder in the base of the repository. Detailed instructions can be found [here](https://developers.google.com/gemini-code-assist/docs/customize-gemini-behavior-github). <b>Limitations & Feedback</b> Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with :thumbsup: and :thumbsdown: on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up [here](https://google.qualtrics.com/jfe/form/SV_2cyuGuTWsEw84yG). <b>You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the [Gemini Code Assist IDE Extension](https://cloud.google.com/products/gemini/code-assist).</b> </details> [^1]: Review the [Privacy Notices](https://policies.google.com/privacy), [Generative AI Prohibited Use Policy](https://policies.google.com/terms/generative-ai/use-policy), [Terms of Service](https://policies.google.com/terms), and learn how to configure Gemini Code Assist in GitHub [here](https://developers.google.com/gemini-code-assist/docs/customize-gemini-behavior-github). Gemini can make mistakes, so double check it and [use code with caution](https://support.google.com/legal/answer/13505487). -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
