gemini-code-assist[bot] commented on PR #18785:
URL: https://github.com/apache/tvm/pull/18785#issuecomment-3908804380
## Summary of Changes
Hello @tqchen, 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 target configuration mechanism within the
system, moving from a legacy string-based format to a more robust and
extensible JSON dictionary format. This change streamlines the handling of
diverse target specifications, improves code maintainability by centralizing
configuration parsing, and sets the foundation for more advanced target
features. The update impacts various components, including RPC tests,
documentation, Python utilities, and core C++ target parsing logic, ensuring a
consistent and modern approach to target definition throughout the project.
### Highlights
* **Target String Format Transition**: The core change involves phasing out
the legacy string-based target format (e.g., 'llvm -mtriple=...') in favor of a
more structured JSON dictionary representation (e.g., '{"kind": "llvm",
"mtriple": "..."}'). This enhances clarity and simplifies parsing of target
configurations.
* **API Updates for Target Configuration**: Numerous Python and C++ files
have been updated to reflect the new JSON target format. This includes changes
in how targets are defined, parsed, and passed to various TVM functions and
testing utilities, ensuring consistency across the codebase.
* **Removal of Legacy String Parsing Logic**: The underlying C++
implementation for target parsing has been refactored, removing complex string
interpretation and splitting logic. The system now directly leverages JSON
parsing for target configurations, making the code cleaner and less error-prone.
* **Improved Test Coverage and Clarity**: Existing tests have been updated
to use the new JSON target format, and new tests have been added to explicitly
validate the JSON parsing and reject the old CLI string format, reinforcing the
transition and preventing regressions.
🧠**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>
* **apps/android_rpc/tests/android_rpc_test.py**
* Updated target configuration from string to JSON dictionary format.
* **apps/ios_rpc/tests/ios_rpc_test.py**
* Updated target configuration from string to JSON dictionary format.
* **docs/how_to/tutorials/cross_compilation_and_rpc.py**
* Updated target string examples and assignments to use JSON dictionary
format.
* **docs/how_to/tutorials/export_and_load_executable.py**
* Updated target string to JSON dictionary format.
* **include/tvm/target/target.h**
* Updated documentation for the `str()` method to reflect JSON string
representation.
* **python/tvm/contrib/hexagon/pytest_plugin.py**
* Fixed docstring formatting.
* Updated `HEXAGON_AOT_LLVM_TARGET` from string to JSON dictionary.
* Modified `aot_target` function to handle dictionary-based target
configurations.
* **python/tvm/exec/gpu_memory_bandwidth.py**
* Updated `target_host` example string to JSON dictionary format.
* **python/tvm/relax/frontend/torch/dynamo.py**
* Updated `AVX512_TARGET` and `AVX2_TARGET` from strings to JSON
dictionaries.
* **python/tvm/relax/pipeline.py**
* Updated target configuration in example to JSON dictionary format.
* **python/tvm/runtime/module.py**
* Imported the `json` module.
* Renamed `llvm_target_string` to `llvm_target` and updated its usage to
handle JSON.
* Added a check for `target.kind` attribute in `enabled` function to
support new target object.
* **python/tvm/s_tir/dlight/benchmark/bench.py**
* Refactored `f_preproc` assignment for better readability.
* Updated `target` type hint and default value in `benchmark_relax_func`
to support dictionary targets.
* **python/tvm/s_tir/meta_schedule/testing/validate_database.py**
* Updated `baseline-target` default value to JSON dictionary format.
* **python/tvm/target/target.py**
* Removed redundant `json` import.
* Removed deprecated `mkldnn` warning logic.
* Removed `_merge_opts` helper function.
* Refactored target creation functions (`cuda`, `rocm`, `mali`,
`intel_graphics`, `arm_cpu`, `bifrost`, `riscv_cpu`, `stm32`, `adreno`) to
construct and return JSON dictionary targets.
* Added `_parse_cli_opts_to_dict` helper to convert CLI-style options to
dictionary format.
* Removed `_load_config_dict` global function registration.
* **python/tvm/testing/plugin.py**
* Updated `enabled_targets` print statement to correctly handle
dictionary targets.
* Modified `dev` fixture to extract target kind from dictionary targets.
* Adjusted `update_parametrize_target_arg` to handle target kind
extraction from dictionary targets.
* Updated `_target_to_requirement` to accept both string and dictionary
targets.
* **python/tvm/testing/utils.py**
* Updated `_get_targets` to extract target kind from dictionary targets.
* Modified default `TVM_TEST_TARGETS` list to include JSON dictionary
formats.
* Adjusted `device_enabled` to correctly process dictionary targets.
* Updated `enabled_targets` to pass the correct target kind to
`tvm.device`.
* Modified `_compile_only_marks` to handle dictionary targets.
* Updated `_has_cpu_feat` to use JSON dictionary for target
configuration.
* **src/target/llvm/llvm_instance.cc**
* Included `tvm/ffi/extra/json.h` for JSON serialization.
* Modified `LLVMTargetInfo::str()` to output target configuration as a
JSON string.
* Updated `LLVMTarget::GetTargetMetadata` to return target metadata in
JSON format, supporting both new and legacy formats.
* **src/target/target.cc**
* Included `tvm/ffi/extra/json.h` for JSON parsing.
* Removed several legacy string parsing and manipulation helper
functions.
* Simplified `TargetNode::str()` to use JSON stringification.
* Modified `TargetInternal::FromString` to reject legacy CLI string
format and enforce JSON dictionary or bare kind name.
* Updated `TargetInternal::FromConfigString` to use `ffi::json::Parse`
for configuration parsing.
* Removed `TargetInternal::FromRawString` and
`TargetInternal::ParseType` for string inputs.
* **tests/cpp/target/virtual_device_test.cc**
* Updated target string in `EXPECT_NE` assertion to use JSON dictionary
format.
* **tests/cpp/target_test.cc**
* Updated target strings in `TargetCreation` tests to use JSON
dictionary format.
* **tests/python/arith/test_arith_rewrite_simplify.py**
* Updated target string to JSON dictionary format.
* **tests/python/arith/test_arith_simplify.py**
* Updated target strings to JSON dictionary format in tests.
* **tests/python/codegen/test_target_codegen.py**
* Updated `parametrize_targets` to use JSON dictionary for Vulkan target.
* **tests/python/codegen/test_target_codegen_aarch64.py**
* Updated target strings to JSON dictionary format in various tests.
* **tests/python/codegen/test_target_codegen_arm.py**
* Updated target strings to JSON dictionary format in tests.
* **tests/python/codegen/test_target_codegen_cross_llvm.py**
* Updated target string to JSON dictionary and adjusted
`tvm.runtime.enabled` check.
* **tests/python/codegen/test_target_codegen_device.py**
* Modified `check_target` to handle dictionary targets and updated
Vulkan target to JSON dictionary.
* **tests/python/codegen/test_target_codegen_gpu_common.py**
* Updated `parametrize_targets` to use JSON dictionary for Vulkan target.
* **tests/python/codegen/test_target_codegen_llvm.py**
* Updated target strings to JSON dictionary format in tests.
* **tests/python/codegen/test_target_codegen_llvm_vla.py**
* Updated target strings to JSON dictionary format in
`parametrize_targets`.
* **tests/python/codegen/test_target_codegen_opencl.py**
* Updated `parametrize_targets` to use JSON dictionary for Adreno target.
* Modified `_check` function to extract device information from the new
Target object structure.
* **tests/python/codegen/test_target_codegen_riscv.py**
* Updated target strings to JSON dictionary format in
`parametrize_targets`.
* **tests/python/codegen/test_target_codegen_vulkan.py**
* Updated target strings to JSON dictionary format in
`parametrize_targets`.
* **tests/python/codegen/test_target_codegen_x86.py**
* Updated target strings to JSON dictionary format in tests.
* **tests/python/contrib/test_android/infrastructure.py**
* Updated `target_h` string to JSON dictionary format.
* **tests/python/nightly/test_nnapi/infrastructure.py**
* Updated target string to JSON dictionary format.
* **tests/python/relax/adreno/test_transform_annotate_custom_scope.py**
* Updated target string to JSON dictionary format.
* **tests/python/relax/backend/clml/conftest.py**
* Updated `target_host` string to JSON dictionary format.
* **tests/python/relax/backend/clml/utils.py**
* Updated `target_host` string to JSON dictionary format.
* **tests/python/relax/test_backend_dispatch_sort_scan.py**
* Updated target strings to JSON dictionary format in tests.
* **tests/python/relax/test_frontend_nn_op.py**
* Updated target strings to JSON dictionary format in tests.
* **tests/python/relax/test_meta_schedule_relax_integration.py**
* Updated target string to JSON dictionary format.
* **tests/python/relax/test_transform_few_shot_tuning.py**
* Updated target string to JSON dictionary format.
* **tests/python/relax/test_transform_meta_schedule_apply_database.py**
* Updated target string to JSON dictionary format.
* **tests/python/relax/test_transform_meta_schedule_tuning.py**
* Updated target string to JSON dictionary format.
* **tests/python/relax/test_transform_realize_vdevice.py**
* Updated `VDevice` creation with JSON dictionary targets.
* **tests/python/relax/test_transform_update_vdevice.py**
* Updated `VDevice` creation with JSON dictionary targets.
* **tests/python/relax/test_tvmscript_parser.py**
* Updated `VDevice` creation with JSON dictionary targets.
* Fixed minor formatting in `outer_func` definition.
* **tests/python/relax/texture/adreno_utils.py**
* Updated target string to JSON dictionary format.
* **tests/python/relax/texture/test_texture_nd.py**
* Updated target strings to JSON dictionary format.
* **tests/python/runtime/test_runtime_module_load.py**
* Updated target string to JSON dictionary format.
* **tests/python/runtime/test_runtime_rpc.py**
* Updated target string to JSON dictionary format.
* Explicitly created `tvm.target.Target` object in `tvm.compile` call.
* **tests/python/s_tir/dlight/test_benchmark.py**
* Updated target strings to JSON dictionary format in tests.
* **tests/python/s_tir/dlight/test_gpu_gemv.py**
* Updated target strings to JSON dictionary format in tests.
* **tests/python/s_tir/dlight/test_gpu_matmul.py**
* Updated target strings to JSON dictionary format in tests.
* **tests/python/s_tir/meta_schedule/test_meta_schedule_cost_model.py**
* Updated target string to JSON dictionary format.
* **tests/python/s_tir/meta_schedule/test_meta_schedule_measure_callback.py**
* Updated target strings to JSON dictionary format.
*
**tests/python/s_tir/meta_schedule/test_meta_schedule_mutator_mutate_parallel.py**
* Updated target string to JSON dictionary format.
*
**tests/python/s_tir/meta_schedule/test_meta_schedule_mutator_mutate_tile_size.py**
* Updated target strings to JSON dictionary format.
*
**tests/python/s_tir/meta_schedule/test_meta_schedule_mutator_mutate_unroll.py**
* Updated target string to JSON dictionary format.
* **tests/python/s_tir/meta_schedule/test_meta_schedule_post_order_apply.py**
* Updated target strings to JSON dictionary format in tests.
*
**tests/python/s_tir/meta_schedule/test_meta_schedule_postproc_rewrite_tensorize.py**
* Updated target string to JSON dictionary format.
*
**tests/python/s_tir/meta_schedule/test_meta_schedule_postproc_rewrite_unbound_block.py**
* Updated target string to JSON dictionary format.
*
**tests/python/s_tir/meta_schedule/test_meta_schedule_schedule_rule_add_rfactor.py**
* Updated target strings to JSON dictionary format.
*
**tests/python/s_tir/meta_schedule/test_meta_schedule_schedule_rule_apply_custom_rule.py**
* Updated target string to JSON dictionary format.
*
**tests/python/s_tir/meta_schedule/test_meta_schedule_schedule_rule_mlt_intrin.py**
* Updated target strings to JSON dictionary format in tests.
*
**tests/python/s_tir/meta_schedule/test_meta_schedule_schedule_rule_mlt_tc.py**
* Updated target strings to JSON dictionary format in tests.
*
**tests/python/s_tir/meta_schedule/test_meta_schedule_schedule_rule_parallel_vectorize_unroll.py**
* Updated target strings to JSON dictionary format.
* **tests/python/s_tir/meta_schedule/test_meta_schedule_space_post_opt.py**
* Updated target string to JSON dictionary format.
* **tests/python/s_tir/meta_schedule/test_meta_schedule_trace_apply.py**
* Updated target string to JSON dictionary format.
* **tests/python/s_tir/meta_schedule/test_meta_schedule_tune_tir.py**
* Updated target strings to JSON dictionary format.
* **tests/python/s_tir/schedule/test_tir_schedule_split_fuse.py**
* Updated target strings to JSON dictionary format in tests.
* **tests/python/target/test_arm_target.py**
* Updated target strings to JSON dictionary format in
`tvm.testing.parameters`.
* **tests/python/target/test_llvm_features_info.py**
* Updated target strings to JSON dictionary format in tests.
* **tests/python/target/test_riscv_features.py**
* Updated target strings to JSON dictionary format in
`tvm.testing.parameters`.
* **tests/python/target/test_target_parser_mprofile.py**
* Updated target strings to JSON dictionary format in tests.
* **tests/python/target/test_target_target.py**
* Updated target strings to JSON dictionary format in tests.
* Added new tests for JSON roundtrip and explicit rejection of CLI
string format.
* **tests/python/target/test_x86_features.py**
* Updated target strings to JSON dictionary format in
`tvm.testing.parameters`.
* **tests/python/testing/test_tvm_testing_features.py**
* Updated sorting key for targets to handle JSON dictionary format.
* Adjusted logic in `test_exclude_target` and
`test_all_nonexcluded_targets_ran` to correctly process dictionary targets.
* **tests/python/tir-base/test_tir_intrin.py**
* Updated target string to JSON dictionary format.
* **tests/python/tir-transform/test_tir_transform_helpers.py**
* Updated target strings to JSON dictionary format in tests.
* **tests/python/tir-transform/test_tir_transform_split_host_device.py**
* Updated target strings to JSON dictionary format in tests.
* **tests/python/tir-transform/test_tir_transform_vectorize.py**
* Updated target strings to JSON dictionary format.
* Modified error message check to be more general for target string
format.
* **tests/scripts/task_python_integration_gpuonly.sh**
* Updated `TVM_TEST_TARGETS` and `TVM_RELAY_OPENCL_TEXTURE_TARGETS`
environment variables to use JSON format.
* **tests/scripts/task_python_unittest_gpuonly.sh**
* Updated `TVM_TEST_TARGETS` environment variable to use JSON format.
* **web/tests/python/prepare_test_libs.py**
* Updated target strings to JSON dictionary format.
* **web/tests/python/relax_rpc_test.py**
* Updated target string to JSON dictionary format.
* **web/tests/python/webgpu_rpc_test.py**
* Updated target string to JSON dictionary format.
</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]