viiccwen commented on code in PR #881:
URL: https://github.com/apache/mahout/pull/881#discussion_r2708937310


##########
qdp/qdp-core/src/gpu/encodings/amplitude.rs:
##########
@@ -411,8 +415,20 @@ impl AmplitudeEncoder {
 
 impl AmplitudeEncoder {
     /// Compute inverse L2 norm on GPU using the reduction kernel.
+    ///
+    /// # Arguments
+    /// * `device` - CUDA device reference
+    /// * `input_ptr` - Device pointer to input data (f64 array on GPU)
+    /// * `len` - Number of f64 elements
+    ///
+    /// # Returns
+    /// The inverse L2 norm (1/||x||_2) of the input data
+    ///
+    /// # Safety
+    /// The caller must ensure `input_ptr` points to valid GPU memory 
containing
+    /// at least `len` f64 elements on the same device as `device`.
     #[cfg(target_os = "linux")]
-    fn calculate_inv_norm_gpu(
+    pub unsafe fn calculate_inv_norm_gpu(

Review Comment:
   If we promote GPU norm computation later as a public feature (e.g. via a 
QuantumEncoder extension trait), maybe we can do a follow-up about design a 
dedicated safe wrapper and keep this function as an internal building block. 
WDYT?



##########
qdp/qdp-core/src/gpu/encodings/amplitude.rs:
##########
@@ -411,8 +415,20 @@ impl AmplitudeEncoder {
 
 impl AmplitudeEncoder {
     /// Compute inverse L2 norm on GPU using the reduction kernel.
+    ///
+    /// # Arguments
+    /// * `device` - CUDA device reference
+    /// * `input_ptr` - Device pointer to input data (f64 array on GPU)
+    /// * `len` - Number of f64 elements
+    ///
+    /// # Returns
+    /// The inverse L2 norm (1/||x||_2) of the input data
+    ///
+    /// # Safety
+    /// The caller must ensure `input_ptr` points to valid GPU memory 
containing
+    /// at least `len` f64 elements on the same device as `device`.
     #[cfg(target_os = "linux")]
-    fn calculate_inv_norm_gpu(
+    pub unsafe fn calculate_inv_norm_gpu(

Review Comment:
   Given this is an unsafe primitive that’s only used inside the core GPU 
pipeline, I’d lean towards making it `pub(crate)` for now and exposing only 
safe encoding APIs at the crate boundary.



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