gemini-code-assist[bot] commented on code in PR #19614:
URL: https://github.com/apache/tvm/pull/19614#discussion_r3305043185


##########
src/relax/backend/contrib/tensorrt/codegen.cc:
##########
@@ -255,7 +255,7 @@ inline constexpr bool IsTensorRTRuntimeEnabled() {
  * \return Array of three integers for major, minor, and patch, or empty array 
if TensorRT graph
  * runtime is not enabled.
  */
-ffi::Array<Integer> GetTensorRTVersion() {
+ffi::Array<int64_t> GetTensorRTVersion() {

Review Comment:
   ![critical](https://www.gstatic.com/codereviewagent/critical.svg)
   
   The return type of `GetTensorRTVersion` has been updated to 
`ffi::Array<int64_t>`, but the return statement inside the function (on line 
260) still returns `Integer` wrappers (e.g., `Integer(NV_TENSORRT_MAJOR)`). 
This will cause a compilation error. Please update the return statement to use 
primitive `int64_t` values.



##########
src/arith/scalable_expression.cc:
##########
@@ -93,7 +93,7 @@ bool TargetHasVLA(ffi::Optional<Target> target) {
   bool has_vla{false};
   if (target.defined()) {
     // aarch64
-    has_vla = 
Downcast<Target>(target)->GetAttr<Bool>("feature.has_sve").value_or(Bool(false));
+    has_vla = 
Downcast<Target>(target)->GetAttr<bool>("feature.has_sve").value_or(Bool(false));

Review Comment:
   ![high](https://www.gstatic.com/codereviewagent/high-priority.svg)
   
   The default value passed to `value_or` is `Bool(false)`, which is an 
`ObjectRef` wrapper. Since the template parameter is `bool`, it should be 
simplified to the primitive `false` literal.
   
   ```suggestion
       has_vla = 
Downcast<Target>(target)->GetAttr<bool>("feature.has_sve").value_or(false);
   ```



##########
src/target/webgpu/codegen_webgpu.cc:
##########
@@ -126,7 +126,7 @@ void CodeGenWebGPU::InitFuncState(const PrimFunc& f) {
 }
 
 CodeGenWebGPU::CodeGenWebGPU(Target target) : target_(target) {
-  enable_subgroups_ = 
target_->GetAttr<Bool>("supports_subgroups").value_or(Bool(false));
+  enable_subgroups_ = 
target_->GetAttr<bool>("supports_subgroups").value_or(Bool(false));

Review Comment:
   ![high](https://www.gstatic.com/codereviewagent/high-priority.svg)
   
   The default value passed to `value_or` is `Bool(false)`, which is an 
`ObjectRef` wrapper. Since the template parameter is `bool`, it should be 
simplified to the primitive `false` literal.
   
   ```suggestion
     enable_subgroups_ = 
target_->GetAttr<bool>("supports_subgroups").value_or(false);
   ```



##########
src/target/vulkan/spirv_support.cc:
##########
@@ -36,62 +36,58 @@ SPIRVSupport::SPIRVSupport(tvm::Target target) {
   TVM_FFI_ICHECK(device_type == kDLVulkan || device_type == kDLOpenCL || 
device_type == kDLWebGPU)
       << "Unsupported device type for SPIRV codegen:" << device_type;
 
-  if (target->GetAttr<Integer>("vulkan_api_version")) {
-    vulkan_api_version = 
target->GetAttr<Integer>("vulkan_api_version").value().IntValue();
+  if (target->GetAttr<int64_t>("vulkan_api_version")) {
+    vulkan_api_version = 
target->GetAttr<int64_t>("vulkan_api_version").value();
   }

Review Comment:
   ![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg)
   
   Instead of performing a double lookup (checking if the attribute is defined 
and then calling `.value()`), you can use `.value_or()` to simplify the code 
and avoid redundant map lookups. This pattern can be applied to all subsequent 
attribute lookups in this file.
   
   ```c
     vulkan_api_version = 
target->GetAttr<int64_t>("vulkan_api_version").value_or(vulkan_api_version);
   ```



-- 
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