gemini-code-assist[bot] commented on PR #18784:
URL: https://github.com/apache/tvm/pull/18784#issuecomment-3904913568

   ## 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 undertakes a significant refactoring effort to modernize 
how metadata is stored and managed within TVM's runtime and codegen components. 
By migrating to FFI-native data structures like `ffi::Array` and `ffi::Map` for 
attributes and function information, the system benefits from improved 
consistency, streamlined data handling, and better integration with the core 
FFI infrastructure. This change impacts various backend codegen and runtime 
modules, ensuring a more robust and future-proof metadata management system.
   
   ### Highlights
   
   * **FFI Container Integration**: The pull request transitions various 
internal metadata structures, including node attributes and function 
information, to utilize TVM's Foreign Function Interface (FFI) containers such 
as `ffi::String`, `ffi::Array`, and `ffi::Map`. This change modernizes data 
storage and conversion mechanisms.
   * **Metadata Refactoring**: The `FunctionInfo` struct has been refactored 
into an `Object` and `ObjectRef` (`FunctionInfoObj` and `FunctionInfo`) to 
align with TVM's object system, and its serialization logic has been updated 
accordingly. The `meta_data.h` header was also renamed to `metadata.h`.
   * **Serialization Updates**: New `Serializer` template specializations were 
added for `ffi::String`, `ffi::Array<T>`, and `ffi::Map<K, V>` to enable 
seamless serialization and deserialization of these FFI types.
   * **Attribute Handling Modernization**: Numerous codegen and runtime files 
were updated to replace legacy `std::vector<std::string>` and 
`std::vector<std::any>` usages for node attributes with the more efficient and 
FFI-compatible `ffi::Array<ffi::String>`.
   
   🧠 **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>
   
   * **include/tvm/support/serializer.h**
       * Added `Serializer` specializations for `ffi::String`, `ffi::Array<T>`, 
and `ffi::Map<K, V>`.
       * Included new FFI container headers.
   * **src/contrib/msc/core/codegen/codegen_json.cc**
       * Updated `AddNodeAttr` to use `ffi::Array<ffi::String>` for node 
attributes.
   * **src/relax/backend/contrib/clml/codegen.cc**
       * Replaced `std::vector<std::string>` and `std::vector<std::any>` with 
`ffi::Array<ffi::String>` for setting node attributes.
   * **src/relax/backend/contrib/codegen_json/codegen_json.h**
       * Modified `OpAttrExtractor` to use `ffi::Array<ffi::String>` for 
`SetNodeAttr` and `ffi::Any` handling.
       * Updated `SetShape` and `SetDType` to directly use internal members.
   * **src/relax/backend/contrib/cublas/codegen.cc**
       * Changed `dq_scale` attribute setting to use `ffi::Array<ffi::String>`.
   * **src/relax/backend/contrib/cudnn/codegen.cc**
       * Updated attribute setting for various parameters to use 
`ffi::Array<ffi::String>`.
   * **src/relax/backend/contrib/nnapi/codegen.cc**
       * Replaced `std::vector<std::any>` with direct `ffi::Array<ffi::String>` 
for several attributes.
   * **src/relax/backend/contrib/tensorrt/codegen.cc**
       * Updated compiler configuration attributes to use 
`ffi::Array<ffi::String>`.
   * **src/relax/backend/vm/codegen_vm.cc**
       * Added `TVM_FFI_UNREACHABLE()` after a fatal log message.
   * **src/runtime/contrib/arm_compute_lib/acl_runtime.cc**
       * Changed `GetAttr` calls to retrieve `ffi::Array<ffi::String>` for 
various attributes.
   * **src/runtime/contrib/bnns/bnns_json_runtime.cc**
       * Updated `GetAttr` calls to retrieve `ffi::Array<ffi::String>` for 
various attributes.
   * **src/runtime/contrib/clml/clml_runtime.cc**
       * Modified `GetAttr` calls to retrieve `ffi::Array<ffi::String>` for 
numerous attributes.
   * **src/runtime/contrib/cublas/cublas_json_runtime.cc**
       * Updated `GetAttr` call for `dq_scale` to retrieve 
`ffi::Array<ffi::String>`.
   * **src/runtime/contrib/cudnn/cudnn_json_runtime.cc**
       * Changed `vstr2vint` and direct `GetAttr` calls to retrieve 
`ffi::Array<ffi::String>` for attributes.
   * **src/runtime/contrib/dnnl/dnnl_json_runtime.cc**
       * Modified `GetNodeAttr` to retrieve `ffi::Array<ffi::String>`.
   * **src/runtime/contrib/json/json_node.h**
       * Changed `JSONGraphAttrs` from `std::unordered_map<std::string, 
std::any>` to `ffi::Map<ffi::String, ffi::Any>`.
       * Removed `std::any` related helper functions.
       * Updated `JSONGraphNode`'s `ToJSON` and `FromJSON` methods for new FFI 
types.
       * Added `SetAttr` overloads for `std::string` and 
`ffi::Array<ffi::String>`.
       * Added `SetShape` and `SetDType` methods.
   * **src/runtime/contrib/msc/tensorrt_runtime.cc**
       * Updated `GetAttr` calls to retrieve `ffi::Array<ffi::String>` for 
global options.
   * **src/runtime/contrib/nnapi/nnapi_ops.cc**
       * Modified `GetAttr` calls to retrieve `ffi::Array<ffi::String>` for 
various attributes.
   * **src/runtime/contrib/tensorrt/tensorrt_ops.cc**
       * Updated `GetAttr` calls to retrieve `ffi::Array<ffi::String>` for 
numerous operator attributes.
   * **src/runtime/contrib/tensorrt/tensorrt_runtime.cc**
       * Changed `GetAttr` calls to retrieve `ffi::Array<ffi::String>` for 
runtime configuration.
   * **src/runtime/cuda/cuda_module.cc**
       * Renamed `meta_data.h` to `metadata.h`.
       * Changed `fmap_` type to `ffi::Map<ffi::String, FunctionInfo>`.
       * Updated `CUDAModuleCreate` and `CUDAModuleLoadFile` signatures.
       * Modified `GetFunction` to use `fmap_.Get` and `FunctionInfo` members 
via `->`.
       * Updated `CUDAModuleLoadFromBytes` to use `ffi::Map` and `ICHECK` for 
stream read.
   * **src/runtime/cuda/cuda_module.h**
       * Renamed `meta_data.h` to `metadata.h`.
       * Updated `CUDAModuleCreate` signature.
   * **src/runtime/file_utils.cc**
       * Removed `std::unordered_map` include.
       * Refactored `FunctionInfo` to `FunctionInfoObj` and `FunctionInfo` 
(ObjectRef).
       * Updated `SaveToJSON` and `LoadFromJSON` to use `ffi::String` and 
`ffi::Array`.
       * Modified `SaveMetaDataToFile` and `LoadMetaDataFromFile` to work with 
`ffi::Map<ffi::String, FunctionInfo>`.
       * Added `TVM_FFI_STATIC_INIT_BLOCK` for `FunctionInfoObj` reflection.
   * **src/runtime/file_utils.h**
       * Renamed `meta_data.h` to `metadata.h`.
       * Updated `SaveMetaDataToFile` and `LoadMetaDataFromFile` signatures.
       * Added `using Stream::Read; using Stream::Write;` to 
`SimpleBinaryFileStream`.
   * **src/runtime/hexagon/hexagon_module.cc**
       * Updated `HexagonModuleNode` constructor and `HexagonModuleCreate` 
signature to use `ffi::Map<ffi::String, FunctionInfo>`.
   * **src/runtime/hexagon/hexagon_module.h**
       * Renamed `meta_data.h` to `metadata.h`.
       * Updated `HexagonModuleCreate` and `HexagonModuleNode` constructor 
signatures.
       * Changed `fmap_` type to `ffi::Map<ffi::String, FunctionInfo>`.
   * **src/runtime/meta_data.h**
       * File renamed to `src/runtime/metadata.h`.
   * **src/runtime/metadata.h**
       * Renamed from `meta_data.h`.
       * Removed `std::unordered_map` include.
       * Refactored `FunctionInfo` into `FunctionInfoObj` (Object) and 
`FunctionInfo` (ObjectRef).
       * Updated `SaveToJSON` and `LoadFromJSON` methods.
       * Updated `Serializer` specialization for `runtime::FunctionInfo` to 
handle new FFI types.
   * **src/runtime/metal/metal_module.h**
       * Renamed `meta_data.h` to `metadata.h`.
       * Updated `MetalModuleCreate` signature.
   * **src/runtime/metal/metal_module.mm**
       * Renamed `meta_data.h` to `metadata.h`.
       * Updated `MetalModuleNode` constructor and `fmap_` type.
       * Modified `MetalWrappedFunc::Init` and `MetalModuleNode::GetFunction` 
to use `ffi::Array<ffi::String>` and `ffi::Map::Get`.
       * Updated `MetalModuleCreate` and `MetalModuleLoadFromBytes` to use 
`ffi::Map`.
   * **src/runtime/opencl/opencl_common.h**
       * Renamed `meta_data.h` to `metadata.h`.
       * Updated `OpenCLModuleNodeBase` constructor and `fmap_` type.
       * Updated `OpenCLModuleNode` constructor.
   * **src/runtime/opencl/opencl_module.cc**
       * Removed `std::unordered_map` include.
       * Updated `OpenCLWrappedFunc::Init` to use `ffi::Array<ffi::String>`.
       * Modified `OpenCLModuleNodeBase::GetFunction` to use `fmap_.Get` and 
`FunctionInfo` members via `->`.
       * Updated `OpenCLModuleCreate` and `OpenCLModuleLoadFile` signatures.
       * Updated `OpenCLModuleLoadFromBytes` to use `ffi::Map` and `ICHECK` for 
stream read.
   * **src/runtime/opencl/opencl_module.h**
       * Renamed `meta_data.h` to `metadata.h`.
       * Updated `OpenCLModuleCreate` signatures.
   * **src/runtime/opencl/opencl_module_spirv.cc**
       * Removed `std::unordered_map` include.
       * Updated `OpenCLSPIRVModuleNode` constructor and `OpenCLModuleCreate` 
signature to use `ffi::Map<ffi::String, FunctionInfo>`.
   * **src/runtime/pack_args.h**
       * Included `metadata.h`.
       * Updated `PackFuncVoidAddr`, `PackFuncNonBufferArg`, 
`PackFuncPackedArgAligned`, and `NumBufferArgs` signatures to use `ffi::Array` 
and `ArgExtraTags`.
   * **src/runtime/rocm/rocm_module.cc**
       * Renamed `meta_data.h` to `metadata.h`.
       * Updated `ROCMModuleNode` constructor and `fmap_` type.
       * Modified `ROCMWrappedFunc::Init` and `ROCMModuleNode::GetFunction` to 
use `ffi::Array<ffi::String>` and `ffi::Map::Get`.
       * Updated `ROCMModuleCreate` and `ROCMModuleLoadFile` signatures.
       * Updated `ROCMModuleLoadFromBytes` to use `ffi::Map` and `ICHECK` for 
stream read.
   * **src/runtime/rocm/rocm_module.h**
       * Renamed `meta_data.h` to `metadata.h`.
       * Updated `ROCMModuleCreate` signature.
   * **src/runtime/thread_storage_scope.h**
       * Renamed `meta_data.h` to `metadata.h`.
       * Updated `LaunchParamConfig::Init` to use `ffi::Array<ffi::String>`.
   * **src/runtime/vulkan/vulkan_module.cc**
       * Updated `VulkanModuleCreate` and `VulkanModuleLoadFile` signatures to 
use `ffi::Map<ffi::String, FunctionInfo>`.
       * Updated `VulkanModuleLoadFromBytes` to use `ffi::Map` and `ICHECK` for 
stream read.
   * **src/runtime/vulkan/vulkan_module.h**
       * Renamed `meta_data.h` to `metadata.h`.
       * Updated `VulkanModuleCreate` signature.
   * **src/runtime/vulkan/vulkan_wrapped_func.cc**
       * Modified `VulkanWrappedFunc::Init` and `VulkanModuleNode::GetFunction` 
to use `ffi::Array<ffi::String>` and `ffi::Map::Get`.
       * Updated `VulkanModuleNode::GetPipeline` to use `fmap_.Get` and access 
`FunctionInfo` members via `->`.
   * **src/runtime/vulkan/vulkan_wrapped_func.h**
       * Renamed `meta_data.h` to `metadata.h`.
       * Updated `VulkanWrappedFunc::Init` and `VulkanModuleNode` constructor 
signatures.
       * Changed `fmap_` type to `ffi::Map<ffi::String, FunctionInfo>`.
   * **src/target/build_common.h**
       * Included `tvm/ffi/container/map.h`.
       * Updated `ExtractFuncInfo` to return `ffi::Map<ffi::String, 
runtime::FunctionInfo>` and construct `runtime::FunctionInfo` using the new 
ObjectRef constructor.
   * **src/target/opt/build_cuda_off.cc**
       * Updated `CUDAModuleCreate` signature to use `ffi::Map<ffi::String, 
FunctionInfo>`.
   * **src/target/opt/build_hexagon_off.cc**
       * Updated `HexagonModuleCreate` signature to use `ffi::Map<ffi::String, 
FunctionInfo>`.
   * **src/target/opt/build_metal_off.cc**
       * Updated `MetalModuleCreate` signature to use `ffi::Map<ffi::String, 
FunctionInfo>`.
   * **src/target/opt/build_opencl_off.cc**
       * Updated `OpenCLModuleCreate` signatures to use `ffi::Map<ffi::String, 
FunctionInfo>`.
   * **src/target/opt/build_rocm_off.cc**
       * Updated `ROCMModuleCreate` signature to use `ffi::Map<ffi::String, 
FunctionInfo>`.
   * **src/target/source/codegen_source_base.h**
       * Renamed `meta_data.h` to `metadata.h`.
       * Updated `DeviceSourceModuleCreate` signature.
   * **src/target/source/codegen_webgpu.cc**
       * Removed `std::unordered_map` include.
       * Included `runtime/file_utils.h` and `runtime/metadata.h`.
       * Modified `CodeGenWebGPU::AddFunction` to construct 
`runtime::FunctionInfo` using the new ObjectRef constructor and use 
`ffi::Array` for `arg_types` and `launch_param_tags`.
       * Updated `WebGPUSourceModuleNode` constructor and `InspectSource` to 
use `ffi::Map` and access `FunctionInfo` members via `->`.
       * Updated `BuildWebGPU` to use `ffi::Map`.
   * **src/target/source/source_module.cc**
       * Removed `std::unordered_map` include.
       * Updated `DeviceSourceModuleNode` constructor and `fmap_` type.
       * Updated `DeviceSourceModuleCreate` signature.
   * **web/emcc/webgpu_runtime.cc**
       * Included `runtime/file_utils.h` and `runtime/metadata.h`.
       * Updated `WebGPUModuleNode` constructor and `fmap_` type.
       * Modified `GetFunction` and `InspectSource` to use `ffi::Map` and 
access `FunctionInfo` members via `->`.
       * Updated `WebGPUModuleLoadFromBytes` to use `ffi::Map` and `ICHECK` for 
stream read.
   </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]

Reply via email to