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


##########
python/tvm_ffi/_optional_torch_c_dlpack.py:
##########
@@ -114,7 +114,7 @@ def load_torch_c_dlpack_extension() -> Any:  # noqa: 
PLR0912, PLR0915
             if not lib_path.exists():
                 raise RuntimeError("Failed to build torch c dlpack addon.")
 
-        lib = ctypes.CDLL(str(lib_path))
+        lib = ctypes.CDLL(str(lib_path), ctypes.RTLD_LOCAL)

Review Comment:
   ![critical](https://www.gstatic.com/codereviewagent/critical.svg)
   
   Using `ctypes.RTLD_LOCAL` directly will cause an `AttributeError` on Windows 
because this flag is not defined on that platform. To ensure cross-platform 
compatibility, you should use this flag conditionally.
   
   ```suggestion
           lib = ctypes.CDLL(str(lib_path), getattr(ctypes, "RTLD_LOCAL", 0))
   ```



##########
addons/torch_c_dlpack_ext/torch_c_dlpack_ext/core.py:
##########
@@ -42,7 +42,7 @@ def load_torch_c_dlpack_extension() -> None:
     )
     if not lib_path.exists() or not lib_path.is_file():
         raise ImportError("No matching prebuilt torch c dlpack extension")
-    lib = ctypes.CDLL(str(lib_path))
+    lib = ctypes.CDLL(str(lib_path), ctypes.RTLD_LOCAL)

Review Comment:
   ![critical](https://www.gstatic.com/codereviewagent/critical.svg)
   
   Using `ctypes.RTLD_LOCAL` directly will cause an `AttributeError` on Windows 
because this flag is not defined on that platform. To ensure cross-platform 
compatibility, you should use this flag conditionally.
   
   ```suggestion
       lib = ctypes.CDLL(str(lib_path), getattr(ctypes, "RTLD_LOCAL", 0))
   ```



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