rich7420 commented on code in PR #745:
URL: https://github.com/apache/mahout/pull/745#discussion_r2636966475


##########
qdp/qdp-python/src/lib.rs:
##########
@@ -94,8 +94,22 @@ impl QuantumTensor {
     /// Returns:
     ///     Tuple of (device_type, device_id) where device_type=2 for CUDA
     fn __dlpack_device__(&self) -> PyResult<(i32, i32)> {
-        // DLDeviceType::kDLCUDA = 2, device_id = 0
-        Ok((2, 0))
+        if self.ptr.is_null() {
+            return Err(PyRuntimeError::new_err("Invalid DLPack tensor 
pointer"));
+        }
+
+        unsafe {
+            // Read device_id from DLPack tensor metadata
+            // DLDeviceType::kDLCUDA = 2 (from dlpack.h)

Review Comment:
   oh my mistake , thanks!
   



##########
qdp/qdp-python/src/lib.rs:
##########
@@ -94,8 +94,22 @@ impl QuantumTensor {
     /// Returns:
     ///     Tuple of (device_type, device_id) where device_type=2 for CUDA
     fn __dlpack_device__(&self) -> PyResult<(i32, i32)> {
-        // DLDeviceType::kDLCUDA = 2, device_id = 0
-        Ok((2, 0))
+        if self.ptr.is_null() {
+            return Err(PyRuntimeError::new_err("Invalid DLPack tensor 
pointer"));
+        }
+
+        unsafe {
+            // Read device_id from DLPack tensor metadata

Review Comment:
   sure!



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

Reply via email to