This is an automated email from the ASF dual-hosted git repository.

guanmingchiu pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/mahout.git


The following commit(s) were added to refs/heads/main by this push:
     new 814c5669c [QDP] Add TensorFlow .pb support to unified encode() path 
(#891)
814c5669c is described below

commit 814c5669c1e42795ff6de735856ce4296dc65f4e
Author: Shivam Mittal <[email protected]>
AuthorDate: Wed Jan 21 16:21:02 2026 +0530

    [QDP] Add TensorFlow .pb support to unified encode() path (#891)
    
    - Added .pb extension handling in encode_from_file() method
    - Routes .pb files to encode_from_tensorflow() implementation
    - Updated error message to include .pb in supported formats
    - Updated docstring to document .pb file support
    - Updated README.md with TensorFlow format documentation
    
    Fixes #880
---
 qdp/qdp-python/README.md  |  2 ++
 qdp/qdp-python/src/lib.rs | 10 ++++++++--
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/qdp/qdp-python/README.md b/qdp/qdp-python/README.md
index 96828fc34..3558c6f23 100644
--- a/qdp/qdp-python/README.md
+++ b/qdp/qdp-python/README.md
@@ -44,6 +44,8 @@ uv run maturin develop
 - **Parquet** - `.parquet` files
 - **Arrow IPC** - `.arrow` or `.feather` files
 - **NumPy** - `.npy` files
+- **PyTorch** - `.pt` or `.pth` files
+- **TensorFlow** - `.pb` files (TensorProto format)
 
 ## Adding new bindings
 
diff --git a/qdp/qdp-python/src/lib.rs b/qdp/qdp-python/src/lib.rs
index 0baa4eb56..fbd5c91cb 100644
--- a/qdp/qdp-python/src/lib.rs
+++ b/qdp/qdp-python/src/lib.rs
@@ -218,7 +218,7 @@ impl QdpEngine {
     ///         - Python list: [1.0, 2.0, 3.0, 4.0]
     ///         - NumPy array: 1D (single sample) or 2D (batch) array
     ///         - PyTorch tensor: CPU tensor (float64 recommended; will be 
copied to GPU)
-    ///         - String path: .parquet, .arrow, .npy, .pt, .pth file
+    ///         - String path: .parquet, .arrow, .feather, .npy, .pt, .pth, 
.pb file
     ///         - pathlib.Path: Path object (converted via os.fspath())
     ///     num_qubits: Number of qubits for encoding
     ///     encoding_method: Encoding strategy ("amplitude" default, "angle", 
or "basis")
@@ -450,9 +450,15 @@ impl QdpEngine {
                 .map_err(|e| {
                     PyRuntimeError::new_err(format!("Encoding from PyTorch 
failed: {}", e))
                 })?
+        } else if path.ends_with(".pb") {
+            self.engine
+                .encode_from_tensorflow(path, num_qubits, encoding_method)
+                .map_err(|e| {
+                    PyRuntimeError::new_err(format!("Encoding from TensorFlow 
failed: {}", e))
+                })?
         } else {
             return Err(PyRuntimeError::new_err(format!(
-                "Unsupported file format. Expected .parquet, .arrow, .feather, 
.npy, .pt, or .pth, got: {}",
+                "Unsupported file format. Expected .parquet, .arrow, .feather, 
.npy, .pt, .pth, or .pb, got: {}",
                 path
             )));
         };

Reply via email to