viiccwen commented on code in PR #1100:
URL: https://github.com/apache/mahout/pull/1100#discussion_r2867112329
##########
qdp/qdp-python/src/pytorch.rs:
##########
@@ -56,6 +56,20 @@ pub fn is_cuda_tensor(tensor: &Bound<'_, PyAny>) ->
PyResult<bool> {
Ok(device_type == "cuda")
}
+const CUDA_ENCODING_METHODS: &[&str] = &["amplitude", "angle", "basis", "iqp",
"iqp-z"];
+
+fn format_supported_cuda_encoding_methods() -> String {
+ let quoted: Vec<String> = CUDA_ENCODING_METHODS
+ .iter()
+ .map(|method| format!("'{}'", method))
+ .collect();
+ let len = quoted.len();
+ if len == 1 {
+ return quoted[0].clone();
+ }
+ format!("{}, or {}", quoted[..len - 1].join(", "), quoted[len - 1])
+}
+
Review Comment:
the intent of this helper function can be more clean, manual length handling
and clone is unnecessary.
##########
qdp/qdp-python/src/pytorch.rs:
##########
@@ -56,6 +56,20 @@ pub fn is_cuda_tensor(tensor: &Bound<'_, PyAny>) ->
PyResult<bool> {
Ok(device_type == "cuda")
}
+const CUDA_ENCODING_METHODS: &[&str] = &["amplitude", "angle", "basis", "iqp",
"iqp-z"];
+
+fn format_supported_cuda_encoding_methods() -> String {
+ let quoted: Vec<String> = CUDA_ENCODING_METHODS
+ .iter()
+ .map(|method| format!("'{}'", method))
+ .collect();
+ let len = quoted.len();
+ if len == 1 {
+ return quoted[0].clone();
+ }
+ format!("{}, or {}", quoted[..len - 1].join(", "), quoted[len - 1])
+}
+
Review Comment:
The intent of this helper function can be more clean, manual length handling
and clone is unnecessary.
--
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]